-2

am completely new to coding, and i got this error

Parse error: syntax error, unexpected '{' in C:\xmpp\htdocs\e-kartbz\includes\config.php on line 4

the code i wrote is:

<?php
//connect to database
mysql_connect{"localhost", "root", ""} or die{mysql_error{}};
mysql_select_db{"e-kartbz"} or die{mysql_error{}};
echo "working";
?>

i wrote it exactly as the instructor did in the tutorial, and it worked perfectly for him. can you help me please, thank you.

1 Answers1

1

You have to use () instead of {}

Your code must be,

mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("e-kartbz") or die(mysql_error());
echo "working";
  • it is now saying: Fatal error: Uncaught Error: Call to undefined function mysql_connect() in C:\xmpp\htdocs\e-kartbz\includes\config.php:4 Stack trace: #0 C:\xmpp\htdocs\e-kartbz\index.php(1): include() #1 {main} thrown in C:\xmpp\htdocs\e-kartbz\includes\config.php on line 4 – Jennine Hamilton Jan 24 '16 at 19:56
  • read this http://stackoverflow.com/a/12860046/2462527 – Yavuz YILDIZ Jan 24 '16 at 20:32