View Full Version: MySQL problem

Fake2knet > programming & game design > MySQL problem



Title: MySQL problem


iceklown - February 15, 2008 02:47 AM (GMT)
Moved to a new server, on old server all php files worked fine, now I am getting errors on simple mysql_connect issue.

http://www.focal-point.org/view.php?id_num=1

This is the code he sent me he said he is using....
mysql_connect("localhost", "UNAME", "PASS") or die("Failed"); mysql_select_db("focalp_main"); $query = "SELECT * FROM users WHERE id = $id_num"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result);

thats line 1.
am I missing something? MySQL is version 5, and php is version 5

mooty - February 15, 2008 09:41 AM (GMT)
IT might be fussy..

SELECT * FROM `users` WHERE `id` = '$id_num'

iceklown - February 15, 2008 06:02 PM (GMT)
nope, still does it

mooty - February 15, 2008 06:11 PM (GMT)
'$id_num' as opposed to $id_num.

iceklown - February 15, 2008 07:49 PM (GMT)
Unknown column '' in 'where clause'

its not carrying the $id_num into the page when I put two `'s in

mickygor - February 15, 2008 08:34 PM (GMT)
For the variable it's got to be 's, not `s.

iceklown - February 15, 2008 09:22 PM (GMT)
still nothing.

squirrel - February 29, 2008 11:55 AM (GMT)
So long as $id_num is numeric, this should work.

CODE

$query = sprintf('SELECT * FROM users WHERE id = %d', $id_num);




Hosted for free by InvisionFree