sweinkauf13 Posted January 8, 2009 Share Posted January 8, 2009 OK. all this script is suppose to do is add the user input into a mysql table. but i get this error:" Parse error: parse error in arcade_add.php on line 22". First is line 22 and then there is the rest of my script incase i counted wrong. $db = @mysql_select_db("$my_db", $connection) or die(mysql_error()); <?session_start();if(($_SESSION[username] == "") ||($_SESSION[password] == "")){header("location: login.phtml");exit;}?><?$id = "$_POST[id]";$g_name = "$_POST[gamename]";$g_dis = "$_POST[discription]";$g_code = "$_POST[gamecode]";$g_width = "$_POST[width]";$g_height = "$_POST[height]";#$my_db = "arcade";$connection = @mysql_connect("localhost","user","pass") or die(mysql_error());$db = @mysql_select_db("$my_db", $connection) or die(mysql_error());$sql = "insert into games (game_id, gamename, gamediscription, gamelink, gamecode, width,height) values (\"$id\",\"$g_name\",\"$g_dis\","<form method=\"post\" action=\"playgame.phtml\"><input type=\"hidden\" name=\"game\" value=\"$id\"><input type=\"submit\" value=\"Play Game\" class=\"playgame\"></form>\",\"$g_code\",\"$g_width\",\"$g_height\")";$result = @mysql_query("$sql", $connection) or die(mysql_error());?><?session_start();if(($_SESSION[username] == "") ||($_SESSION[password] == "")){header("location: login.phtml");exit;}?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head><title>Family Connection</title><link rel=stylesheet type="text/css" href="style.css"><link rel=icon type="image/x-icon" href="fav_icon.ico"></head><body><p class="adminmenu"><OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="138" height="204"><PARAM name="movie" value="flashvortex.swf"><PARAM name="quality" value="best"><PARAM name="menu" value="true"><PARAM name="allowScriptAccess" value="always"><EMBED src="flashvortex.swf" quality="best" menu="true" width="138" height="204" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" allowScriptAccess="always"></EMBED></OBJECT></p><div class="home_outline"><br><br><p><center><img src="header_image.gif" alt="Header Image" width="625"></center></p> <div class="login_body"><p>Welcome, <? echo "$_SESSION[real_name]"; ?> [<a href="http://localhost/familyconnection.com/logout.php">Log Out</a>]</p> <div class="menu"><div class="button_1"><a href="http://localhost/familyconnection.com/home.phtml" class="button"><p>Home<p></a></div><div class="button_2"><center><a href="http://localhost/familyconnection.com/add_date_step_one.php" class="button"><p>Add A Date To The Calandar</p></a></center></div><div class="button_3"><center><a href="http://localhost/familyconnection.com/fms/index.php" class="button"><p>Family Mail Service</p></a></center></div><div class="button_4"><center><p><a href="http://localhost/familyconnection.com/feedback.phtml" class="button">Feedback</a></p></center></div><div class="button_5"><center><p><a href="http://localhost/familyconnection.com/quick_links.phtml" class="button">Quick Links</a></p></center></div><div class="button_6"><center><p><a href="http://localhost/familyconnection.com/arcade.phtml" class="button">Arcade</a></p></center></div><?If($_SESSION[username] == "admin"){$button = "<div class=\"button_7\"><center><p><a href=\"http://localhost/familyconnection.com/admin_mode/admin_index.phtml\" class=\"button\">Admin Mode</a></p></center></div>";#echo("$button");}else{$button = "<div class=\"button_7\"><center><p><a href=\"http://localhost/familyconnection.com/picks.phtml\" class=\"button\">Top Picks</a></p></center></div>";echo("$button");}?><br><br><br><p><hr size="2" color="black" class="divide_line"></p><br><p>Game was entered!!!</p><p> please help me!!!-youngwebmaster Link to comment Share on other sites More sharing options...
Wander Posted January 9, 2009 Share Posted January 9, 2009 ur dubble-quotes get messy in $sql around the form stuff, i'd suggest u use single quotes more$sql = "insert into games (game_id, gamename, gamediscription, gamelink, gamecode, width,height) values ('$id','$g_name','$g_dis','<form method=\"post\" action=\"playgame.phtml\"><input type=\"hidden\" name=\"game\" value=\"$id\"><input type=\"submit\" value=\"Play Game\" class=\"playgame\"></form>','$g_code','$g_width','$g_height')"; Link to comment Share on other sites More sharing options...
jlhaslip Posted January 9, 2009 Share Posted January 9, 2009 Try removing the Error Suppresion "@" signs in front of the mysql commands to see if there are other issues. Link to comment Share on other sites More sharing options...
sweinkauf13 Posted January 15, 2009 Author Share Posted January 15, 2009 Thank you Wander and jlhaslip for helping me. My script works now.But now i have a different problem. I have a script somewhat like this. It enters info into a mysql database and it is supose to auto-increment the column titled "id". But it doesn't increment. It just sets every entry id to 0? The script is posted below. Please help me yet again. <?session_start();if(($_SESSION[username] == "") ||($_SESSION[password] == "")){header("location: login.phtml");exit;}?><?################Add date################$connection = @mysql_connect('localhost','user','pass') or die(mysql_error());$database = "familyconnection";$db = @mysql_select_db("$database", $connection) or die(mysql_error());#for($i=0; $i< $_POST[fieldcount]; $i++){$sql = "insert into calandar(id, date, discription) values (\"\",'{$_POST[month][$i]} {$_POST[day][$i]} {$_POST[year][$i]}','{$_POST[discription][$i]}');"; #$result = @mysql_query("$sql", $connection) or die(mysql_error());}#?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head><title>Family Connection</title><link rel=stylesheet type="text/css" href="style.css"></head><body><div class="login_outline"><br><br><p><center><img src="header_image.gif" alt="Header Image" width="625"></center></p> <div class="login_body"><p>Welcome, <? echo "$_SESSION[real_name]"; ?> [<a href="logout.php">Log Out</a>]</p> <div class="menu"><div class="button_1"><a href="home.phtml" class="button"><p>Home<p></a></div><div class="button_2"><center><a href="add_date_step_one.php" class="button"><p>Add A Date To The Calandar</p></a></center></div><div class="button_3"><center><a href="fms/index.php" class="button"><p>Family Mail Service</p></a></center></div><div class="button_4"><center><p><a href="feedback.phtml" class="button">Feedback</a></p></center></div><div class="button_5"><center><p><a href="quick_links.phtml" class="button">Quick Links</a></p></center></div><div class="button_6"><center><p><a href="arcade.phtml" class="button">Arcade</a></p></center></div><?If($_SESSION[username] == "admin"){$button = "<div class=\"button_7\"><center><p><a href=\"admin_mode/admin_index.phtml\" class=\"button\">Admin Mode</a></p></center></div>";#echo("$button");}else{$button = "<div class=\"button_7\"><center><p><a href=\"picks.phtml\" class=\"button\">Top Picks</a></p></center></div>";echo "$button";}?><br><br><br><p><hr size="2" color="black" class="divide_line"></p><p>Your date(s) were added. Please choose an option above.</p> Thanks in advace,youngwebmaster Link to comment Share on other sites More sharing options...
Wander Posted January 15, 2009 Share Posted January 15, 2009 to make a column automatically auto-increment you have to set it that way in sqlif you have phpmyadmin you can edit the column and at Extra set it on AUTO_INCREMENT, i believe the table has to be empty to change this Link to comment Share on other sites More sharing options...
justsomeguy Posted January 19, 2009 Share Posted January 19, 2009 And don't include the autonumber field in the insert statement, just leave it out. If you specify a value for a field, even if the field is an autonumber, it's going to use whatever you give it. Since you're giving it an empty string, it casts that to an integer, gets 0, and inserts using that. Just leave the field out of the insert statement. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.