darkfreaks Posted December 5, 2008 Share Posted December 5, 2008 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" Quote Link to comment https://forums.phpfreaks.com/topic/135589-solved-mysql-question/ Share on other sites More sharing options...
trq Posted December 5, 2008 Share Posted December 5, 2008 mysql_query simply returns true / false when executing UPDATE statements, so calling mysql_free_resource makes no sense. Quote Link to comment https://forums.phpfreaks.com/topic/135589-solved-mysql-question/#findComment-706414 Share on other sites More sharing options...
darkfreaks Posted December 5, 2008 Author Share Posted December 5, 2008 the queries are hanging and causing the script to slowdown. however with the addition of mysql_close() it sped things up but caused those errors. my question is how do i stop the update delete queries from hanging ??? Quote Link to comment https://forums.phpfreaks.com/topic/135589-solved-mysql-question/#findComment-706416 Share on other sites More sharing options...
trq Posted December 5, 2008 Share Posted December 5, 2008 however with the addition of mysql_close() it sped things up but caused those errors. Can we see this code? Quote Link to comment https://forums.phpfreaks.com/topic/135589-solved-mysql-question/#findComment-706418 Share on other sites More sharing options...
darkfreaks Posted December 5, 2008 Author Share Posted December 5, 2008 <?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 Quote Link to comment https://forums.phpfreaks.com/topic/135589-solved-mysql-question/#findComment-706419 Share on other sites More sharing options...
trq Posted December 5, 2008 Share Posted December 5, 2008 Can we see how you implimented mysql_close() is what I was asking? And why are you using two queries there? They both have the same WHERE clause so could easily be put into one query. Quote Link to comment https://forums.phpfreaks.com/topic/135589-solved-mysql-question/#findComment-706420 Share on other sites More sharing options...
darkfreaks Posted December 5, 2008 Author Share Posted December 5, 2008 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 ??? Quote Link to comment https://forums.phpfreaks.com/topic/135589-solved-mysql-question/#findComment-706421 Share on other sites More sharing options...
trq Posted December 5, 2008 Share Posted December 5, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/135589-solved-mysql-question/#findComment-706424 Share on other sites More sharing options...
PFMaBiSmAd Posted December 5, 2008 Share Posted December 5, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/135589-solved-mysql-question/#findComment-706425 Share on other sites More sharing options...
PFMaBiSmAd Posted December 5, 2008 Share Posted December 5, 2008 Edit to the above: How do you know the three different UPDATE queries you have posted are where the problem is? What symptoms or errors are you getting? Quote Link to comment https://forums.phpfreaks.com/topic/135589-solved-mysql-question/#findComment-706427 Share on other sites More sharing options...
darkfreaks Posted December 5, 2008 Author Share Posted December 5, 2008 the problem didnt happen until i added mysql_close() so i just think im going to combine some of the queries and see if it speeds up any. remove mysql_close(). Quote Link to comment https://forums.phpfreaks.com/topic/135589-solved-mysql-question/#findComment-706429 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.