Help with unexpected T_VARIABLE |
Help with unexpected T_VARIABLE |
tyler.watkins |
Apr 5 2012, 04:17 PM
Post
#1
|
Novice Group: Members Posts: 27 Joined: 6-March 12 Member No.: 16,654 |
<?php
$mysql_database="********"; $mysql_host="********"; $mysql_user="******"; $mysql_password="******"; $link= mysql_connect($mysql_host, $mysql_user, $mysql_password); if (!$con) { die('Could not connect: ' . mysql_error()); } $fname=$_POST['fname']; $lname=$_POST['lname']; $user=$_POST['username']; $password=$_POST['password']; $email=$_POST['email']; mysql_select_db("$mysql_database",$con) $table="CREATE TABLE username <-------This is the line the problem is on, it says "Parse error: syntax error, unexpected T_VARIABLE". Please help!! ($fname varchar(30), $lname varchar(30), $username varchar(30), $password varchar(30), $email varchar(30) )"; mysql_query($table,$con); mysql_close($con); ?> This information is from a form. This post has been edited by tyler.watkins: Apr 5 2012, 04:18 PM |
tyler.watkins |
Apr 5 2012, 06:25 PM
Post
#2
|
Novice Group: Members Posts: 27 Joined: 6-March 12 Member No.: 16,654 |
This is the EXACT format I was shown to use by multiple websites, i even copied and pasted their examples and still get the same message.
|
pandy |
Apr 5 2012, 06:28 PM
Post
#3
|
🌟Computer says no🌟 Group: WDG Moderators Posts: 20,716 Joined: 9-August 06 Member No.: 6 |
I'm no programmer but it looks like a right hand quote is missing on that line.
|
tyler.watkins |
Apr 5 2012, 06:35 PM
Post
#4
|
Novice Group: Members Posts: 27 Joined: 6-March 12 Member No.: 16,654 |
I'm no programmer either, but if you look down a few more lines there is the end quote. I've tried putting a quote there and it still won't work
|
Ephraim F. Moya |
Apr 5 2012, 10:34 PM
Post
#5
|
Advanced Member Group: Members Posts: 167 Joined: 2-September 07 From: New Mexico Member No.: 3,702 |
<?php $mysql_database="********"; $mysql_host="********"; $mysql_user="******"; $mysql_password="******"; $link= mysql_connect($mysql_host, $mysql_user, $mysql_password); if (!$con) { die('Could not connect: ' . mysql_error()); } $fname=$_POST['fname']; $lname=$_POST['lname']; $user=$_POST['username']; $password=$_POST['password']; $email=$_POST['email']; mysql_select_db("$mysql_database",$con) $table="CREATE TABLE username <-------This is the line the problem is on, it says "Parse error: syntax error, unexpected T_VARIABLE". Please help!! ($fname varchar(30), $lname varchar(30), $username varchar(30), $password varchar(30), $email varchar(30) )"; mysql_query($table,$con); mysql_close($con); ?> This information is from a form. Most likely what you want is: ------------------------------------ $con = mysql_connect( $mysql_host, $mysql_user, $mysql_password ); if ( !$con ) { die( 'Could not connect: ' . mysql_error() ); } ------------------------------------- mysql_select_db( "$mysql_database", $con ); $table = null; $table = "CREATE TABLE `username` ( `fname` varchar(30), `lname` varchar(30), `username` varchar(30), `password` varchar(30), `email` varchar(30) )"; -------------------------------------------------- Above are just snippets You might lookup what else you need to define each table's members. Lookup how to put an error exit around the database select statement. I suggest you open the format a little by using spaces to make the text easier to read. This post has been edited by Ephraim F. Moya: Apr 5 2012, 11:33 PM |
Brian Chandler |
Apr 5 2012, 10:51 PM
Post
#6
|
Jocular coder Group: Members Posts: 2,460 Joined: 31-August 06 Member No.: 43 |
The php error messages are rather amateurish, because they give the internal symbols, instead of saying what they mean. But T_VARIABLE fairly obviously means "a variable", so the interpreter choked because it was expecting something else. So you have to look at the immediately *preceding* bit of code, and I think you will see (or rather "not see"!) a missing semicolon...
|
Lo-Fi Version | Time is now: 29th March 2024 - 07:47 AM |