new_coder Posted September 29, 2009 Share Posted September 29, 2009 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...) Quote Link to comment https://forums.phpfreaks.com/topic/175889-first-lesson-in-connecting-to-database/ Share on other sites More sharing options...
Alex Posted September 29, 2009 Share Posted September 29, 2009 Your problem is a configuration setting in php.ini; you need to change sql.safe_mode = ON to OFF. Quote Link to comment https://forums.phpfreaks.com/topic/175889-first-lesson-in-connecting-to-database/#findComment-926771 Share on other sites More sharing options...
PrinceOfDragons Posted September 29, 2009 Share Posted September 29, 2009 <? $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = 'password'; $dbcon = mysql_connect($dbhost,$dbuser,$dbpass ); mysql_select_db("mydatabase", $dbcon) or die( "Unable to select database."); ?> should work Quote Link to comment https://forums.phpfreaks.com/topic/175889-first-lesson-in-connecting-to-database/#findComment-926845 Share on other sites More sharing options...
new_coder Posted September 29, 2009 Author Share Posted September 29, 2009 Your problem is a configuration setting in php.ini; you need to change sql.safe_mode = ON to OFF. How do I change the safe_mode? Please advise. Quote Link to comment https://forums.phpfreaks.com/topic/175889-first-lesson-in-connecting-to-database/#findComment-926992 Share on other sites More sharing options...
cags Posted September 29, 2009 Share Posted September 29, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/175889-first-lesson-in-connecting-to-database/#findComment-927004 Share on other sites More sharing options...
new_coder Posted October 1, 2009 Author Share Posted October 1, 2009 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 :'( Quote Link to comment https://forums.phpfreaks.com/topic/175889-first-lesson-in-connecting-to-database/#findComment-928086 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.