PHP - Php Is Sometimes Executed Twice?
I have a games website called GPStudios.com.
In a previous topic (that remains unresolved) I needed help fixing a view counter on a specific page that was sometimes executing a mysql query twice. I've since noticed that it is happening on other pages, maybe all of them. At the top of the php "playgame.php", is the statement: $updatesql = "update games set timesplayed = timesplayed+1, last_played = now() where gameid = $gameid"; mysql_query($updatesql); However, when I reload the page or check on phpMyAdmin, it has sometimes incremented by 2 (possibly 3). I have confirmed that no where else is calling the same query. I created a new table called "FUCK" and editted the code stated above to: $updatesql = "update FUCK set timesplayed = timesplayed+1, last_played = now() where gameid = $gameid"; mysql_query($updatesql); Upon loading the page, it did exactly the same thing. So I confirmed that the PHP must be being run twice. I have tried it on other pages on my website such as I had no luck on my other topic of the same problem, but hopefully someone might be able to tell me why or how this might be happening. Just remember - it is an absolute certainty that the query is NOT being run elsewhere. Thanks. Similar TutorialsHello, I create tracking code file named "get_t.php". I call it using javascript: <script language='javascript' type='text/javascript'> var r=document.referrer; var counter = new Object(); counter.src = 'http://MyWebSite.com/get_t.php?aid=55&lid=F29&r='+r; </script><script src=http://MyWebSite.com/get_t.php?aid=55&lid=F29> </script> In this file all I do is to print "Hello World". Now, everything works fine most of the time. but sometimes the file does not executed for some reason, and empty page is displayed without showing message "Hello World". Please advice. Thanks, I have a function with a query and then a while loop and then an if file_exists with an image path. I am getting the image path displayed as text. Would this be because I am running the query through json encoding? so a user fills out a form, data gets sent to send.php then if successful redirects back to index.php, how on that index.php can i get it to say, sent successfully? When I try to upload a file larger than the server's max limit, the following code is not executed. How am I supposed to inform the user that their file is too large? NOTE: I've stripped the code down for this post. Code: [Select] <?php if(isset($_POST['submit'])) { echo "test.."; } ?> <html> <head> <title>Upload Test</title> </head> <body> <form action='' enctype='multipart/form-data' method='POST'> <input type='file' name='file_upload' /> <input type='submit' name='submit' value='upload' /> </form> </body> </html> Hi all I have this problem on a server using php5, unix based, safe_mode is On globally, i have turned it off locally through php.ini. Ok, this is testing example script i used: $cmd = ( "php -v" ); $out = shell_exec( $cmd ); print $out; On my own server this returns php version. On this mentioned server i'm using (commercial) this causes complete server breakdown, when logged in with SSH, i can't even issue "ls" command after that, nor find and kill the process. What could be so wrong with it? I don't think calling php-cli would make any difference. Hi, we are trying to make a marketing wheel. This means we got a database with lots of persons in it each with a individual email adres. The simel example of how the basic database looks is seen in the picture below. This table is called "Clicks" As you might notice the field "Aan" is either a 0 or a 1. This is how it works, when someone fills in a form on the website asking for more information the form with all the personal information of this person is send to a random email adres found in this table. When this happens the field "Aan" changes from 0 to 1 this way we can make sure that the same person does not get a email again until everyone else has been used 1 time. So in other words until that the field "Aan" is value 1 for every person in the table. As you might have guessed this is sadly enough not working ... this is our code : Code: [Select] include_once('connection.php'); $data = array(); $i = 0; $result1 = mysql_query("SELECT * FROM `Clicks` WHERE Aan = 0"); while ($list1 = mysql_fetch_array($result1,MYSQL_ASSOC)) { if (empty($list1) ){ mysql_query("UPDATE `Clicks` SET `Aan`= 0 WHERE `Aan` = 1"); } $result = mysql_query("SELECT * FROM `Clicks` WHERE Aan = 0 ORDER BY RAND() LIMIT 1"); while ($list = mysql_fetch_array($result,MYSQL_ASSOC)) { foreach ($list as $key => $value) { // Met htmlentities() voorkom je dat html wordt uitgevoert. $value = htmlentities($value); $data[$i][$keyl] = $value; } $i++; } } mysql_free_result($result); $data = array_reverse($data); // Zet de nieuwste berichten bovenaan // in plaats van onderaan. $cnt = count($data); for($i = 0; $i < $cnt; ++$i) { $bericht = $data[$i]; echo(nl2br($bericht['bericht'])); // Met nl2br() worden alle enters in het // bericht omgezet naar <br/>. echo('</td></tr></table>'); $naarwie= $bericht['Email']; }mysql_query("UPDATE `Clicks` SET `Aan`= 1 WHERE `Email` = $naarwie"); mysql_close($Verbinding); // Sluit de verbinding. // We hebben hem nu niet meer nodig. So this code in short explained would be. It checks if all the "Aan" fields are on 0 if the list is empty so it means they are all on 1 he will reset all the fields of every user to 0. and then he will take a random person out and send the email to that person. And after the mail is send will change that person his value on "Aan" to value 1. Now if the list is not empty, that means there are still persons with value 0 in the list. Then he will take a random user out of all the persons who have "Aan" with value 0 send the mail to that user and change his "Aan" value to 1. This process will be repeated every time someone asks for information until all values of all users are on 1. And then again he will change them to 0 for everyone. I hope its clear what we are looking for. And I hope someone can help us out. We are clueless... Hello all
I'm new to this forum. I've been struggling on this problem for a few days now.
I’m writing a script to automatically push code to a git server. exec(‘git config user.name "’ . $userName . ‘"’); exec(‘git config user.email "’ . $userEmail . ‘"’); exec('git checkout -b ’ . $branch); exec(‘git add --all’); exec(‘git commit -m "’ . $message . ‘"’); exec('git push origin ’ . $branch);
When running the last command, the script stops and asks for a user name, then a password. I tried other forums, searching the net. I'm frustrated...
Thanks in advance. Say a script has ignore_user_abort(true); set. If the user aborts the connection and print is called, the buffer doesn't get written anywhere. So shouldn't print() return false in this case? To clarify, I know it doesn't, but shouldn't it? If not, why not? Hi All, I have a form that enables the user to know events that occur in a specific city. Most of the time they get the results in a few seconds, despite the fact that many rows in various tables might be searched for detailed infos about the events in that city. However, this form partly relies on a table against which a MySQL event regularly does some operations. If the user uses the form while the event is being executed, they have to wait up to 30 seconds before getting the results, and sometimes only part of the html page is generated. Is there a way to avoid this lengthy waiting time ? I am wondering whether or not the best would be putting the site on maintenance while the event is being executed, with a "please come back in a few minutes" message. Thanks in advance for your help. |