![]() |
|
Welcome to the Computer Webmaster Gaming Console Graphics Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
| |||||||
| Database Database problems or need to ask a question? maybe something to do with sql injections or a database software question. Database topics cover MySQL, PostgreSQL, Oracle, SQL Server or anything else related to databases. |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 | ||
| I have a mySQL database I am accessing via php using the code if(!$connection = mysql_pconnect("localhost",DBUSER,DBUSERPW)) { Fatalerror($connection); } then calling if(!mysql_select_db(DATABASE,$connection)) to select the database. where DBUSER,DBUSERPW and DATABASE are defined variables These functions appear to operate correctly. 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 have checked the insert query syntax by cutting and pasting into mySQL at the command line. mysql -h returns mysql Ver 14.7 Distrib 4.1.12, for mandriva-linux-gnu (i586) using readline 5.0 ..... cut .... auto-rehash TRUE character-sets-dir (No default value) default-character-set latin1 compress FALSE database (No default value) delimiter ; vertical FALSE force FALSE named-commands FALSE local-infile FALSE no-beep FALSE host (No default value) html FALSE xml FALSE line-numbers TRUE unbuffered FALSE column-names TRUE sigint-ignore FALSE port 3306 prompt mysql> quick FALSE raw FALSE reconnect TRUE socket (No default value) ssl FALSE ssl-key (No default value) ssl-cert (No default value) ssl-ca (No default value) ssl-capath (No default value) ssl-cipher (No default value) table FALSE debug-info FALSE user (No default value) safe-updates FALSE i-am-a-dummy FALSE connect_timeout 0 max_allowed_packet 16777216 net_buffer_length 16384 select_limit 1000 max_join_size 1000000 secure-auth FALSE Does this indicate that my php or mySQL setup is wrong ? I searched google groups, with no luck. Thanks in advance Carlton. | |||
| Advertisements |
| | #2 | ||
| "Carlton" <USENET@adent.demon.co.uk> wrote in message news:f61a5d$j57$1$8300dec7@news.demon.co.uk... >I have a mySQL database I am accessing via php using the code > if(!$connection = mysql_pconnect("localhost",DBUSER,DBUSERPW)) > { > Fatalerror($connection); > } > > then calling > if(!mysql_select_db(DATABASE,$connection)) to select the database. > > where DBUSER,DBUSERPW and DATABASE are defined variables > > These functions appear to operate correctly. > 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 have checked the insert query syntax by cutting and pasting into mySQL > at the command line. > > Perhaps you do not have the proper permissions? | |||
| | #3 | ||
| 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 | |||
| | #4 | ||
| Carlton wrote: > I have a mySQL database I am accessing via php using the code > if(!$connection = mysql_pconnect("localhost",DBUSER,DBUSERPW)) > { > Fatalerror($connection); > } > > then calling > if(!mysql_select_db(DATABASE,$connection)) to select the database. > > where DBUSER,DBUSERPW and DATABASE are defined variables > > These functions appear to operate correctly. > 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 have checked the insert query syntax by cutting and pasting into mySQL > at the command line. > > mysql -h returns > mysql Ver 14.7 Distrib 4.1.12, for mandriva-linux-gnu (i586) using > readline 5.0 > .... cut .... > auto-rehash TRUE > character-sets-dir (No default value) > default-character-set latin1 > compress FALSE > database (No default value) > delimiter ; > vertical FALSE > force FALSE > named-commands FALSE > local-infile FALSE > no-beep FALSE > host (No default value) > html FALSE > xml FALSE > line-numbers TRUE > unbuffered FALSE > column-names TRUE > sigint-ignore FALSE > port 3306 > prompt mysql> > quick FALSE > raw FALSE > reconnect TRUE > socket (No default value) > ssl FALSE > ssl-key (No default value) > ssl-cert (No default value) > ssl-ca (No default value) > ssl-capath (No default value) > ssl-cipher (No default value) > table FALSE > debug-info FALSE > user (No default value) > safe-updates FALSE > i-am-a-dummy FALSE > connect_timeout 0 > max_allowed_packet 16777216 > net_buffer_length 16384 > select_limit 1000 > max_join_size 1000000 > secure-auth FALSE > > Does this indicate that my php or mySQL setup is wrong ? > I searched google groups, with no luck. > Thanks in advance > Carlton. > First of all, don't use mysql_pconnect(). It will cause you more problems than it will solve. You may not have INSERT privileges. But I would expect mysql_errno to return a value (I forget exactly which one offhand). But you haven't shown the actual code you're using, so it's impossible to tell what the problem might be. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== | |||
| | #5 | ||
| Jon Slaughter wrote: > "Carlton" <USENET@adent.demon.co.uk> wrote in message > news:f61a5d$j57$1$8300dec7@news.demon.co.uk... >> I have a mySQL database I am accessing via php using the code >> if(!$connection = mysql_pconnect("localhost",DBUSER,DBUSERPW)) >> { >> Fatalerror($connection); >> } >> >> then calling >> if(!mysql_select_db(DATABASE,$connection)) to select the database. >> >> where DBUSER,DBUSERPW and DATABASE are defined variables >> >> These functions appear to operate correctly. >> 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 have checked the insert query syntax by cutting and pasting into mySQL >> at the command line. >> >> > > Perhaps you do not have the proper permissions? > > Running mySQL from the command line, using the same user and password the INSERT query runs without error. php will then find the inserted data using the mysql_query function. I would assume this means the user has suitable permissions. I will remove the pconnect function as advised. | |||
| Featured Websites | ||||
|
![]() |
| Tags: command, failure, insert, php |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Conditional INSERT | evanpeck@gmail.com | Database | 2 | 07-02-2007 10:59 AM |
| unwanted insert delay | christopher@dailycrossword.com | Database | 0 | 07-01-2007 11:00 PM |
| PHP rendering failure? | tns1 | PHP | 0 | 07-01-2007 3:36 PM |
| no post, no beeps...cpu failure? | dryOtto | Central Processing Unit (CPU) and Overclocking | 2 | 06-17-2007 9:07 PM |
| registration failure, live help failure | QuiltShopHopper | Ebay Technical Questions | 0 | 05-31-2007 12:38 AM |
| Featured Websites | ||||
|