Jump to content
Larry Ullman's Book Forums

Chapter 9 Connecting To Mysql - 'syntax Error"!

Recommended Posts


I'm at chapter 9 and trying to create the php file, 'mysqli_connect.php'. I've made the file, saved it, loaded it but all I get is 'syntax error'. I've experimented with commenting out individual lines of code but always the same message appears, only pointing to a different line: suggesting all the code is wrong!


I copied it exactly as in the book (it should be recognised!):


<?php mysqli_connect.php

DEFINE ('DB_USER', 'xxxx');
DEFINE ('DB_HOST', 'localhost:8888');
DEFINE ('DB_NAME', 'sitename');

//make the connection
$dbc = @mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) OR die ('Could not
                connect to MySQL: ' . mysqli_connect_error() );
//set the encoding...
mysqli_set_charset($dbc, 'utf8');     



The username and password I use are ones I set when I created myself as a user of the database 'sitename', entering myself into the 'users' table. Are these the right values to use?

I have checked that MySQLI is running.....so I don't know why there is a problem here...help?        

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...