Lukey Posted May 16, 2007 Share Posted May 16, 2007 Hi i hope this is the right forum. I am attempting a simple database connection using php i have installed apache php and mysql. Created a mysql database with a table etc. I can get phpinfo(); to show on my apache server however.. I am trying this simple script to test a connection to the data base but i get no result, no error message nothing. <?php $mysqli = new mysqli("localhost", "root", "****", "sunhouse"); // Creates connection to sunhouse database if(mysqli_connect_errno()) { printf("Connection Failed: %s\n", mysqli_connect_error());//error message exit(); } else { printf("Host Info: %s\n", mysqli_get_host_info($mysqli)); mysqli_close($mysqli); } ?> I have edited the php.ini file to include the mysqli extension by removing the semicolon at: extension=php_msql.dll and extension=php_mysqli.dll Also i have selected the correct extension directory as in the FAQ. Any help would be appreciated as without even an error message i am struggling! Quote Link to comment https://forums.phpfreaks.com/topic/51680-mysqlphp-problems/ Share on other sites More sharing options...
Lukey Posted May 16, 2007 Author Share Posted May 16, 2007 Anyone?? i know its tough because i cant even see an error message hence me not being able to find the root of the problem. HELP!! Quote Link to comment https://forums.phpfreaks.com/topic/51680-mysqlphp-problems/#findComment-254617 Share on other sites More sharing options...
marf Posted May 16, 2007 Share Posted May 16, 2007 If your looking to run it locally, just to test and build use http://www.wampserver.com/en/ Really easy setup, has all the basics and phpmyadmin. Quote Link to comment https://forums.phpfreaks.com/topic/51680-mysqlphp-problems/#findComment-254627 Share on other sites More sharing options...
Garath531 Posted May 16, 2007 Share Posted May 16, 2007 Did you make sure mysqli was listed in the phpinfo();? Quote Link to comment https://forums.phpfreaks.com/topic/51680-mysqlphp-problems/#findComment-254628 Share on other sites More sharing options...
Lukey Posted May 16, 2007 Author Share Posted May 16, 2007 Actually i checked the phpinfo page using the find function in Firefox and there is no mention of mysqli I am running locally, i tried using XAMPP but had issues with it so i am using a package on a cd from a book. Its all installed and running as i can access phpinfo(); from http://localhost/phpinfo.php Quote Link to comment https://forums.phpfreaks.com/topic/51680-mysqlphp-problems/#findComment-254632 Share on other sites More sharing options...
Garath531 Posted May 16, 2007 Share Posted May 16, 2007 Near the top of your phpinfo();, there should be a line that reads Configuration File (php.ini) Path What does that say? Quote Link to comment https://forums.phpfreaks.com/topic/51680-mysqlphp-problems/#findComment-254638 Share on other sites More sharing options...
Lukey Posted May 16, 2007 Author Share Posted May 16, 2007 Configuration File (php.ini) Path C:\php\php.ini Maybe its something i messed up in the .ini Cheers for helping Quote Link to comment https://forums.phpfreaks.com/topic/51680-mysqlphp-problems/#findComment-254641 Share on other sites More sharing options...
Garath531 Posted May 16, 2007 Share Posted May 16, 2007 Did you restart your webserver after removing the semi-colons? Quote Link to comment https://forums.phpfreaks.com/topic/51680-mysqlphp-problems/#findComment-254644 Share on other sites More sharing options...
Lukey Posted May 16, 2007 Author Share Posted May 16, 2007 Yep done that, i'll try it again tho! Quote Link to comment https://forums.phpfreaks.com/topic/51680-mysqlphp-problems/#findComment-254645 Share on other sites More sharing options...
Garath531 Posted May 16, 2007 Share Posted May 16, 2007 Is mysql listed? Quote Link to comment https://forums.phpfreaks.com/topic/51680-mysqlphp-problems/#findComment-254649 Share on other sites More sharing options...
Lukey Posted May 16, 2007 Author Share Posted May 16, 2007 Is mysql listed where in the phpinfo? It says.... MSQL Support enabled Allow Persistent Links yes Persistent Links 0/unlimited Total Links 0/unlimited but no mysql <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <!-- Created on 13-May-2007 18:35:18 --> <html> <head> <title> Please login here </title> <meta name="GENERATOR" content="Arachnophilia 5.3"/> <meta name="FORMATTER" content="Arachnophilia 5.3"/> </head> <body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#ff0066" alink="#ff0000"> HELP ME <br/> <h1> <?php $mysqli = new mysqli("localhost", "root", "blahblah", "sunhouse"); // Creates connection to sunhouse database if(mysqli_connect_errno()) { printf("Connection Failed: %s\n", mysqli_connect_error());//error message exit(); } else { printf("Host Info: %s\n", mysqli_get_host_info($mysqli)); mysqli_close($mysqli); } ?> </h1> </body> </html> | Here is the entire script. It displays HELP ME then blank no notification whether its connected and no error message Quote Link to comment https://forums.phpfreaks.com/topic/51680-mysqlphp-problems/#findComment-254653 Share on other sites More sharing options...
Garath531 Posted May 16, 2007 Share Posted May 16, 2007 Can you post a screenshot of the top of your phpinfo()? (Right under the version) Quote Link to comment https://forums.phpfreaks.com/topic/51680-mysqlphp-problems/#findComment-254674 Share on other sites More sharing options...
Lukey Posted May 16, 2007 Author Share Posted May 16, 2007 here you go. http://i96.photobucket.com/albums/l185/lukey420/ss.jpg Do you think i need to restart my entire computer? Quote Link to comment https://forums.phpfreaks.com/topic/51680-mysqlphp-problems/#findComment-254680 Share on other sites More sharing options...
Garath531 Posted May 16, 2007 Share Posted May 16, 2007 Try stopping, then starting Apache. Sometimes that works when restart doesn't. Quote Link to comment https://forums.phpfreaks.com/topic/51680-mysqlphp-problems/#findComment-254681 Share on other sites More sharing options...
Lukey Posted May 16, 2007 Author Share Posted May 16, 2007 Nope doesnt work. I have done this: http://www.php.net/manual/en/faq.installation.php#faq.installation.addtopath Do you think i need to do the next step below it aswell? 53.15. How do I make the php.ini file available to PHP on windows? Quote Link to comment https://forums.phpfreaks.com/topic/51680-mysqlphp-problems/#findComment-254684 Share on other sites More sharing options...
Garath531 Posted May 16, 2007 Share Posted May 16, 2007 Just as a test, change the php part of your code to this. <?php $con = mysql_connect("host", "username", "password") or die(mysql_error()); ?> If mysql is not enabled, you should get an error. Quote Link to comment https://forums.phpfreaks.com/topic/51680-mysqlphp-problems/#findComment-254686 Share on other sites More sharing options...
Lukey Posted May 16, 2007 Author Share Posted May 16, 2007 Nope i get nothing, no error. Quote Link to comment https://forums.phpfreaks.com/topic/51680-mysqlphp-problems/#findComment-254693 Share on other sites More sharing options...
Garath531 Posted May 16, 2007 Share Posted May 16, 2007 Change your username to a fake username and see if you get an error. Quote Link to comment https://forums.phpfreaks.com/topic/51680-mysqlphp-problems/#findComment-254698 Share on other sites More sharing options...
Lukey Posted May 16, 2007 Author Share Posted May 16, 2007 Nah its the same mate. I think its php.ini thats messing it up as i have no metion of mysql in phpinfo(); Im not sure what i've done wrong tho :S Quote Link to comment https://forums.phpfreaks.com/topic/51680-mysqlphp-problems/#findComment-254700 Share on other sites More sharing options...
Garath531 Posted May 16, 2007 Share Posted May 16, 2007 Do you have errors disabled? Quote Link to comment https://forums.phpfreaks.com/topic/51680-mysqlphp-problems/#findComment-254702 Share on other sites More sharing options...
Lukey Posted May 16, 2007 Author Share Posted May 16, 2007 ; - display_errors = Off [security] Should i lose the semicolon and change that one to On then? Quote Link to comment https://forums.phpfreaks.com/topic/51680-mysqlphp-problems/#findComment-254706 Share on other sites More sharing options...
Garath531 Posted May 16, 2007 Share Posted May 16, 2007 Try it and then run your script again. Quote Link to comment https://forums.phpfreaks.com/topic/51680-mysqlphp-problems/#findComment-254707 Share on other sites More sharing options...
Lukey Posted May 16, 2007 Author Share Posted May 16, 2007 aha Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Group\Apache2\htdocs\login.php on line 22 Quote Link to comment https://forums.phpfreaks.com/topic/51680-mysqlphp-problems/#findComment-254708 Share on other sites More sharing options...
Garath531 Posted May 16, 2007 Share Posted May 16, 2007 Ok, so now we have errors. I have had this problem before. The thing is that there is a really long and complicated string of things to do. Just one quick question. Where is the php.ini file that you have been editing, and was it php.ini-recommended, or php.ini-dist? Quote Link to comment https://forums.phpfreaks.com/topic/51680-mysqlphp-problems/#findComment-254709 Share on other sites More sharing options...
Lukey Posted May 16, 2007 Author Share Posted May 16, 2007 It is in C:/php/php.ini and it was the recommended one This is a bast of a problem and i havent even started coding yet! My projects due on friday :'( Quote Link to comment https://forums.phpfreaks.com/topic/51680-mysqlphp-problems/#findComment-254712 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.