Needing help with the insert into command please.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
calumstevens
Forum Commoner
Posts: 25
Joined: Mon Oct 23, 2006 5:16 am

Needing help with the insert into command please.

Post 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);     

?>
Last edited by calumstevens on Mon Oct 23, 2006 7:24 am, edited 1 time in total.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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
calumstevens
Forum Commoner
Posts: 25
Joined: Mon Oct 23, 2006 5:16 am

Post by calumstevens »

yehah I love you xD lol, thanks alot!
calumstevens
Forum Commoner
Posts: 25
Joined: Mon Oct 23, 2006 5:16 am

Post 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 :)
GeXus
Forum Regular
Posts: 631
Joined: Sat Mar 11, 2006 8:59 am

Post by GeXus »

Column names are case sensitive, be sure those are right.
calumstevens
Forum Commoner
Posts: 25
Joined: Mon Oct 23, 2006 5:16 am

Post by calumstevens »

Thanks I didnt know that, but as luck would have it they were correct lol, still not working :(
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

GeXus wrote:Column names are case sensitive.
Since when? :?
calumstevens
Forum Commoner
Posts: 25
Joined: Mon Oct 23, 2006 5:16 am

Post by calumstevens »

Ok its working :) thanks alot for the tips guys.
Post Reply