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
https://forums.phpfreaks.com/topic/175889-first-lesson-in-connecting-to-database/
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

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      :'(

Archived

This topic is now archived and is closed to further replies.

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