ddd1600 Posted March 12, 2012 Share Posted March 12, 2012 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 Quote Link to comment Share on other sites More sharing options...
ddd1600 Posted March 12, 2012 Author Share Posted March 12, 2012 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 Quote Link to comment Share on other sites More sharing options...
ddd1600 Posted March 12, 2012 Author Share Posted March 12, 2012 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"; } ?> Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted March 12, 2012 Share Posted March 12, 2012 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. 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.