vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   = works fine but != messed up the query? (https://vborg.vbsupport.ru/showthread.php?t=75236)

sabret00the 01-27-2005 02:32 PM

= works fine but != messed up the query?
 
this is the query
PHP Code:

    $grps_newestmembers $DB_site->query("
        SELECT grps_user.groupid,grps_user.userid, user.username, grps_user.join_date,grps_user.mod_queue
        FROM grps_user
        LEFT JOIN user ON (user.userid = grps_user.userid)
        WHERE grps_user.groupid = 
$groupid AND grps_user.mod_queue != 1
        ORDER BY grps_user.join_date DESC
    "
); 

has php stopped supporing != overnight or am i just being stupid and doing something wrong?

Natch 01-27-2005 02:42 PM

PHP is fine with it, but SQL prefers NOT (iirc)

Marco van Herwaarden 01-27-2005 02:44 PM

Try "<>" instead of "!=" ;)

Lol a lot of different answers :D

IIRC "<>" is the official SQL notation, "!=" is added later i think (MySQL only???, what version??).

But what happens, you get an error, it don't function like expected?

sabret00the 01-27-2005 02:49 PM

Quote:

Originally Posted by MarcoH64
Try "<>" instead of "!=" ;)

Lol a lot of different answers :D

IIRC "<>" is the official SQL notation, "!=" is added later i think (MySQL only???, what version??).

But what happens, you get an error, it don't function like expected?

still returning nothing :(

the table looks like this
Code:

groupid            userid            username            join_date            mod_queue
7        10        sabret00the        1106842883        1
7        64        user2        1106661929        NULL

so it should return the one with NULL in it, shouldn't it?

Quote:

Originally Posted by MarcoH64
But what happens, you get an error, it don't function like expected?

no error it just returns no data :(

Marco van Herwaarden 01-27-2005 02:58 PM

Are you 100% sure that $groupid contain "7"?

What are the fieldtypes?

Are these userid's in the user table?

PS you could try running it without the test on mod_queue to find where the error is.

Edit try changing that NULL value to 0.

sabret00the 01-27-2005 03:43 PM

groupid is definately 7
fieldtypes, oh mod_queue is set at tinyint(4)
the userid's are in the grps_user table
it works without the mod_queue clause, it's just that that's causing the problem?
even with NULL set as 0 it don't work?

Dean C 01-27-2005 03:47 PM

Change this:

PHP Code:

 $grps_newestmembers $DB_site->query("
        SELECT grps_user.groupid,grps_user.userid, user.username, grps_user.join_date,grps_user.mod_queue
        FROM grps_user
        LEFT JOIN user ON (user.userid = grps_user.userid)
        WHERE grps_user.groupid = 
$groupid AND grps_user.mod_queue != 1
        ORDER BY grps_user.join_date DESC
    "
); 

To this:

PHP Code:

 echo("
        SELECT grps_user.groupid,grps_user.userid, user.username, grps_user.join_date,grps_user.mod_queue
        FROM grps_user
        LEFT JOIN user ON (user.userid = grps_user.userid)
        WHERE grps_user.groupid = 
$groupid AND grps_user.mod_queue != 1
        ORDER BY grps_user.join_date DESC
    "
); 

Show us what it outputs to the browser :)

sabret00the 01-27-2005 03:50 PM

Code:

SELECT grps_user.groupid,grps_user.userid, user.username, grps_user.join_date,grps_user.mod_queue FROM grps_user LEFT JOIN user ON (user.userid = grps_user.userid) WHERE grps_user.groupid = 7 AND grps_user.mod_queue != 1 ORDER BY grps_user.join_date DESC

Dean C 01-27-2005 04:01 PM

Ok we have some issues with your database model here. You have some data redundancy in the fact you have the username column in this grps_user table. Drop that column as you can get the users username via a join on the userid column. Also change the fieldtype of the mod_queue column to smallint, lenth 1, unsigned and default 0. Then try your query :up:

sabret00the 01-27-2005 04:27 PM

oops, that username was never apart of the grps_user column

here's the table straight from phpmyadmin
Code:

recordid            groupid            userid            join_date            mod_queue
Edit        Delete        4        3        10        1102848936        NULL
Edit        Delete        3        2        10        1102848632        NULL
Edit        Delete        13        6        10        1106781470        NULL
Edit        Delete        12        3        64        1106777848        NULL
Edit        Delete        9        2        64        1106568571        NULL
Edit        Delete        10        7        64        1106661929        NULL
Edit        Delete        14        6        64        1106781499        0
Edit        Delete        16        7        10        1106842883        1

now i just ran a query to change al them nulls to 1 and it never worked, i think theirs something seriously wrong with the mod_queue column

i'm gonna try and delete it and reinstall it, as i have no idea why it won't work still.

works fine now :( changed it to in_mod_queue just to be safe and it's working fine.

thank you everyone, sorry to waste your time.


All times are GMT. The time now is 02:33 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01075 seconds
  • Memory Usage 1,746KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code_printable
  • (3)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete