Re: PHP/MySql Help
| From: | Philip Olson | Date: | Wed, 09 Apr 2003 21:54:45 +0000 |
| Subject: | Re: PHP/MySql Help | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-143222@lists.php.net to get a copy of this message | ||
On Wed, 9 Apr 2003 UGADawgs6910@aol.com wrote:
> Thanks for the help, but it still isn't working... I am not sure exactly of
> the problem, the thing is I am getting no error messages I am just not
> getting any of the variables back below... it is getting past the connect
> phase, and I tested out the query in PHPMyAdmin and it works. I've checked it
> over and over so I have no idea. I suppose the error must be in these lines:
>
> $insert = mysql_result($query or die ('im a piece'));
> $number = MYSQL_NUM_ROWS($query);
> if($number != 0) {
>
> $i = 0;
> $ordernumber = mysql_result($insert,$i,"ordernumber");
> $emailaddy = mysql_result($insert,$i,"emailaddy");
> }
> Thanks for the help, I wish I had more info to give you about the error. I
> know that $number is being returned as 0, if that helps at all. Thanks guys
The above code is all messed up. Rather then go into
detail why, please rewrite your code from scratch and
do so in a way that mimicks php.net/mysql_fetch_assoc
Hints:
a) Use mysql_query() which returns false on failure
b) Don't overuse mysql_result()
c) Use mysql_error() a lot
d) Start over
Example:
$sql = "SELECT * FROM bar";
if (!$result = mysql_query($sql)) {
print "Error, cannot run query ($sql) : " . mysql_error();
exit;
}
Regards,
Philip Olson