Selection issue

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
thefreebielife
Forum Contributor
Posts: 126
Joined: Thu Apr 26, 2007 2:59 pm

Selection issue

Post by thefreebielife »

Code: Select all

else 
		$sql="select * from users where site=Cash order by uId";
	}
$result = mysql_query($sql)
or die(mysql_error()); 
$i = 0;
//grab all the content
while($r=mysql_fetch_array($result))
{	
That code displays nothing, I assume there is a problem with the "where" because i get this error
"Unknown column 'Cash' in 'where clause'"
Thanks,
Jared
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

You have to mark string literals for mysql with single quotes.
site='Cash'
thefreebielife
Forum Contributor
Posts: 126
Joined: Thu Apr 26, 2007 2:59 pm

Post by thefreebielife »

I tried - but now theres no error, but no data.
nickvd
DevNet Resident
Posts: 1027
Joined: Thu Mar 10, 2005 5:27 pm
Location: Southern Ontario
Contact:

Post by nickvd »

Maybe there IS no data to display...

Try your query in phpmyadmin...
thefreebielife
Forum Contributor
Posts: 126
Joined: Thu Apr 26, 2007 2:59 pm

Post by thefreebielife »

No, there is data... since the default for "site" IS "Cash".. but from now on it may vary. What "site" may be.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

There evidently is no rows with Site = 'Cash' if no rows were returned..

Can you provide a same export of your table with data?

Moved to Databases.
Post Reply