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

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

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";
}
?>

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.