Brandon Jaeger Posted May 5, 2006 Share Posted May 5, 2006 It says that I have an error in my SQL syntax and the query was empty and such. Here's the code:[code] $title = $_POST["title"]; $location = $_POST["location"]; $age = $_POST["age"]; $icq = $_POST["icq"]; $aim = $_POST["aim"]; $msn = $_POST["msn"]; $yahoo = $_POST["yahoo"]; $web = $_POST["homepage"]; $coder = $_POST["coder"]; $query = array(); $query[0] = sprintf("UPDATE ghw_users SET title='%s' WHERE id='%d'" , quote_smart($title) , $id); $query[1] = sprintf("UPDATE ghw_users SET location='%s' WHERE id='%d'" , quote_smart($location) , $id); $query[2] = sprintf("UPDATE ghw_users SET age='%s' WHERE id='%d'" , quote_smart($age) , $id); $query[3] = sprintf("UPDATE ghw_users SET icq='%s' WHERE id='%d'" , quote_smart($icq) , $id); $query[4] = sprintf("UPDATE ghw_users SET aim='%s' WHERE id='%d'" , quote_smart($aim) , $id); $query[5] = sprintf("UPDATE ghw_users SET msn='%s' WHERE id='%d'" , quote_smart($msn) , $id); $query[6] = sprintf("UPDATE ghw_users SET yahoo='%s' WHERE id='%d'" , quote_smart($yahoo) , $id); $query[7] = sprintf("UPDATE ghw_users SET homepage='%s' WHERE id='%d'" , quote_smart($homepage) , $id); $query[8] = sprintf("UPDATE ghw_users SET coder='%s' WHERE id='%d'" , quote_smart($coder) , $id); for($i = 0; $i < 9; $i++) mysql_query($query[i]) or die(mysql_error() . ". Report this to blah@blah.com"); function quote_smart($value) { if (get_magic_quotes_gpc()) $value = stripslashes($value); if (!is_numeric($value)) $value = "'" . mysql_real_escape_string($value) . "'"; return $value; }[/code] Quote Link to comment Share on other sites More sharing options...
jeremywesselman Posted May 5, 2006 Share Posted May 5, 2006 [code] <?php...for($i = 0; $i < 9; $i++) mysql_query($query[i]) or die(mysql_error() . ". Report this to blah@blah.com");...?>[/code]You need to add a $ in front of the $query[i]. It should be $query[$i].[!--coloro:#990000--][span style=\"color:#990000\"][!--/coloro--]Jeremy[!--colorc--][/span][!--/colorc--] Quote Link to comment Share on other sites More sharing options...
Brandon Jaeger Posted May 6, 2006 Author Share Posted May 6, 2006 Oh, duh. I'm used to coding C++ and such. Quote Link to comment 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.