Jump to content

first lesson in connecting to database


new_coder

Recommended Posts

Hi, I am trying to connect to a database. I am reading many tutorials, and they all seem very simple.

In phpMyAdmin I have created a database, called mydatabase. I do not add any user to this database.

My php file is:

<?
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'password';
    mysql_connect($dbhost,$dbuser,$dbpass );
    mysql_select_db("mydatabase") or die( "Unable to select database.")	
?>

When I run the file, I get this message.

 

Notice: mysql_connect() [function.mysql-connect]: SQL safe mode in effect - ignoring host/user/password information in C:\wamp\www\handler.php on line 6

Unable to select database.

 

What is it that I am missing? Thanks for the help. (spent 2 days, but no luck...)

 

Link to comment
Share on other sites

In your php.ini (in your case probably located at c:\wamp\php\php.ini, but I'm not sure as I use xampp not wamp) file, there will be a line of code that says...

 

sql.safe_mode = On

 

You need to change it to...

 

sql.safe_mode = Off

Link to comment
Share on other sites

In your php.ini (in your case probably located at c:\wamp\php\php.ini, but I'm not sure as I use xampp not wamp) file, there will be a line of code that says...

 

sql.safe_mode = On

 

You need to change it to...

 

sql.safe_mode = Off

 

No, I checked the php.ini file, the safe mode is turned off!

 

here is the part:

 

; http://php.net/sql.safe-mode

sql.safe_mode = Off      :'(

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

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

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.