Jump to content

SQL Connection


xymalf

Recommended Posts


<?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.


Link to comment
Share on other sites

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();
}

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.