cfarm Posted June 17, 2011 Share Posted June 17, 2011 Hi I'm going through EX1 and I've come up with two errors so far. The first error has to do with mysqli. I tried using mysqli_connect then mysql_connect and things are only working for mysql_connect. Is there a reason why it's not working for mysqli? The second is that I'm getting an error on the require statement on line 15 of index.php. See error below An error occurred in script '/Applications/MAMP/htdocs/ex1/html/index.php' on line 15: require(/ex1/mysql.inc.php) [function.require]: failed to open stream: No such file or directory Is there a reason for this? Thanks! Link to comment Share on other sites More sharing options...
Larry Posted June 17, 2011 Share Posted June 17, 2011 The first error has to do with mysqli. I tried using mysqli_connect then mysql_connect and things are only working for mysql_connect. Is there a reason why it's not working for mysqli? Most likely because your PHP installation doesn't support the Improved MySQL extension. You can confirm this by running a phpinfo() script. For debugging purposes, it'd also help to know the versions of PHP and MySQL in use, per the forum guidelines. The second is that I'm getting an error on the require statement on line 15 of index.php. See error below An error occurred in script '/Applications/MAMP/htdocs/ex1/html/index.php' on line 15: require(/ex1/mysql.inc.php) [function.require]: failed to open stream: No such file or directory Is there a reason for this? Yes: there's no such file or directory. it'd help to know what operating system you're using, per the forum guidelines, what Web server you're using, etc., but the problem is likely because your use of /ex1 means to start looking in the root of the computer (I assume you're using a Mac?), whereas your files are in /Applications/MAMP/htdocs. Also, just to be clear, the book does assume comfort with the basics of PHP and MySQL. Although the book teaches new and useful applications of these two technologies, it does not teach either of them per se. Link to comment Share on other sites More sharing options...
cfarm Posted June 17, 2011 Author Share Posted June 17, 2011 Yes I am using a mac and have tried setting to '/Applications/MAMP/htdocs/'. For some reason it's still not working. As for mysqli I'm using PHP5 with mysql v 5.1x so I should be fine with the versions. I think there is probably some setting that I'm missing in the config file for apache. Would you happen to know what this could be? mysqli MysqlI Support enabled Client API library version 5.1.44 Active Persistent Links 0 Inactive Persistent Links 0 Active Links 0 Client API header version 5.1.44 MYSQLI_SOCKET /Applications/MAMP/tmp/mysql/mysql.sock Directive Local Value Master Value mysqli.allow_local_infile On On mysqli.allow_persistent On On mysqli.default_host no value no value mysqli.default_port 3306 3306 mysqli.default_pw no value no value mysqli.default_socket no value no value mysqli.default_user no value no value mysqli.max_links Unlimited Unlimited mysqli.max_persistent Unlimited Unlimited mysqli.reconnect Off Off Thanks! Link to comment Share on other sites More sharing options...
Larry Posted June 17, 2011 Share Posted June 17, 2011 Yes I am using a mac and have tried setting to '/Applications/MAMP/htdocs/'. For some reason it's still not working. What does "not working" mean? Do you see errors? If so, what are they? As for mysqli I'm using PHP5 with mysql v 5.1x so I should be fine with the versions. I think there is probably some setting that I'm missing in the config file for apache. Would you happen to know what this could be? If phpinfo() says that MySQLI support is enabled, then it's enabled. Link to comment Share on other sites More sharing options...
cfarm Posted June 18, 2011 Author Share Posted June 18, 2011 Ok I think I figured out what was wrong with the root dir. There was another folder that was storing the includes. Silly me. As for the mysqli, I'm still not sure what's going wrong here. Do you think it's reasonable to move from mysqli to mysql? I've been trying to figure out what the cause to this might be for a while now and am starting to wonder if it's even worth the trouble. Here is the error that the code is generating: An error occurred in script '/Applications/MAMP/htdocs/mysql.inc.php' on line 16: mysqli_connect() [function.mysqli-connect]: (HY000/2003): Can't connect to MySQL server on 'localhost:8888' (60) Link to comment Share on other sites More sharing options...
cfarm Posted June 18, 2011 Author Share Posted June 18, 2011 Ok I think I figured out what was wrong with the root dir. There was another folder that was storing the includes. Silly me. As for the mysqli, I'm still not sure what's going wrong here. Do you think it's reasonable to move from mysqli to mysql? I've been trying to figure out what the cause to this might be for a while now and am starting to wonder if it's even worth the trouble. Here is the error that the code is generating: An error occurred in script '/Applications/MAMP/htdocs/mysql.inc.php' on line 16: mysqli_connect() [function.mysqli-connect]: (HY000/2003): Can't connect to MySQL server on 'localhost:8888' (60) Ok I think I got it working. I rebooted the server and seems to work fine now. Link to comment Share on other sites More sharing options...
Larry Posted June 20, 2011 Share Posted June 20, 2011 Okay. To be clear, there's nothing in the error message to suggest that the MySQLi functions are the problem. It's a simple database connection error. I wouldn't be surprised to hear you failed to reload the MySQL privileges after adding a user or making other changes. Link to comment Share on other sites More sharing options...
Recommended Posts