Hello, It has happened that i am in need of a small php script to execute two empty and one update commands for a particular database on my server. Can anyone please tell me what should be teh syntax in php script so i run it from cron daily ?
Your requirement is not clear. Are you using mysql? What is meant by empty query? What table do you want to update?
Ok,here is what i am trying to do. I need to create php script to run queries to one of my database,i will be runing that php script from cron. The script should empty two tables and also update another one. Lets call updating table update_1 and and tables which must be emptied update_2 and update_3 Would be great of you could post the syntax of php script.
Thanks,i have tried it to update the table but it seems that there is something wrong with my code.. <?php $con = mysql_connect("localhost","database_name","database_password"); if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("my_db", $con); mysql_query("update tsl_sites set hit_count=0");mysql_close($con); ?> Any suggestions?
I think your database name is not database_name and password is not database_password (create a database and database password first)
i think you should create simple script for database connectivity and queries, than put it on cronjobs...
neelesh, He is trying to get the script to work, then call it from a cron job. When something doesn't work, show us what the output was, e.g. an error message. I think "it career" is right about the database settings.
Thanks everyone,i have figured out correct code,the script works just perfect and there are just 11 lines of code.