Jump to content
Larry Ullman's Book Forums
Sign in to follow this  
jonathan

Chapter 9 Connecting To Mysql - 'syntax Error"!

Recommended Posts

Hi,

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_PASSWORD', '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?        

Share this post


Link to post
Share on other sites

mysqli_connect.php in the first line is your problem.

Try add // before it to comment it out.

 

Also, welcome to the forums.

Thank yooouuu, HartleySan! Do I feel stupid.....

Share this post


Link to post
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.

Guest
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.

Loading...
Sign in to follow this  

×
×
  • Create New...