Hi It seems on my php script whenever i submit data to the database it shows this 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 'show, height, width ) VALUES ( 'ep name', 'ep descriptio' at line 7 Code (markup): The php is as follows: <?php $host = "localhost"; // The host for your server, this is usually localhost. $user = "xnalarac"; // Your username for the SQL. $database = "xnalarac_scifi"; // This is the database you created for this script, this is usually username_databasename $password = "*******"; // The password for the SQL. $conn = mysql_connect("{$host}","{$user}","{$password}"); mysql_select_db("{$database}", $conn); function p($s){ return mysql_real_escape_string(htmlspecialchars($s)); } if($_POST['input']){ $name = p($_POST['name']); $desciption = p($_POST['desciption']); $swf = p($_POST['swf']); $episode = p($_POST['episode']); $series = p($_POST['series']); $show = p($_POST['show']); $height = p($_POST['height']); $width = p($_POST['width']); $q = mysql_query("INSERT INTO Episode ( name, desciption, swf, episode, series, show, height, width ) VALUES ( '{$name}', '{$desciption}', '{$swf}', '{$episode}', '{$series}', '{$show}', '{$height}', '{$width}' )") or die (mysql_error()); echo ($q == false) ? "An error occured!" : "Success! yay"; }else{?> <form method="post"> <input type="hidden" name="input" value="1"/> Episode Name: <input type="text" name="name" /> <br /> Episode Description: <input type="text" name="desciption" /> <br /> Episode SWF: <input type="text" name="swf" /> <br /> Episode Number <input type="text" name="episode" /> <br /> Series: <input type="text" name="series" /> <br /> Show: <select name="category"><? $c = mysql_query("SELECT * FROM Shows"); while($a = mysql_fetch_assoc($c)){ echo "<option value='{$a['id']}'>{$a['showname']}</option>"; }?> </select> <br /> Height: <input type="text" name="height" /> <br /> Width: <input type="text" name="width" /> <br /> </select> <br /> <input type="submit" name="input" value="Submit" /> </form> <?}?> PHP: The database is fine and the login details are fine. but we can't find any errors in the script Thank you for your help. -sbaldam1992
Hi, Show is MySQL reserved word and you use it as column name! try `show` instead: $q = mysql_query("INSERT INTO Episode ( name, desciption, swf, episode, series, `show`, ............................ PHP: Regards
just change the name of your "$show" variable to something else & run the script, then you will be fine. But make sure that you will not again choose any reserved MySql keyword Thanks, Jimmy