Computer Webmaster Gaming Console Graphics Forum

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.

MK PitStop Main Earn $25 Earn Money Posting Extras Members Blogs Image Hosting User Pages
Go Back   Computer Webmaster Gaming Console Graphics Forum > Webmaster Forum > Website Coding > PHP
Register FAQ/Rules Become A V.I.P. Member Search Today's Posts Mark Forums Read

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.

Google
Reply
 
LinkBack Thread Tools Display Modes
Old 07-01-2007, 3:58 PM   #1
E-Star
 
E-Star's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default PHP & mySQL record update error

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>
===========================================
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Advertisements
Old 07-01-2007, 3:58 PM   #2
Andy Hassall
 
Andy Hassall's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default PHP & mySQL record update error

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)
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Old 07-01-2007, 3:59 PM   #3
E-Star
 
E-Star's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default PHP & mySQL record update error

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
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Old 07-01-2007, 3:59 PM   #4
Andy Hassall
 
Andy Hassall's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default PHP & mySQL record update error

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)
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Old 07-01-2007, 3:59 PM   #5
Andy Hassall
 
Andy Hassall's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default PHP & mySQL record update error

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)
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Old 07-01-2007, 4:12 PM   #6
E-Star
 
E-Star's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default PHP & mySQL record update error

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.
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Featured Websites
Free Space
Free Space
Free Space Free Space
Reply
Tags: , , , ,




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

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




All times are GMT +1. The time now is 2:55 PM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.0.0
Cheap Computers
MK PitStop Copyright 2005 - 2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98