Re: [PHP] Mysql statement works in phpmyadmin but not in php page

2010-02-11 Thread Paul M Foster
On Thu, Feb 11, 2010 at 09:49:02PM -0600, Joseph Thayne wrote: > I was going to write an example as to what should happen instead of what > actually does when id dawned on me why MySQL works the way it does. One of > the biggest complaints people have with MySQL is in speed. The much-vaunted s

RE: [PHP] Mysql statement works in phpmyadmin but not in php page

2010-02-11 Thread Joseph Thayne
ment works in phpmyadmin but not in php page On Fri, Feb 12, 2010 at 09:44:47AM +1030, James McLean wrote: > On Fri, Feb 12, 2010 at 9:31 AM, Joseph Thayne wrote: > > As for the backticks, they are required because of MySQL, not because of > > phpMyAdmin.  The issue was not that

Re: [PHP] Mysql statement works in phpmyadmin but not in php page

2010-02-11 Thread Paul M Foster
On Fri, Feb 12, 2010 at 09:44:47AM +1030, James McLean wrote: > On Fri, Feb 12, 2010 at 9:31 AM, Joseph Thayne wrote: > > As for the backticks, they are required because of MySQL, not because of > > phpMyAdmin.  The issue was not that phpMyAdmin uses backticks, it is that > > MySQL pretty much re

Re: [PHP] Mysql statement works in phpmyadmin but not in php page

2010-02-11 Thread Joseph Thayne
Yeah, I am a lot more descriptive now. I ran into it quite a bit when I was first starting out. James McLean wrote: On Fri, Feb 12, 2010 at 9:31 AM, Joseph Thayne wrote: As for the backticks, they are required because of MySQL, not because of phpMyAdmin. The issue was not that phpMyAdmin

Re: [PHP] Mysql statement works in phpmyadmin but not in php page

2010-02-11 Thread James McLean
On Fri, Feb 12, 2010 at 9:31 AM, Joseph Thayne wrote: > As for the backticks, they are required because of MySQL, not because of > phpMyAdmin.  The issue was not that phpMyAdmin uses backticks, it is that > MySQL pretty much requires them when naming a field the same as an internal > function to m

Re: [PHP] Mysql statement works in phpmyadmin but not in php page

2010-02-11 Thread James McLean
On Fri, Feb 12, 2010 at 9:31 AM, Jochem Maas wrote: > Op 2/11/10 10:51 PM, James McLean schreef: >> My personal preference these days is to use Curly braces around >> variables in strings such as this, I always find excessive string >> concatenation such as is often used when building SQL queries

Re: [PHP] Mysql statement works in phpmyadmin but not in php page

2010-02-11 Thread Jochem Maas
Op 2/11/10 10:51 PM, James McLean schreef: > On Fri, Feb 12, 2010 at 8:27 AM, Joseph Thayne wrote: >> >> Actually, the syntax is just fine. I personally would prefer it the way you >> mention, but there actually is nothing wrong with the syntax. >> >>> The ,'$date1'"." is not correct syntax, chan

Re: [PHP] Mysql statement works in phpmyadmin but not in php page

2010-02-11 Thread Joseph Thayne
That is a good idea to use the curly braces. I consistently forget about them, and fell like an idiot every time I am reminded of them. As for the backticks, they are required because of MySQL, not because of phpMyAdmin. The issue was not that phpMyAdmin uses backticks, it is that MySQL pret

Re: [PHP] Mysql statement works in phpmyadmin but not in php page

2010-02-11 Thread James McLean
On Fri, Feb 12, 2010 at 8:27 AM, Joseph Thayne wrote: > > Actually, the syntax is just fine.  I personally would prefer it the way you > mention, but there actually is nothing wrong with the syntax. > >> The ,'$date1'"." is not correct syntax, change it to ,'".$date."' My personal preference thes

Re: [PHP] Mysql statement works in phpmyadmin but not in php page

2010-02-11 Thread Joseph Thayne
Actually, the syntax is just fine. I personally would prefer it the way you mention, but there actually is nothing wrong with the syntax. The ,'$date1'"." is not correct syntax, change it to ,'".$date."' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.ph

Re: [PHP] Mysql statement works in phpmyadmin but not in php page

2010-02-11 Thread james stojan
Thank you. You were right on the money, "hour" was the problem and the tick marks solved it. I spent 3 hours trying to figure out why I never got an error but there was no insert and php myadmin does add the tick marks automatically. Probably a good habit to always use the tick marks. Learn some

Re: [PHP] Mysql statement works in phpmyadmin but not in php page

2010-02-11 Thread Mari Masuda
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

Re: [PHP] Mysql statement works in phpmyadmin but not in php page

2010-02-11 Thread Kim Madsen
james stojan wrote on 11/02/2010 22:21: $query="INSERT INTO upload_history (v_id,hour,visits,date) VALUES (".$v_id.",".$hour.",".$visits.",'$date1'".");"; The ,'$date1'"." is not correct syntax, change it to ,'".$date."' -- Kind regards Kim Emax - masterminds.dk -- PHP General Mailing List

Re: [PHP] Mysql statement works in phpmyadmin but not in php page

2010-02-11 Thread Joseph Thayne
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 fie