简体   繁体   中英

PHP and MySQL Runs twice but only echos once

I'm troubleshooting a problem on my site and I have narrowed it down to the php being run twice. I assume this means the page is loaded twice but the catch is that the code is only echoed or printed once. I figured this out using ChromePHP to log some text. That text prints in the console twice every now and again.

The main issue is that I'm making a mysql query and setting a variable. In an example. It prints the ID number it gets as 2, but then the code randomly loads again and that variable is now set to something else... lets say 15 or whatever. But visually the echoed variable is still 2.

include 'php/classes/ChromePhp.php';
$link = mysqli_connect($host, $dbuser, $dbpass, $dbname );

if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}

if ($result = mysqli_query($link,'SELECT questionID FROM questions order by rand() limit 1')) {
    $row = mysqli_fetch_array($result);
    printf("Question ", $row['questionID']);
    mysqli_free_result($result);
    ChromePhp::log('QUESTIONID '.$row['questionID']);
}       
if($link) 
    mysqli_close($link);
?>

I've looked around and people say it could be the favicon being loaded separately or the .htaccess redirect which I use. I took the .htaccess off and I still have this issue.

Any pointers to a direction would be nice.

Thanks

I discovered it was a Google Chrome Extension: FirePHP that was causing the reload of code. Once I deleted the extension everything started working again!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM