DeathStar Posted February 17, 2007 Share Posted February 17, 2007 Well i have been coding this script for a part game/mod but it wont work ?!? I get the error : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 But i cxant find anything wrong! Can anyone help me? the script <?php session_start(); //connect to the config file include "config_o.php"; $userid=$_SESSION['userid']; $date=date('Y'); //generate a random image $ranimg = rand(1,5); //end random // Collects data from "users" table $da = mysql_query("SELECT * FROM users WHERE userid=$userid") or die(mysql_error()); // puts the "users" info into the $info array $ds = mysql_fetch_array($da ); // Collects data from "settings" table $da1 = mysql_query("SELECT * FROM settings") or die(mysql_error()); // puts the "settings" info into the $info array $ds1 = mysql_fetch_array($da ); // print the contents of the file print "<table><td>"; //style print "<b>Name:</b> {$ds['name']} <br><b>Level:</b> {$ds['level']} <br><b>Gold Cions:</b> {$ds['gcoins']}"; //if statements(race) if ($ds['race'] == 1) { $srace = print "Human"; } else if ($ds['race'] == 2) { $srace = print "Dragon"; } if ($ds['race'] == 3) { $srace = print "Elf"; } else if ($ds['race'] == 4) { $srace = print "Alien"; } if ($ds['race'] ==5) { $srace = print "Paranormal"; } //print race print "<br><b>Race:</b> $race"; //end if //if statments (subrace) if ($ds['srace'] == 1) { $srace = print "Workers"; } else if ($ds['srace'] == 2) { $srace = print "Craftmens"; } if ($ds['srace'] == 3) { $srace = print "Mages"; } else if ($ds['srace'] == 4) { $srace = print "Warriors"; } if ($ds['srace'] ==5) { $srace = print "Archers"; } //print srace print "<br><b>Sub Race:</b> $srace"; //end if print "<br><b>Place:</b> {$ds['place']} >> {ds['splace']}<br> Click <a href='mainstats.php'>here</a> for main stats. <br>Click <a href='substats.php'>here</a> for sub stats."; print "</td><td>"; //get a random image if ($ranimg == 1) { print "<img scr='{$ds1['banner1']}'>"; } else if ($ranimg == 2) { print "<img scr='{$ds1['banner2']}'>"; } if ($ranimg == 3) { print "<img scr='{$ds1['banner3']}'>"; } else if ($ranimg == 4) { print "<img scr='{$ds1['banner4']}'>"; } if ($ranimg == 5) { print "<img scr='{$ds1['banner5']}'>"; } print "</td></table><br><BR>"; print "<center><i><center>Copyright © $date #####.</center></i>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/38934-solved-fairly-simple-script/ Share on other sites More sharing options...
fert Posted February 17, 2007 Share Posted February 17, 2007 $da = mysql_query("SELECT * FROM users WHERE userid=$userid") should be $da = mysql_query("SELECT * FROM users WHERE userid='$userid'") Quote Link to comment https://forums.phpfreaks.com/topic/38934-solved-fairly-simple-script/#findComment-187257 Share on other sites More sharing options...
DeathStar Posted February 17, 2007 Author Share Posted February 17, 2007 hmm... That worked. [move]Thanks. [/move] But how can the error message say error at line 1 and its at line 16? Quote Link to comment https://forums.phpfreaks.com/topic/38934-solved-fairly-simple-script/#findComment-187258 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.