1,105,644 Community Members

unexpected T_STRING

Member Avatar
asghar123
Newbie Poster
1 post since Dec 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

hi,
I am getting this error:
Parse error: syntax error, unexpected T_STRING in C:\xampp\htdocs\makedatabase.php on line 2

here is the code:

<?php
CREATE USER("jeffrey"@"localhost", IDENTIFIED BY "mypass");
$con = mysql_connect("localhost" ,"jeffrey","mypass");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

if (mysql_query("CREATE DATABASE my_db",$con))
{
echo "Database created";
}
else
{
echo "Error creating database: " . mysql_error();
}

mysql_close($con);
?>

I am a beginner in PHP please explain what I am doing wrong. the code above is coming from a tutorial but it does not want to work for me!

Member Avatar
pritaeas
mod_pritaeas
11,330 posts since Jul 2006
Reputation Points: 1,420 [?]
Q&As Helped to Solve: 1,835 [?]
Skill Endorsements: 156 [?]
Moderator
Featured
Sponsor
 
0
 
CREATE USER("jeffrey"@"localhost", IDENTIFIED BY "mypass");

Is the problem. You cannot just use a mysql query in php and expect it to work. That line should be removed. You have to execute it in your mysql console, or phpmyadmin, or whatever you prefer to use.

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: