Hey, Just started learning PHP and cant go any further. It seems to be working at first glance, but then does nothing. I'm using xampp and have everything setup. Whenever this script loads it shows the die comment cant connect: in the //SELECT DATABASE operation, but nothing else so I don't know what to do. the //TEST connection does not work either - just if anyone asks for any reason database: tutorial localhost user: root pass: <?php //OPENS CONNECTION TO MYSQL SERVER $dbc = mysql_connect('localhost','root',''); if (!$dbc){ die('Not connected:' .mysql_error()); } //SELECT DATABASE $db_selected = mysql_select_db("tutorial", $dbc); if (!$db_selected); { die ('cant connect:' .mysql_error()); } //TEST $query="UPDATE tutorial SET email='hope_this_works' WHERE username='bobo'"; $result=mysql_query($query); ?> PHP:
Can you open phpmyadmin from the localhost tab? Are you sure mysql and Apache have been started using the bat file. If yes to both of the above, did you create the DB and install the tables for the script? This is what I really think your problem is.
You will master the use of the semi-colon if you mess with PHP much. It will get to the point when where the error message pops up and you say damn semicolon AGAIN.
Haha, So I've been told for anyone randomly browsing this, here is the final working code. //OPENS CONNECTION TO MYSQL SERVER $dbc = mysql_connect('localhost','root',''); if (!$dbc){ die('Not connected:' . mysql_error()); } //SELECT DATABASE $db_selected = mysql_select_db('tutorial', $dbc); if (!$db_selected){ die ('cant connect:' . mysql_error()); } //TEST CONNECTION $query="UPDATE users SET email='hope_this_works' WHERE username='bobo'"; $result=mysql_query($query); if (!$result){ die ('connection failed ->' . mysql_error()); } PHP: