xymalf Posted July 26, 2012 Share Posted July 26, 2012 <?php $link = mysqli_connect('217.174.', 'xymalf' , 'po'); if (!$link) { $output = 'unable to connect to database server.'; include 'output.html.php'; exit(); } if (!mysqli_select_db($link, 'xymalfco1')) { $output = 'unable to locate db'; include 'output.html.php'; exit(); } $output = 'connected.'; include 'output.html.php'; ?> [code] output.html.php <?php echo $output; ?> </p> </body> Can any one spot an error in my SQL connection code? it has stopped working. Quote Link to comment Share on other sites More sharing options...
Psycho Posted July 26, 2012 Share Posted July 26, 2012 Stopped working how? What errors are you getting and/or what is happening and what do you expect to happen differently? You say it stopped working which implies it was working before. What did you change? I see you are checking for error conditions for connecting to and selecting the database. But, you don't seem to be displaying the actual error in either of those two cases. That's fine for a production environment, but when developing you need that information to understand what the problem is. Try this $link = mysqli_connect('217.174.', 'xymalf' , 'po'); if (!$link) { die("Unable to connect: " .mysql_error()); //debugging line $output = 'unable to connect to database server.'; include 'output.html.php'; exit(); } if (!mysqli_select_db($link, 'xymalfco1')) { die("Unable to select db: " .mysql_error()); //debugging line $output = 'unable to locate db'; include 'output.html.php'; exit(); } Quote Link to comment Share on other sites More sharing options...
xymalf Posted July 26, 2012 Author Share Posted July 26, 2012 Warning: mysqli_connect() [function.mysqli-connect]: Premature end of data (mysqlnd_wireprotocol.c:553) in C:\wamp\www\connect\index.php on line 11 Call Stack # Time Memory Function Location 1 0.0084 367976 {main}( ) ..\index.php:0 2 0.0085 368176 mysqli_connect ( ) ..\index.php:11 ( ! ) Warning: mysqli_connect() [function.mysqli-connect]: OK packet 1 bytes shorter than expected in C:\wamp\www\connect\index.php on line 11 Call Stack # Time Memory Function Location 1 0.0084 367976 {main}( ) ..\index.php:0 2 0.0085 368176 mysqli_connect ( ) ..\index.php:11 ( ! ) Warning: mysqli_connect() [function.mysqli-connect]: (HY000/2000): mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication. Please use an administration tool to reset your password with the command SET PASSWORD = PASSWORD('your_existing_password'). This will store a new, and more secure, hash value in mysql.user. If this user is used in other scripts executed by PHP 5.2 or earlier you might need to remove the old-passwords flag from your my.cnf file in C:\wamp\www\connect\index.php on line 11 Call Stack # Time Memory Function Location 1 0.0084 367976 {main}( ) ..\index.php:0 2 0.0085 368176 mysqli_connect ( ) ..\index.php:11 Unable to connect: I think my web server may have changed the security? All I did is re-write the output.html.php file 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.