Twist3d Posted December 21, 2009 Share Posted December 21, 2009 Hello. Well i can't see the problem with this error: Here is the code to add the form information into the database: <?php //Connecting to PHP mysql_query("INSERT INTO data (sname, serverip, sport, sdetail, details, server owner, Deob, password) VALUES ('{$_POST['servername']}', '{$_POST['serverip']}', '{$_POST['port']}', '{$_POST['sdetails']}', '{$_POST['details']}, '{$_POST['serverowner']}', '{$_POST['deob']}', '{$_POST['password']}')") or die(mysql_error()); And here is the form: <form action="addserver2.php" method="post"> <center> <br /> Server Name: <input type="text" name="servername" /> <br /> Server IP: <input type="text" name="serverip" /> <br /> Port: <input type="text" name="port" /> <br /> Short Details: <input type="text" name="sdetails" maxlength="100"/> <br /> Details: <input type="text" name="details" /> <br /> Server Owner: <input type="text" name="serverowner" /> <br /> Deob: <input type="text" name="deob" /> <br /> Password: <input type="password" name="password" /> <br /> <input name="submit" type="submit" value="Submit" /> </form> </center> And here is 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 'owner, Deob, password) VALUES ('ServerName', 'ServerIP', 'Port', 'Details', 'Se' at line 1 I think that means i mistyped something. But i have checked and checked over, i can't see it. Any help? SORRY ALSO, this will be the last 1 for the night. Link to comment https://forums.phpfreaks.com/topic/185844-php-error-inserting-data/ Share on other sites More sharing options...
Deoctor Posted December 21, 2009 Share Posted December 21, 2009 u cannot have a space in the field names of a table sname, serverip, sport, sdetail, details, server owner, Deob, password in this server owner is wrong change it to server_owner Link to comment https://forums.phpfreaks.com/topic/185844-php-error-inserting-data/#findComment-981321 Share on other sites More sharing options...
Twist3d Posted December 21, 2009 Author Share Posted December 21, 2009 ok i changed. New 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 'Server Owner', 'Deob', 'password')' at line 2 Link to comment https://forums.phpfreaks.com/topic/185844-php-error-inserting-data/#findComment-981326 Share on other sites More sharing options...
Deoctor Posted December 21, 2009 Share Posted December 21, 2009 u have alter the table structure not the query.. Link to comment https://forums.phpfreaks.com/topic/185844-php-error-inserting-data/#findComment-981327 Share on other sites More sharing options...
Twist3d Posted December 21, 2009 Author Share Posted December 21, 2009 Ok the database now has serverowner as the field. and altered the code. New 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 'Server Owner', 'Deob', 'password')' at line 2 And this is retarded. mysql_query("INSERT INTO data (sname, serverip, sport, sdetail, details, serverowner, Deob, password) VALUES ('{$_POST['servername']}', '{$_POST['serverip']}', '{$_POST['port']}', '{$_POST['sdetails']}', '{$_POST['details']}, '{$_POST['serverowner']}', '{$_POST['deob']}', '{$_POST['password']}')") That is the new query. serverowner has been changed, and still 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 'Server Owner', 'Deob', 'password')' at line 2 Link to comment https://forums.phpfreaks.com/topic/185844-php-error-inserting-data/#findComment-981330 Share on other sites More sharing options...
Deoctor Posted December 21, 2009 Share Posted December 21, 2009 change this line ('{$_POST['servername']}','{$_POST['serverip']}', '{$_POST['port']}', '{$_POST['sdetails']}','{$_POST['details']}, '{$_POST['serverowner']}', '{$_POST['deob']}','{$_POST['password']}')") like this ('{$_POST['servername']}','{$_POST['serverip']}', '{$_POST['port']}', '{$_POST['sdetails']}','{$_POST['details']}', '{$_POST['serverowner']}', '{$_POST['deob']}','{$_POST['password']}')") u forgot to close the inverted tags after the details.. Link to comment https://forums.phpfreaks.com/topic/185844-php-error-inserting-data/#findComment-981333 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.