Jump to content

Recommended Posts

oay so im thinking about putting mysql_free_result() in my script.

 

so if i do something like:

<?php
$sql=mysql_query("UPDATE members_profiles2 SET location = '$update_location' WHERE username = '$username' AND game = '$game'");
mysql_free_result($sql);?>

 

will it throw any errors? i tried this with mysql_close() and i got errors like "cant connect on line ___ using password NO"

and "mysql_close() is not a valid link resource identifier"

Link to comment
https://forums.phpfreaks.com/topic/135589-solved-mysql-question/
Share on other sites

<?php
if ($datestamp != "$current_date")
{
mysql_query("UPDATE game_tables SET daily_page_views=0 WHERE the_current_date != '$datestamp'") or die ("Database error: ".mysql_error());
mysql_query("UPDATE game_tables SET the_current_date = '$datestamp' WHERE the_current_date != '$datestamp'") or die ("Database error: ".mysql_error());
$getGame[daily_page_views] = 0;
}?>

 

that is just but a small taste of the code

i called it using the query but was told that this would throw errors if i didnt close it using the database connection which is $con

 

but what o am asking if this mysql_free_result() would be better than mysql_close() for hanging queries ???

i called it using the query but was told that this would throw errors if i didnt close it using the database connection which is $con

 

but what o am asking if this mysql_free_result() would be better than mysql_close() for hanging queries ???

 

Not for UPDATE queries. As I said, it makes no sense.

 

If you have multiple queries which could be condensed into one Id suggest you start there.

You need to find the actual problem. Find which query or which piece of code is having a problem.

 

The "cant connect on line ___ using password NO" errors were because mysql_query() attempts to create a connection if there is not one. The reason the code sped up was because the queries were never being executed when there is no connection to the database server.

 

Neither mysql_free_result() or mysql_close() have any effect on how a query executes. So, it does not matter which one you try (except that mysql_free_result() when there is no result will cause an error and mysql_close() will close a connection that the remaining queries need.)

 

And as thorpe already posted, there is only a resource created for SELECT, SHOW, DESCRIBE, and EXPLAIN queries, which has nothing to do with the UPDATE queries you have posted.

 

Besides -

Freeing resources

Due to the reference-counting system introduced with PHP 4's Zend Engine, it is automatically detected when a resource is no longer referred to (just like Java). When this is the case, all resources that were in use for this resource are made free by the garbage collector. For this reason, it is rarely ever necessary to free the memory manually by using some free_result function.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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