Also, in PHP you should NOT put the last semi-colon at the end of your SQL 
statement.  http://www.php.net/manual/en/function.mysql-query.php

On Feb 11, 2010, at 1:26 PM, Joseph Thayne wrote:

> Try putting tick marks (`) around the field and table names.  So your SQL 
> query would then look like:
> 
> INSERT INTO `history` (`v_id`, `hour`, `visits`, `date`) VALUES (45, 0, 59, 
> '2010 01 27');
> 
> This is a good practice to get into.  The problem is that MySQL allows you to 
> create tables and fields with the same name as functions.  If the tick marks 
> are not there, then it assumes you mean to try using the function.  In your 
> case, hour is a function in mysql.  I would assume that the reason it works 
> in phpmyadmin is that it filters the query somehow to add the tick marks in.
> 
> Joseph
> 
> james stojan wrote:
>> I'm at my wits end trying to make this mysql statement insert work in
>> PHP. I'm not getting any errors from PHP or mysql but the insert fails
>> (nothing is inserted) error reporting is on and is reporting other
>> errors. When I echo out the query and manually paste it into PHP
>> myAdmin the query inserts without a problem. I know that I am
>> connecting to the database as well part of the data being inserted
>> comes from the same database and that the mysql user has permission to
>> do inserts (even tried as root no luck).
>> 
>> $query="INSERT INTO upload_history (v_id,hour,visits,date) VALUES
>> (".$v_id.",".$hour.",".$visits.",'$date1'".");";
>> 
>> $r2=mysql_query($query) or die("<b>A fatal MySQL error
>> occured</b>.\n<br />Query: " . $query . "<br />\nError: (" .
>> mysql_errno() . ") " . mysql_error());
>> 
>> This is an echo of $query and runs in phpmyadmin.
>> 
>> INSERT INTO history (v_id,hour,visits,date) VALUES (45,0,59,'2010 01 27');
>> 
>> 
>> Any idea what is going on here?
>> 
>>  
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to