darkfreaks Posted December 6, 2008 Share Posted December 6, 2008 ok so i have something like <?php mysql_query("UPDATE ghetto_cron SET last_run = '$today2' WHERE game = '$game' AND id = '$getMonthlyCron[id]'"); mysql_close(); mysql_query("UPDATE ghetto_cron SET total_runs = total_runs + 1 WHERE game = '$game' AND id = '$getMonthlyCron[id]'"); mysql_close();?> if i change it to: <?php $con=mysql_connect('localhost','user','pass'); mysql_query("UPDATE ghetto_cron SET last_run = '$today2' WHERE game = '$game' AND id = '$getMonthlyCron[id]'"); mysql_close($con); mysql_query("UPDATE ghetto_cron SET total_runs = total_runs + 1 WHERE game = '$game' AND id = '$getMonthlyCron[id]'"); mysql_close($con);?> if i change it to that rather than mysql_close() or mysql_close($query) will it stop giving me "can not connect to ___ using password NO" and mysql_close() is not a valid MYSQL link resource identifier. errors Link to comment https://forums.phpfreaks.com/topic/135809-solved-mysql_close-question/ Share on other sites More sharing options...
gevans Posted December 6, 2008 Share Posted December 6, 2008 I think you're confused about what mysql_close() does It closes the current connection to the database so the second query will never work; <?php <?php $con=mysql_connect('localhost','user','pass'); mysql_query("UPDATE ghetto_cron SET last_run = '$today2' WHERE game = '$game' AND id = '$getMonthlyCron[id]'"); mysql_query("UPDATE ghetto_cron SET total_runs = total_runs + 1 WHERE game = '$game' AND id = '$getMonthlyCron[id]'"); mysql_close($con); ?> that will work just fine Link to comment https://forums.phpfreaks.com/topic/135809-solved-mysql_close-question/#findComment-707760 Share on other sites More sharing options...
revraz Posted December 6, 2008 Share Posted December 6, 2008 That error is a problem Connecting to the DB. Read the error.. Looks like you never connect to the Database, you only connect to the Server. Link to comment https://forums.phpfreaks.com/topic/135809-solved-mysql_close-question/#findComment-707763 Share on other sites More sharing options...
darkfreaks Posted December 6, 2008 Author Share Posted December 6, 2008 ah ok thanks and this script is global and it does connect to the DB otherwise my script would not work Link to comment https://forums.phpfreaks.com/topic/135809-solved-mysql_close-question/#findComment-707764 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.