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

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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