Page 1 of 1

Needing help with the insert into command please.

Posted: Mon Oct 23, 2006 5:23 am
by calumstevens
Hey guys,

My first post here, hoping someone could throw some pointers my way, I really doubt the problems too complicated for you hehe :)

So I've just started experimenting in php and mysql, and am attempting to write information taken from a form, to a database. Ill be damned if I can get it to work, I cant escape the evil clutches of this error message: 'Parse error: parse error, unexpected T_VARIABLE in C:\xampplite\phpMyAdmin\customer\addcustomer.php on line 10'. From what I can gather, this is on the query line. Any pointers would be hugely appreciated, thanks for your time people.

Code: Select all

<?php
	include "connection.php"
?>
<?php 
$newFirstname = $_POST['firstname']
$newSurname = $_POST['surname']
$newUsername = $_POST['username']
$newEmail = $_POST['email']
$newPassword = $_POST['password']

$query = "INSERT INTO Customer (Firstnames, Surname, Username, Email, Password) VALUES ('$newFirstname', '$newSurname', '$newUsername', '$newEmail', '$newPassword')";

$result = mysql_query($query) or die ("Error in query:$query. 
".mysql_error());

echo "New Record Inserted!";

  mysql_close($connection);     

?>

Posted: Mon Oct 23, 2006 6:21 am
by Chris Corbyn
You're missing semic-colons on virtually all of your code. You need semi-colons to mark the end of a statement ;)

FYI: Please put

Code: Select all

 [/php ] tags around your code when posting on the forum to make it easier for us to read :)

:arrow: Moved to PHP Code

Posted: Mon Oct 23, 2006 6:38 am
by calumstevens
yehah I love you xD lol, thanks alot!

Posted: Mon Oct 23, 2006 7:11 am
by calumstevens
Ok it would appear that my love for you is slightly premature lol.

Now my code has a few semi colons dotted about, once the form is submitted it appears to work perfectly, with 'new record inserted' being displayed. However the record does not appear to actually be inserted into the database. My db structure is shown below, I presumed that the customer id (as it is on auto increment) would effectively insert itself? Im not sure if thats what the problem is. Also, if you look at the above code, am I actually running the query? Or just effectively creating it?

CustomerID
Firstnames
Surname
Username
Email varchar
Password varchar

Any ideas?
Thanks in advance :)

Posted: Mon Oct 23, 2006 7:36 am
by GeXus
Column names are case sensitive, be sure those are right.

Posted: Mon Oct 23, 2006 7:40 am
by calumstevens
Thanks I didnt know that, but as luck would have it they were correct lol, still not working :(

Posted: Mon Oct 23, 2006 9:07 am
by Chris Corbyn
GeXus wrote:Column names are case sensitive.
Since when? :?

Posted: Mon Oct 23, 2006 11:55 am
by calumstevens
Ok its working :) thanks alot for the tips guys.