Reply to Re: php insert command failure

Your name:

Reply:


Posted by J.O. Aho on 06/29/07 05:05

Carlton wrote:
> I have a mySQL database I am accessing via php using the code
> if(!$connection = mysql_pconnect("localhost",DBUSER,DBUSERPW))
> {
> Fatalerror($connection);
> }

If you will have many users using your script, switch to mysql_connect() or
you risk to run out of "connection slots".

> If I run SELECT queries, using $result=mysql_query($query,$connection);
> I get the correct data returned from the database.
> However, running INSERT queries fail.
> mysql_errno($connection) and mysql_error() both return empty strings,
> giving no indication of the cause of the error.

I suggest you echo out the insert query and then try that query manually.
I do suspect, as Jon, that you may not have permissions with the selected
DBUSER to do the inserts you want.


> Does this indicate that my php or mySQL setup is wrong ?

If php had been the problem, then you got an "undefined function" error and if
mysql had been wrongly setup you most likely wouldn't been able to connect to
it. The great benefit of running Linux or BSD is that the default settings
will ensure that things works (no need to hassle with settings like microsoft
users has to get things to work, of course use the official packages from your
distribution).
If you have a low number of "connection slots" and use mysql_pconnect(), it's
known to give troubles, specially if you use more than one database at the
same time (not talking about multiple servers), as mysql_pconnect() will
remember the last database selected and will use that by default.

You know there is alt.php.sql that is for this kind of questions.


--

//Aho

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация