Jump to content

[SOLVED] mysql_close question


darkfreaks

Recommended Posts

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

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

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.