Jump to content

unexpected '}', expecting ',' or ';'


AlmarM

Recommended Posts

Hello,

 

This is my first time on PHPFreaks.com :)

And I have a question. Whats wrong with this:

<?php
$host['name'] = '86.92.129.3';
$host['username'] = 'root';
$host['password'] = '';
$host['databasename'] = 'odinms';
$db = mysql_connect($host['name'], $host['username'], $host['password']) OR die ('Cant connect to MySQL!');
mysql_select_db($host['databasename'], $db);
$name = $_POST['name'];
$age = $_POST['age'];
$accountname = $_POST['accountname'];
$experience = $_POST['experience'];
$why = $_POST['why'];
$sel = "SELECT * FROM accounts WHERE name='$name'";
if ($accountname == '');
{
echo "Please enter a accountname!"
}
$d = 'INSERT INTO gmapps (name, age, accountname, experience, why' VALUES('$name', '$age', '$accountname', '$experience', '$why');
mysql_query($d) OR die (mysql_error());
echo "Your GM Application has been send!";
?>

 

When I use it it says:

unexpected '}', expecting ',' or ';'

 

-AlmarM-

Link to comment
https://forums.phpfreaks.com/topic/113447-unexpected-expecting-or/
Share on other sites

Thank you :)

 

I tried it and worked. But now im getting:

unexpected T_STRING

In line 18!

 

<?php
$host['name'] = '86.92.129.3';
$host['username'] = 'root';
$host['password'] = '';
$host['databasename'] = 'odinms';
$db = mysql_connect($host['name'], $host['username'], $host['password']) OR die ('Cant connect to MySQL!');
mysql_select_db($host['databasename'], $db);
$name = $_POST['name'];
$age = $_POST['age'];
$accountname = $_POST['accountname'];
$experience = $_POST['experience'];
$why = $_POST['why'];
$sel = "SELECT * FROM accounts WHERE name='$name'";
if ($accountname == '');
{
echo "Please enter a accountname!";
}
$d = 'INSERT INTO gmapps (name, age, accountname, experience, why' VALUES('$name', '$age', '$accountname', '$experience', '$why'); //Line 18
mysql_query($d) OR die (mysql_error());
echo "Your GM Application has been send!";
?>

What sould I do?

 

-AlmarM-

Thank you :)

 

I tried it and worked. But now im getting:

unexpected T_STRING

In line 18!

 

$d = 'INSERT INTO gmapps (name, age, accountname, experience, why' VALUES('$name', '$age', '$accountname', '$experience', '$why'); //Line 18

What sould I do?

 

-AlmarM-

 

You're using an apostrophe just before VALUES instead of a closing brace ;)

Hmm like this?

<?php
$host['name'] = '86.92.129.3';
$host['username'] = 'root';
$host['password'] = '';
$host['databasename'] = 'odinms';
$db = mysql_connect($host['name'], $host['username'], $host['password']) OR die ('Cant connect to MySQL!');
mysql_select_db($host['databasename'], $db);
$name = $_POST['name'];
$age = $_POST['age'];
$accountname = $_POST['accountname'];
$experience = $_POST['experience'];
$why = $_POST['why'];
$sel = "SELECT * FROM accounts WHERE name='$name'";
if ($accountname == '');
{
echo "Please enter a accountname!";
}
$d = 'INSERT INTO gmapps (name, age, accountname, experience, why') VALUES ('$name', '$age', '$accountname', '$experience', '$why'); //Line 18
mysql_query($d) OR die (mysql_error());
echo "Your GM Application has been send!";
?>

 

*Trying*

 

Arg now im getting

unexpected ')'

Sorry for all the questions but this is my first day with PHP :)

 

-AlmarM-

Should be:

<?php
$host['name'] = '86.92.129.3';
$host['username'] = 'root';
$host['password'] = '';
$host['databasename'] = 'odinms';
$db = mysql_connect($host['name'], $host['username'], $host['password']) OR die ('Cant connect to MySQL!');
mysql_select_db($host['databasename'], $db);
$name = $_POST['name'];
$age = $_POST['age'];
$accountname = $_POST['accountname'];
$experience = $_POST['experience'];
$why = $_POST['why'];
$sel = "SELECT * FROM accounts WHERE name='$name'";
if ($accountname == '');
{
echo "Please enter a accountname!";
}
$d = "INSERT INTO `gmapps` (`name`, `age`, `accountname`, `experience`, `why`) VALUES ($name, $age, $accountname, $experience, $why)";
mysql_query($d) OR die (mysql_error());
echo "Your GM Application has been send!";
?>

Thx, but now im getting

unexpected T_STRING

On line 21

<?php
$host['name'] = '86.92.129.3';
$host['username'] = 'root';
$host['password'] = '';
$host['databasename'] = 'odinms';

$db = mysql_connect($host['name'], $host['username'], $host['password']) OR die ('Cant connect to MySQL!');
mysql_select_db($host['databasename'], $db);

$name = $_POST['name'];
$age = $_POST['age'];
$accountname = $_POST['accountname'];
$experience = $_POST['experience'];
$why = $_POST['why'];
$sel = "SELECT * FROM accounts WHERE name='$name'";

if ($accountname == '');
{
echo "Please enter a accountname!";
}
$d = INSERT INTO `gmapps` (`name`, `age`, `accountname`, `experience`, `why`) VALUES ($name, $age, $accountname, $experience, $why); // Line 21
mysql_query($d) OR die (mysql_error());
echo "Your GM Application has been send!";
?>

 

-AlmarM-

thanks, but now im getting

unexpected T_STRING

On line 21

<?php
$host['name'] = '86.92.129.3';
$host['username'] = 'root';
$host['password'] = '';
$host['databasename'] = 'odinms';

$db = mysql_connect($host['name'], $host['username'], $host['password']) OR die ('Cant connect to MySQL!');
mysql_select_db($host['databasename'], $db);

$name = $_POST['name'];
$age = $_POST['age'];
$accountname = $_POST['accountname'];
$experience = $_POST['experience'];
$why = $_POST['why'];
$sel = "SELECT * FROM accounts WHERE name='$name'";

if ($accountname == '');
{
echo "Please enter a accountname!";
}
$d = INSERT INTO `gmapps` (`name`, `age`, `accountname`, `experience`, `why`) VALUES ($name, $age, $accountname, $experience, $why); // Line 21
mysql_query($d) OR die (mysql_error());
echo "Your GM Application has been send!";
?>

 

-AlmarM-

You didnt use my modified version. Copy it again.

P.S This extremely easy stuff, you should look into the basics of PHP.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.