chunk Posted January 31, 2007 Share Posted January 31, 2007 HiI have apache 2.2.4 running and i have php 5.2.0 running.When I use phpinfo() in a page, I get this screen:[img]http://i26.photobucket.com/albums/c109/chunk38/phpinfo.jpg[/img]This made me think that I had everything set up ok, however I cant connect to a database no matter what I do.When I try and use this:$conn = mysql_connect('localhost', 'userone', 'password') or die ('Error connecting to mysql');I just get a blank screen.Can anyone help please? Quote Link to comment Share on other sites More sharing options...
janroald Posted January 31, 2007 Share Posted January 31, 2007 With only that line of code, you won't output anything to the screen, just connect. Just trying to rule out the obvious before i try to help you :-) Quote Link to comment Share on other sites More sharing options...
chunk Posted January 31, 2007 Author Share Posted January 31, 2007 Ahh yeah, sorry. Should have said, anything I code after that line just doesnt show up.Ive tried:echo 'Hello World!';etc and if i place it after that line, it doesnt show on screen. Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted January 31, 2007 Share Posted January 31, 2007 You cannot use mysql_* with the mysqli library you must use mysql[b][color=red]i[/color][/b]_* function set.Your code should be like this:[code=php:0]$conn = mysqli_connect('localhost', 'userone', 'password') or die ('Error connecting to mysql');echo "connection established";[/code]Also when you are bugging scripts make sure you turn on display_errors directive in the php.ini and that error_reporting is set to E_ALL aswell. Quote Link to comment Share on other sites More sharing options...
janroald Posted January 31, 2007 Share Posted January 31, 2007 And i assume you get output 'Hello world' to screen if you remove you connect line? Quote Link to comment Share on other sites More sharing options...
chunk Posted February 9, 2007 Author Share Posted February 9, 2007 You cannot use mysql_* with the mysqli library you must use mysqli_* function set. Your code should be like this: $conn = mysqli_connect('localhost', 'userone', 'password') or die ('Error connecting to mysql'); echo "connection established"; Also when you are bugging scripts make sure you turn on display_errors directive in the php.ini and that error_reporting is set to E_ALL aswell. Yep. Installed mysql instead of mysqli, and it works fine. Thanks. Quote Link to comment 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.