mysql_query("UPDATE sites SET site_count =$newRow, access_time=$time, value=$value WHERE site_name='$site'") or die(mysql_error()); Code (markup): I would like to add auto refresh to the page instead of die(mysql_error()); Code (markup): can any of the expert guys help out.. i tried to put this one <?php echo "<meta http-equiv='refresh'>" ?> Code (markup): but its coming up with an error. what i need is to refresh the page rather than letting out a die error message.
try something like that $result=mysql_query($sql); $data=mysql_fetch_array($result); if($data) your code ; else { $thispage=$_SERVER['php_self']; $location='location:' . $thispage; header($location); //header('location:$thispage'); Code (markup):
What is the error message? hasanbasri solution sounds good, but beware that you can only use the header('location:$thispage') PHP: if you didn't echo anything else before on that page.
Guys i had tried that, but it is not working. here is the actual code mysql_query("UPDATE sites SET site_count =$newRow, access_time=$time, value=$value WHERE site_name='$site'") or die(mysql_error()); The page ends up an error sometimes. but when i refresh it, then it becomes ok. so what i would like is to replace this part die(mysql_error()); with an auto refresh code like <?php echo "<meta http-equiv='refresh'>" ?> but the thing is its ending up with an error. can u guys modify this code <?php echo "<meta http-equiv='refresh'>" ?> so that it can be replaced instead of die(mysql_error());
function pageRefresh() { $location = $_SERVER['PHP_SELF']; header("Location: $location"); } $query = mysql_query("SELECT * FROM table") or die(pageRefresh()); PHP: Let us know whether it works the way you wanted or not.
Thanks for the help. There is no header in the page. the page name is data_conect.php when i checked with the code given it is saying cannot find header. how should i continue?
As long as it's a PHP script, $_SERVER properties will always ( with a few exceptions ) be active. Can you show ( screenshot, copy/paste, .. ) us the exact output ?
Parse error: syntax error, unexpected '<' in /home/valued/public_html/database_connect.php on line 10 domain man this is the error i am getting. and the page does not have a header. this is a page that provides data to the main page
so you are saying, by the time this code is called the header is already outputted? if yes, then you will need to change the way its working. The example you are presenting for the refresh is php outputting HTML. And there's 2 files ? database_connect.php and data_connect.php ?
You should use square brackets around array subscripts, not round parentheses: $_SERVER['PHP_SELF'] Code (markup):
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING when using those brackets the above error comes up
That error means you have an extra space in there somewhere, probably inside the square brackets. $_SERVER['PHP_SELF'] with no spaces.
function pageRefresh1() { echo '<meta http-equiv="refresh" content="3;' . $_SERVER['PHP_SELF'] .'">'; } PHP: and the 3; is required to make the HTML redirect work. replace 3 with 0 if you want it immediate. or you can write the echo line like this : echo "<meta http-equiv='refresh' content=3;{$_SERVER['PHP_SELF']}>";