Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

72 users online



Select.....

Select.....

Currently viewing this thread: 1 (0 members and 1 guests)


Page 1 out of 2
factoria

factoria

Neverside Newbie
Status: Offline!

Select.....

well the search tool doesnt work so im sorry if this has been said anywhere else Smile

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 Sad

aonic

aonic

Neversidian
Status: Offline!

can you post ur code?
try:
"SELECT user, dlid FROM DATABASE WHERE (user = '$username' AND dlid = '$dlid')"

___________________

-Developer
-Forum Leader
-NeverNET

chatmasta

chatmasta

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

factoria

factoria

Neverside Newbie
Status: Offline!

something as simple as that , im mega confused however now , because that has worked Grin

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 Smile

TheClincher

TheClincher

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.

factoria

factoria

Neverside Newbie
Status: Offline!

yeh but why does one work without them ? Smile

or is it maybe the brackets () ?

TheClincher

TheClincher

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.

VantageX4

VantageX4

PHP Developer
Status: Offline!

When performing a mysql query, always, always, always put quotes around your variables.

ie:

PHP:

<?php

$query 
mysql_query("SELECT user, dlid FROM DATABASE WHERE user='$username' AND dlid='$dlid'") or die(mysql_error());

?>

Daystar

Daystar

One and The Same
Status: Offline!

because if you dont place quotes around you variables this can happen:

PHP:

<?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)

factoria

factoria

Neverside Newbie
Status: Offline!

ah great , cheers for clearing that up for me Daystar Smile

Page 1 out of 2
Quick Jump:

Main Navigation


Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach


NeverAPI generated this page in 0.0088 seconds.