![]() |
|
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. |
| |||||||
| PHP PHP for some can be one of the hardest website programming codes, so do you need help on your PHP script, if it is php4, php5 or lower this is the place for you for any PHP help. |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 | ||
| In article <re0eiv0297e9sl1gfh8mgdja0muce5rk3s@4ax.com>, Andy Hassall <andy@andyh.co.uk> wrote: > Don't ask us, ask the database, it knows more about the situation. > > Output the error string returned by mysql_error() when the query > fails, and it wouldn't hurt to output the SQL statement as well. > You'll probably see the error straight away. > > If not, then post the output of the above. Ok, I used mysql_error() to get the database error. Also I tried it on a different server and I still get random results (ie. sometimes it works, sometimes it doesn't). Also, the sql statement is good and always works on command line. Database error: No Database Selected =========================================== My mySQL database has 2 fields id int (my key) sg char(50) test.php ---- <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <form action="test2.php" method="post"> <input type="text" name="sg"> <input name="click" type="submit" value="click"> </form> </body> </html> test2.php -------- <?php require_once('Connections/main.php'); $sql = 'UPDATE c_test SET sg="test" WHERE id=1'; mysql_query($sql) or die(mysql_error()); ?> <html><body> test </body></html> =========================================== | |||
|
| Advertisements |
| | #2 | ||
| On Tue, 29 Jul 2003 23:01:05 -0600, E-Star <unix_core@linuxmail.org> wrote: >Ok, I used mysql_error() to get the database error. >Also I tried it on a different server and I still get random results >(ie. sometimes it works, sometimes it doesn't). > >Also, the sql statement is good and always works on command line. > >Database error: No Database Selected In that case go back to where you set up the connection and add error handling to both the mysql_connect and mysql_select_db calls, as clearly it's missing. Most likely is the mysql_connect is failing, and since it's intermittent, top suspect would be maximum number of connections exceeded. -- Andy Hassall (andy@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk) Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space) | |||
|
| | #3 | ||
| In article <qo4fiv4nse83ungpul02eg008c8cn13d3g@4ax.com>, Andy Hassall <andy@andyh.co.uk> wrote: > On Tue, 29 Jul 2003 23:01:05 -0600, E-Star <unix_core@linuxmail.org> > wrote: > > >Ok, I used mysql_error() to get the database error. > >Also I tried it on a different server and I still get random results > >(ie. sometimes it works, sometimes it doesn't). > > > >Also, the sql statement is good and always works on command line. > > > >Database error: No Database Selected > > In that case go back to where you set up the connection and add error > handling to both the mysql_connect and mysql_select_db calls, as > clearly it's missing. > > Most likely is the mysql_connect is failing, and since it's > intermittent, top suspect would be maximum number of connections > exceeded. I'm getting weird results....I can't get the problem using Netscape but I do with other browsers. Other people I've talked to can get it while some can not. go to http://www.ayice.org/canadv/test.php press click, then back.....repeat like 10 times. If you so get the error you will see the sql_error followed by my sql command. (If you want to view the source you will have to download it as I don't know how to display a file a text.) go tp phpinfo.php for the php settings if it helps. Any ideas are appreciated....if you can even get the error :-/ Thanks | |||
|
| | #4 | ||
| On Wed, 30 Jul 2003 07:37:49 -0600, E-Star <unix_core@linuxmail.org> wrote: >> >Ok, I used mysql_error() to get the database error. >>> >>>Database error: No Database Selected >> >> In that case go back to where you set up the connection and add error >> handling to both the mysql_connect and mysql_select_db calls, as >> clearly it's missing. >> >> Most likely is the mysql_connect is failing, and since it's >> intermittent, top suspect would be maximum number of connections >> exceeded. > >I'm getting weird results....I can't get the problem using Netscape but >I do with other browsers. Other people I've talked to can get it while >some can not. > >go to http://www.ayice.org/canadv/test.php > >press click, then back.....repeat like 10 times. > >If you so get the error you will see the sql_error followed by my sql >command. (If you want to view the source you will have to download it >as I don't know how to display a file a text.) > >go tp phpinfo.php for the php settings if it helps. > >Any ideas are appreciated....if you can even get the error :-/ The error appeared first go here. Did you add error handling code to the mysql_connect and mysql_select_db functions or not? Ignoring errors there is the most likely path to getting 'No Database Selected' out of mysql_query ... Post the code of your connection include file? (with passwords masked out, of course). -- Andy Hassall (andy@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk) Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space) | |||
|
| | #5 | ||
| On Wed, 30 Jul 2003 16:00:44 -0600, E-Star <unix_core@linuxmail.org> wrote: >In article <l70giv0omm1r34fr7oomittsg8ljp9c1kr@4ax.com>, Andy Hassall ><andy@andyh.co.uk> wrote: > >> Did you add error handling code to the mysql_connect and >> mysql_select_db functions or not? Ignoring errors there is the most >> likely path to getting 'No Database Selected' out of mysql_query ... >> >> Post the code of your connection include file? (with passwords masked >> out, of course). > >I replied to this once but I don't know if it went through so here it >goes again..... > >I'm guilty of using Dreamweaver's code to interface to mysql using PHP. >Although I've made a few websites I've never experienced this problem >before....hence I don't know anything about the error handling code. It's the same style as you've used in the mysql_query calls. If Dreamweaver is generating code that ignores error conditions in connecting to the database, it ought to go straight in the bin... >Can you point me in the right direction before I dive into the code? I >have one of my websites running at www.ayice.com and I've never >experienced an error there.....can you think of a possible reason why >only now with the new database table I've created, that I'm >experiencing this error? There's not much point speculating about possible causes when you could get the actual cause by modifying the code, at which point you can then look for a fix to the actual problem. As I said before, look for mysql_connect and mysql_select_db calls in your code, presumably in the Connections/main.php include file, and add error handling in there. Instead of: $conn = mysql_connect(...); Use: $conn = mysql_connect(...) or die ("Connection failed: " . mysql_error()); And similar for the mysql_select_db error. Usual cause for a connection being refused intermittently is, as I posted before, too many concurrent connections to the database. -- Andy Hassall (andy@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk) Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space) | |||
|
| | #6 | ||
| I found a fix to this problem. As you suggested it was in the php/mysql handling code provided by Dreamweaver. After reading their bug fixes to MX 6.0 http://www.macromedia.com/support/dr.../mx/dwmx61_fix ed.html I updated and haven't experienced the problem since. After pulling a diff on the old and new files I believe they had forgot a single quote when sending the header info. To quickly summarize.....upgrade MX 6.0 to 6.1! Thanks all. | |||
|
| Featured Websites | ||||
|
![]() |
| Tags: error, mysql, php, record, update |
| 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 |
| PHP & mySQL record update error | Darryl Porter | PHP | 2 | 07-01-2007 3:58 PM |
| HOW TO: select only the last record in a mySQL table. | gsb | PHP | 0 | 07-01-2007 3:34 PM |
| Adding record to a MYSQL DB using PHP ? | James | PHP | 1 | 07-01-2007 3:32 PM |
| UPDATE a record in MYSQL DB with PHP | James | PHP | 1 | 07-01-2007 3:32 PM |
| Is it possible to update a record if it does not exist? | Jeff Silverman | Database | 1 | 06-10-2007 12:21 AM |
| Featured Websites | ||||
|