ultimachris Posted April 1, 2009 Share Posted April 1, 2009 Hello all, im going round the bend wondering whyyy im getting a mysql query error on this code: <?php $mysql = mysql_connect("*******", "**********", "*******", "********"); if (mysql_errno()) { printf("Connect Failed: %s\n", mysql_connect_error()); exit(); } else { $sql = "INSERT INTO tickets (testfield) VALUES ('".$_POST["testfield"]."')"; $res = mysql_query($mysql, $sql); if ($res === TRUE) { echo "A new ticket has been added."; } else { printf("could not insert record: %s\n", mysql_error($mysql)); } mysql_close ($mysql); } ?> What on earth am i doing wrong??? Hope you can help me guys, you rule! Chris Quote Link to comment Share on other sites More sharing options...
Mchl Posted April 1, 2009 Share Posted April 1, 2009 resource mysql_query ( string $query [, resource $link_identifier ] ) As you can see, query goes first, then the connection resource. You have it the other way round. Quote Link to comment Share on other sites More sharing options...
ultimachris Posted April 1, 2009 Author Share Posted April 1, 2009 thanks MCHL, will try this out! so it should be ($sql, $mysql) hmmm....now it says "could not insert record: No database selected " Quote Link to comment Share on other sites More sharing options...
Mchl Posted April 1, 2009 Share Posted April 1, 2009 No wonder. You did not use mysql_select_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.