
April 7th, 2005
10:59 PM
Neverside Newbie
Status: Offline!
Select.....
well the search tool doesnt work so im sorry if this has been said anywhere else 
But.....
Im using php to find an entry in a database if it satisfies two things, and if it does then do something (A) and if not do something else (B).....
"SELECT user, dlid FROM DATABASE WHERE (user = $username AND dlid = $dlid)"
Is the code which im using to query the sql database,
then using sql_num_rows , if there are any rows returned then do A, else do B
However this method isnt working and i havent the slightest idea why , maybe theres something wrong with the SQL query ?
ive stripped all the other parts of the code, because its phpnuke stuff 

April 7th, 2005
11:12 PM
Neversidian
Status: Offline!
can you post ur code?
try:
"SELECT user, dlid FROM DATABASE WHERE (user = '$username' AND dlid = '$dlid')"
___________________
-Developer
-Forum Leader
-NeverNET

April 7th, 2005
11:20 PM
The Unorthodox Idiot
Status: Offline!
"SELECT user, dlid FROM DATABASE WHERE (user = '$username', dlid = '$dlid')"
I think that may be it. Not sure. :-/
___________________
Originally posted by blackmesa:
Okay! thats the last time i search up goatse on google

April 7th, 2005
11:40 PM
Neverside Newbie
Status: Offline!
something as simple as that , im mega confused however now , because that has worked 
but i have other queries which are like this :
"SELECT title, filesize FROM DB WHERE lid = $dlid"
Why does this work but my others didnt - god i hate nuke 

April 8th, 2005
12:10 AM
Lost in Berkeley, CA
Status: Offline!
he put the variables between single quotes
___________________
There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live.

April 8th, 2005
12:22 AM
Neverside Newbie
Status: Offline!
yeh but why does one work without them ? 
or is it maybe the brackets () ?

April 8th, 2005
01:28 AM
Lost in Berkeley, CA
Status: Offline!
is $dlid an interger
___________________
There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live.

April 8th, 2005
02:17 AM
PHP Developer
Status: Offline!
When performing a mysql query, always, always, always put quotes around your variables.
ie:
<?php
$query = mysql_query("SELECT user, dlid FROM DATABASE WHERE user='$username' AND dlid='$dlid'") or die(mysql_error());
?>

April 8th, 2005
08:44 AM
One and The Same
Status: Offline!
because if you dont place quotes around you variables this can happen:
<?php
$var = "123 Avenue Street";
$query = mysql_query("SELECT * FROM `db` WHERE `address` = $var");
// PHP would sub $var into this and the mysql query would then read
// mysql_query("SELECT * FROM `db` WHERE `address` = 123 Avenue Street");
// So mysql reads `address` = 123 and then the space ends that bit of the query,
// so it trues to read avenue as a column, keyword, etc and has a spaz.
// However:
$query = mysql_query("SELECT * FROM `db` WHERE `address` = '$var'");
// PHP would sub $var into this and the mysql query would then read
// mysql_query("SELECT * FROM `db` WHERE `address` = '123 Avenue Street'");
// which makes perfect sense to mysql; that address equals the string 123 avenue street.
?>
___________________
:: We can be in the world, What we want to be ::
Last edited by Daystar, April 8th, 2005 08:44 AM (Edited 1 times)

April 9th, 2005
10:43 PM
Neverside Newbie
Status: Offline!
ah great , cheers for clearing that up for me Daystar 