Thread: Please Help
View Single Post
Old 04-12-2005, 11:05 AM   #1 (permalink)
jsims
Registered User
 
Join Date: Apr 2005
Posts: 2
jsims is on a distinguished road
Please Help

Hi I am having a problem with understanding how to put data into mysql using php

Here is a script I am using.
I found it on a tutorial on the web and did exactly what it said to do. But when I try to check it. I get an error:
Parse error: syntax error, unexpected T_VARIABLE in C:\Documents and Settings\John Sims\My Documents\phpandmyql\scripts_named\12\html\test1.p hp on line 26

Can anyone help me. Please

John
PHP Code:
// Set Mysql Variables
$host = 'localhost';
$user = 'root';
$pass = '';
$db = 'ex';
$table = 'comment';

// Set global variables to easier names
$uname = $_GET['uname'];
$ucomment = $_GET['ucomment'];

// Connect to Mysql, select the correct database, and run teh query which adds the data gathered from the form into the database
mysql_connect($host,$user,$pass) or die(mysql_error());
mysql_select_db($db) or die(mysql_error());
$add_all = 'INSERT INTO $table values('$uname','$ucomment','$ip','$time','')';
mysql_query($add_all) or die(mysql_error());
}

else
{

// If the form has not been submitted, display it!
?>
<form method='get' action='<? echo'$PHP_SELF'?>'>
Name : <input type='text' name='uname'><br><br>
Comment : <input type='text' name='ucomment'><br><br>
<input type='hidden' name='commented' value='set'>
<input type='submit' value='Post your comment'>
</form>
<?
}
?>
jsims is offline   Reply With Quote