Simple T_VARIABLE problem with SQL insert

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
houston
Forum Newbie
Posts: 17
Joined: Tue Jun 27, 2006 6:41 pm

Simple T_VARIABLE problem with SQL insert

Post by houston »

This is driving me nuts! I'm sure its something glaring that I'm just missing. Problematic line is marked with '***'

Code: Select all

<?php
	$header = rand(1, 2);
	$username = $_GET['newusername'];
	$joindate = $_GET['newjoindate'];
	$rank = $_GET['newrank'];
	$em = $_GET['newemail'];

	$link = mysql_connect("localhost", "xxx_xxx", "xxxx") or die("Could not connect : " . mysql_error());
	mysql_select_db("fatalpre_members") or die("Could not select database");
	$query = "INSERT INTO `roster` ( `id` , `username` , `joindate` , `rank` , `email` ) VALUES ( NULL , '$username', '$joindate', '$rank', '$em' );"
***	$result = mysql_query($query) or die("Query failed : " . mysql_error());
?>

returns this

Code: Select all

Parse error: parse error, unexpected T_VARIABLE in /home/fatalpre/public_html/insert.php on line 11
Last edited by houston on Tue Jun 27, 2006 7:01 pm, edited 2 times in total.
Robert Plank
Forum Contributor
Posts: 110
Joined: Sun Dec 26, 2004 9:04 pm
Contact:

Post by Robert Plank »

You need a semicolon at the end of this line

Code: Select all

$query = "INSERT INTO `roster` ( `id` , `username` , `joindate` , `rank` , `email` ) VALUES ( NULL , '$username', '$joindate', '$rank', '$em' );"
Like this:

Code: Select all

$query = "INSERT INTO `roster` ( `id` , `username` , `joindate` , `rank` , `email` ) VALUES ( NULL , '$username', '$joindate', '$rank', '$em' );";
houston
Forum Newbie
Posts: 17
Joined: Tue Jun 27, 2006 6:41 pm

Post by houston »

I'm not sure I understand, I think that last quotation is to set $query

removing it returns a parse error in line 11
houston
Forum Newbie
Posts: 17
Joined: Tue Jun 27, 2006 6:41 pm

Post by houston »

now I understand, thanks for your help Robert
Post Reply