Jump to content

PHP Error - Inserting Data


Twist3d

Recommended Posts

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

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

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..

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.