The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Help with unexpected T_VARIABLE
tyler.watkins
post 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
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
tyler.watkins
post 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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post 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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
tyler.watkins
post 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
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Ephraim F. Moya
post 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



QUOTE(tyler.watkins @ Apr 5 2012, 02:17 PM) *

<?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
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post 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...
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 28th March 2024 - 04:47 PM