theblokgroup Posted May 7, 2009 Share Posted May 7, 2009 I am entirely baffled by this problem. I have created a basic php script that queries a mysql database and displays the information using a while loop. Sometimes, when a user visits the website page, none of the queries show up but once you refresh the page, they appear. I have modified max_connections in my.cnf, that is not the problem. I have also tried recoding it, that didn't help. Any suggestions would be great! I have also turned on all errors in PHP and there are no errors showing up. Specs: Dedicated Fedora Server, Plesk Control Panel, 4GB RAM, 16-GB Storage, MySQL 5.0.45, PHP 5.2.6 Here is the connection string and code (there is also an attached image that displays what is happening - notice recent jobs, blogs and events are blank): <?php $connection = mysql_pconnect('', '', '', $new_link= true) or die('MySQL Connection Error: The Connection String Malfunctioned.'); mysql_select_db('') or die ('MySQL Connection Error: Cannot connect to the DB: '.mysql_error() ); ?> <?php $sqlrecc = mysql_query("SELECT * FROM events WHERE active = '1' AND home = '1' ORDER BY first_date ASC LIMIT 5"); while($rowrecc = mysql_fetch_assoc($sqlrecc)) { echo "<p><a href=\"viewevent.php?id=".$rowrecc['id']."\">".ucwords($rowrecc['event_name'])." »</a><br />"; echo ucwords($rowrecc['event_date'])."<br/>".ucwords($rowrecc['location'])."</p>"; } ?> [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/157217-solved-queries-doent-appear-until-i-refresh-the-page/ Share on other sites More sharing options...
fenway Posted May 7, 2009 Share Posted May 7, 2009 Stop using persistent connections. Quote Link to comment https://forums.phpfreaks.com/topic/157217-solved-queries-doent-appear-until-i-refresh-the-page/#findComment-828737 Share on other sites More sharing options...
theblokgroup Posted May 7, 2009 Author Share Posted May 7, 2009 Tried that, same result. Whether it is persistent or non, hasn't made a difference. Quote Link to comment https://forums.phpfreaks.com/topic/157217-solved-queries-doent-appear-until-i-refresh-the-page/#findComment-828753 Share on other sites More sharing options...
Ken2k7 Posted May 7, 2009 Share Posted May 7, 2009 Do you know if the SQL runs upon first visit? Quote Link to comment https://forums.phpfreaks.com/topic/157217-solved-queries-doent-appear-until-i-refresh-the-page/#findComment-828756 Share on other sites More sharing options...
theblokgroup Posted May 7, 2009 Author Share Posted May 7, 2009 Ken2k7... It runs upon first visit about 70-75% of the time. If you set the screen aside for about 5 mins, come back to it and refresh, the queries go blank. Here is a link to the page: http://www.latinograduate.com/index.php Quote Link to comment https://forums.phpfreaks.com/topic/157217-solved-queries-doent-appear-until-i-refresh-the-page/#findComment-828897 Share on other sites More sharing options...
Ken2k7 Posted May 7, 2009 Share Posted May 7, 2009 Why does it run only 70-75% of the time? Quote Link to comment https://forums.phpfreaks.com/topic/157217-solved-queries-doent-appear-until-i-refresh-the-page/#findComment-829042 Share on other sites More sharing options...
Potatis Posted May 8, 2009 Share Posted May 8, 2009 Do you have any session code on this page at all? Quote Link to comment https://forums.phpfreaks.com/topic/157217-solved-queries-doent-appear-until-i-refresh-the-page/#findComment-829274 Share on other sites More sharing options...
theblokgroup Posted May 8, 2009 Author Share Posted May 8, 2009 Ken2K... That is what I am trying to figure out. Potatis... there is only a session_start(); at the top. Quote Link to comment https://forums.phpfreaks.com/topic/157217-solved-queries-doent-appear-until-i-refresh-the-page/#findComment-829503 Share on other sites More sharing options...
Ken2k7 Posted May 8, 2009 Share Posted May 8, 2009 Can you post the script rather than that snippet at the top? I think this is more PHP-related than it is MySQL-related. Quote Link to comment https://forums.phpfreaks.com/topic/157217-solved-queries-doent-appear-until-i-refresh-the-page/#findComment-829512 Share on other sites More sharing options...
fenway Posted May 8, 2009 Share Posted May 8, 2009 Can you post the script rather than that snippet at the top? I think this is more PHP-related than it is MySQL-related. We frown upon posting entire scripts... that's never the answer. And if it's php-related, then it doesn't belong on this board. Quote Link to comment https://forums.phpfreaks.com/topic/157217-solved-queries-doent-appear-until-i-refresh-the-page/#findComment-829573 Share on other sites More sharing options...
theblokgroup Posted May 8, 2009 Author Share Posted May 8, 2009 Hi All, we found the problem. There were two connection strings, one serving our ad server and the other our content. We didn't specify in the content which connection to use. It is now working fine. Quote Link to comment https://forums.phpfreaks.com/topic/157217-solved-queries-doent-appear-until-i-refresh-the-page/#findComment-829862 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.