Jump to content

syntax error message


thor_hitor

Recommended Posts

I did your form_response.php and it seemed to work but now I'm having an error message.

I get the same with typing in sql in my admin do you know what this is? thanks thor

 

 

 

 

<?php

 

 

////////////////////////////////////////////////////////////////////////////////////////////////////////////

 

//You can change the parameters in mysql_select_db("localhost","root","")

$myConnect = mysql_connect("localhost","root","");

if($myConnect)

{

echo "Connected to MySQL successful

";

}

else

{

die("Could not connect to MySQL" . mysql_error() . "

" );

}

$my_db = "hostitno_servicehuman";

$table_name = "name";

//Select the db you will work with

$db_name = mysql_select_db($my_db);

 

//Now you need to get the values from the form in myForm.html, right? Now see what I have here:

 

/*If you do not understand why this $_POST[] appears here then go to

http://www.w3schools.com/php/php_post.asp to get the answer

*/

$fullname = $_POST['firstname'];

$email = $_POST['email'];

/*

Now I will try to insert data into the table 'users' and see how it works

*/

//This $sql_insert is a simple inserting query .

$sql_insert = "INSERT INTO $table_name (first name,email) VALUES ('$fullname','$email')";

// Now we execute this query

$result = mysql_query($sql_insert);

//We are not sure if this query has executed successful or not, then we need to check it.

if($result)

{

echo"

Insert sucessfully...

";

}

else

{

echo"

Inserted error :".mysql_error()."

";

}

//You should close this connection after finished

mysql_close($myConnect);

?>

 

 

 

 

 

Connected to MySQL successful

 

Notice: Undefined index: firstname in C:\wamp\www\start_work.php on line 48

 

Notice: Undefined index: email in C:\wamp\www\start_work.php on line 49

 

Inserted 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 'name,email) VALUES ('','')' at line 1

Link to comment
Share on other sites

This is a guess, since I can't see the code that you use to create the form...

 

But I'm guessing that in these two lines, you are asking for data from form fields that aren't named correctly:

 

$fullname = $_POST['firstname'];

$email = $_POST['email'];

 

I'd suggest taking a look at the form fields, and making sure that you have inputs named "firstname" and "email". Make sure that they are spelled correctly and use the cases of the letters match up to the code in the PHP file.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...