I have an insert query which work fine but there is something that I can't understand !
My query :
$query = $db -> prepare ("INSERT INTO table (data_1, data_2, data_3)
VALUES (:data_1, :data_2, :data_3)");
if ($query -> execute (array (":date_1" => $date_1, ":data_2" => $data_2, ":data_3" => $data_3)) == true AND ($query -> rowCount () > 0))
{
echo "Success";
}
else
{
echo "Failed";
}
This will return "Success" every time but insert one row into the database every a few minutes ! (Even if I try to refresh the page 1000 time, I will get "Success" but no new row in the database)
I can't find out where is the problem and I didn't find any answer for my problem while searching over internet !
Is there any way else to check if row has been inserted into the database correctly ?
Update :
I just found that when I use different URL like (example.com/?data_1=data1) and after (example.com/?data_1=data2), it work great and insert row to the database !
But when I try to use same URL again, the row will not be inserted for about 2 or 3 minutes !
Update 2 :
After working more than 10 hours on the scripts I just thought that maybe it's because of Varnish Cache Server that I use on my server !
Is that possible that Varnish make this problem because of caching pages and so the PHP script doesn't run because it serve by Varnish ?
*I have to check it next week when I am @ home because I don't have access to the server from other networks !
So I just like to know if there is any chance that disabling Varnish resolve this problem ? Because I don't have much experience on Varnish !
Update 3 :
I just disabled Varnish and it work fine, about using Varnish, Is there any way to configure Varnish to work better with dynamic pages ?
*I think but i'm not sure if Varnish work like that with dynamic pages, it can also make some security issue too ! I didn't check anything and i'm not an expert of using Varnish either but with my understanding of PHP I think it's not a good idea to use Varnish for dynamic pages !