473,385 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

PHP Corn Job not inserting into database

Please help
I have a php script that inserts current date and value into a table.
The scripts work fine on my local system when run but trows up error when run as corn job in my cpanel.

Expand|Select|Wrap|Line Numbers
  1.  
  2. <?php 
  3. # FileName="Connection_php_mysql.htm"
  4. # Type="MYSQL"
  5. # HTTP="true"
  6. $hostname_dbconnect = "localhost";
  7. $database_dbconnect = "database";
  8. $username_dbconnect = "username";
  9. $password_dbconnect = "password";
  10.  
  11. $dbconnect = mysql_pconnect($hostname_dbconnect, $username_dbconnect, $password_dbconnect) or trigger_error(mysql_error(),E_USER_ERROR); 
  12.  
  13. $date = date("Y-m-d");
  14. //$expiry = date ("Y-m-d", mktime (0,0,0,date("m")+12,(date("d")-1),date("Y")));
  15.  
  16. $Date = curdate();
  17.   $query = mysql_query("INSERT into counter (visit, date)
  18.                     VALUES('0', '$Date')");
  19.   if($query === false) 
  20.     { 
  21.         die("could not insert into database"); 
  22.     } 
  23.  
  24.  
  25. ?>
  26.  
---------------Error Message -----------------

could not insert into database

---------------End Error --------------------

Please what could be the cause and possible solution
Aug 29 '12 #1
3 1788
Luuk
1,047 Expert 1GB
dont use 'mysql_pconnect', its deprecated....

put an 'echo $query' between line 18 and 19, and check that your SQL is correct, preferably by issueing the statment directly in the mysql-client.
Aug 31 '12 #2
Hello Luuk,
The file works perfectly when viewed with a browser. I mean, it inserts the date and value. But when created a corn job in cpanel with the is "/usr/local/bin/php -q /home/username/public_html/corn.php"

It gives the below given error
---------------Error Message -----------------

could not insert into database

---------------End Error --------------------
Sep 3 '12 #3
Markus
6,050 Expert 4TB
In your query error handling, have a look at the output of
Expand|Select|Wrap|Line Numbers
  1. mysql_error()
for some information pertaining to the error.
Sep 3 '12 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: fidelio | last post by:
This could be a language for the next ten years (i think): http://corn.telefonia.pl/ Does anyone try it already ?
7
by: Jared Evans | last post by:
I developed a console application that will continually check a message queue to watch for any incoming data that needs to be inserted into MS SQL database. What would be a low-cost method I...
6
by: ronrsr | last post by:
here is my result. How do I determine the number of tuples in this array, returned from a mysql database? How do I determine the number of characters or entry in each tuple? thanks very much...
4
by: news.microsoft.com | last post by:
Hi all, Assume we have two entity class. Class1: Name: House Property: ID:int Name:String Desktops:Desktop
14
by: veer | last post by:
Hello expert. I made a program in which the data from an SQL table is transferred to an Excel sheet. When the data type of a field is Integer it works fine, but when the data type of a field is...
9
by: Shalini Bhalla | last post by:
What are corn jobs and how can i use it . Moreover can i use it with webhosting account with linux server ? if yes how ?
3
by: gupta24 | last post by:
i wrote one script....... 1. if run the script in cron how can put into the cron 2. the script will need to run every 10 mins how put it in the script (how can declare in my script) 3.when corn...
0
by: stutler.jil | last post by:
lyrics jimmy cracked corn http://cracks.12w.net F R E E
6
by: Bunty | last post by:
I want to insert values in the database.If i insert values one by one then it works till 4 or 5 fields then after it gives error.In my database there are more than 20 field.Pls help me.
2
by: AlexanderDeLarge | last post by:
Hi! I got a problem that's driving me crazy and I'm desperately in need of help. I'll explain my scenario: I'm doing a database driven site for a band, I got these tables for their discography...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.