Re: mysql_result .. what am i doing wrong ?

From: Date: Wed, 06 Sep 2000 05:55:06 +0000
Subject: Re: mysql_result .. what am i doing wrong ?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-15448@lists.php.net to get a copy of this message
In article <011b01c017bf$4213f350$6f01000a@PDX2KWKS>, petel@pdxeng.com ("Pete Lancashire") wrote: > I stole this from the check_date annotations but > mysql_result always returns a 1, not the result of the select. > > Must be something really simple .. > > $r = mysql_db_query("mydatabase", "SELECT > UNIX_TIMESTAMP('2000-6-12') as > testdate"); > if($d=mysql_result($r,0,'testdate') > 0) { > > $fname = mysql_field_name($r,0); <--test to verify field name > echo "fname:" . $fname . "<br>"; > > echo "d:". $d . "<br>"; <--- always 1 > echo date(" n F Y", $d) . "<br>"; > } Put some parentheses around your assignment statement. Maybe the > is happening first, and $d is getting "true" (1) stuffed into it from that. You could check the operator precedence on php.net, but it never hurts to add parens. If that ain't it, I would next suspect that '2000-6-12' is not being turned into a date properly, and thus you are just getting 1. I would try '2000-06-12' and maybe some sort of type-casting in MySQL (which I don't know how to do). Finally, check the docs to be sure mysql_result() returns the actual data and not a "resource id". I'm pretty sure it's the actual data, but could be wrong. -- Richard Lynch | If this was worth $$$ to you, buy a CD US Customer Support Director | from one of the artists listed here: Zend Technologies USA | http://www.L-I-E.com/artists.htm http://www.zend.com | (this has nothing to do with Zend, duh!)

« previous php.general (#15448) next »