Jump to content

mysql_connect doesn't care what my id or pw is. ("It works!" No. It doesn't.)


ddd1600

Recommended Posts

Here's the code:

 

        <?php

       

$link = mysql_connect(`192.168.0.8`, `ddd1600`, `thisisnotmypasswordfml`);

if (!$link) {

    die(`Could not connect: ` . mysql_error());

}else{

    echo "this should not work";

}

 

// make foo the current db

$db_selected = mysql_select_db("test", $link);

if (!$db_selected) {

    die (`Could not connect: ` . mysql_error());

}else{

    echo "It worked!";

}

 

        $sql =

"INSERT INTO `test`.`Table2` (

`ID` ,

`name` ,

`content`

)

VALUES (

NULL ,  `apples`,  `are grown by Australians.`);"

       

      ;

?>

 

OUTPUT:

"this should not workIt worked!"

 

A related post of mine, which might have something to do with this, is here:

http://www.phpfreaks.com/forums/index.php?topic=355486.0

Link to comment
Share on other sites

shit like this


        <?php
        
$link = mysql_connect(`192.168.0.8`, `ddd1600`, `thisisnotmypassword`);
if (!$link) {
    die(`Could not connect: ` . mysql_error());
}else{
    echo "this is working";
}
?>

 

Again, this might have something to do with this (http://www.phpfreaks.com/forums/index.php?topic=355485.0)

 

And yes, that one says its working too

Link to comment
Share on other sites

Oh yeah, this too


        <?php
        
$link = mysql_connect(`192.168.0.8`, `notexistentuser`, `thisisnotmypassword`);
if (!$link) {
    die("Could not connect: " . mysql_error());
}else{
    echo "this is working";
}
?>

Link to comment
Share on other sites

Most of your problem is in the way you're quoting things. String values get enclosed in single 'quotes'. Normally, table and field names don't need to be enclosed in anything unless they happen to be MySQL reserved words, in which case, they get enclosed in `backticks`. Backticks are not used in the php functions to connect to the db.

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.