Bluehost.com Web Hosting $6.95

MySQL query problems

This is a discussion on MySQL query problems within the PHP General forums, part of the PHP Programming Forums category; Hi, Not sure if the problem here is PHP or MySQL, but here we go. I am trying to do ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-16-2003
Beauford.2005
 
Posts: n/a
Default MySQL query problems

Hi,

Not sure if the problem here is PHP or MySQL, but here we go. I am
trying to do two queries on a database - one after the other, but the
second one never seems to get executed. The two queries are identical
except for two variables. I have checked my form and they are correct
and are being sent to the PHP script the way they should be.

The variables are $playerto, $playerfrom, $nameto, $namefrom. The 'TO'
query is the one that doesn't work.

Here is my code. Any help is appreciated.

if ($namefrom != $nameto) {
if ($playerfrom != $playerto) {

include("2004server.inc");
if($error) {
include("trades-input.php");
exit;
}

$query1 = "select manager.idn, manager.total,
roster.idp, position, points from roster join reference
join manager where manager.idn=reference.idn and
reference.idp=roster.idp and manager.idn like '$namefrom' and
roster.idp like '$playerfrom'";

$result1 = mysql_query($query1) or $mysqlerror =
mysql_error();
if ($mysqlerror) {
$error = "$d_base_error$email_error";
include("trades-input.php");
exit;
}

$line = mysql_fetch_row($result1);

mysql_free_result($result1);

$query2 = "select manager.idn, manager.total,
roster.idp, position, points from roster join reference
join manager where manager.idn=reference.idn and
reference.idp=roster.idp and manager.idn like '$nameto' and
roster.idp like '$playerto'";

$result2 = mysql_query($query2) or $mysqlerror =
mysql_error();
if ($mysqlerror) {
$error = "$d_base_error$email_error";
include("trades-inputs.php");
exit;
}

$row = mysql_fetch_array($result2);

mysql_free_result($result2);
}
}

Reply With Quote
  #2 (permalink)  
Old 07-16-2003
Marek Kilimajer
 
Posts: n/a
Default Re: [PHP] MySQL query problems

Change $email_error to $mysqlerror and hopefully some error message will
appear.

Beauford.2005 wrote:
> if ($mysqlerror) {
> $error = "$d_base_error$email_error";
> include("trades-input.php");
> exit;
> }



Reply With Quote
  #3 (permalink)  
Old 07-16-2003
Beauford.2005
 
Posts: n/a
Default RE: [PHP] MySQL query problems

I tried that, but there is no error to stop the script at this point.
The script continues past this point and to the end of the script -
there are just no values in the variables for the second query, which
obviously gives me the wrong results.

-----Original Message-----
From: Marek Kilimajer [mailto:kilimajer@webglobe.sk]
Sent: July 16, 2003 1:18 PM
To: Beauford.2005
Cc: PHP
Subject: Re: [php] MySQL query problems


Change $email_error to $mysqlerror and hopefully some error message will

appear.

Beauford.2005 wrote:
> if ($mysqlerror) {
> $error = "$d_base_error$email_error";
> include("trades-input.php");
> exit;
> }




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Reply With Quote
  #4 (permalink)  
Old 07-16-2003
Nomadeous
 
Posts: n/a
Default Re: MySQL query problems

But what's your prob ?
When you say the second one seems to never be executed ...
Does the line:
$row = mysql_fetch_array($result2);
launches a Php Error ?

And pay attention, because you're using mysql_fetch_array and
mysql_fetch_row, be sure that
you are not treating the result in the same way ;-)

"Beauford.2005" <beauford.2005@rogers.com> a écrit dans le message de news:
000001c34bb5$5772a200$6401a8c0@p1...
> Hi,
>
> Not sure if the problem here is PHP or MySQL, but here we go. I am
> trying to do two queries on a database - one after the other, but the
> second one never seems to get executed. The two queries are identical
> except for two variables. I have checked my form and they are correct
> and are being sent to the PHP script the way they should be.
>
> The variables are $playerto, $playerfrom, $nameto, $namefrom. The 'TO'
> query is the one that doesn't work.
>
> Here is my code. Any help is appreciated.
>
> if ($namefrom != $nameto) {
> if ($playerfrom != $playerto) {
>
> include("2004server.inc");
> if($error) {
> include("trades-input.php");
> exit;
> }
>
> $query1 = "select manager.idn, manager.total,
> roster.idp, position, points from roster join reference
> join manager where manager.idn=reference.idn and
> reference.idp=roster.idp and manager.idn like '$namefrom' and
> roster.idp like '$playerfrom'";
>
> $result1 = mysql_query($query1) or $mysqlerror =
> mysql_error();
> if ($mysqlerror) {
> $error = "$d_base_error$email_error";
> include("trades-input.php");
> exit;
> }
>
> $line = mysql_fetch_row($result1);
>
> mysql_free_result($result1);
>
> $query2 = "select manager.idn, manager.total,
> roster.idp, position, points from roster join reference
> join manager where manager.idn=reference.idn and
> reference.idp=roster.idp and manager.idn like '$nameto' and
> roster.idp like '$playerto'";
>
> $result2 = mysql_query($query2) or $mysqlerror =
> mysql_error();
> if ($mysqlerror) {
> $error = "$d_base_error$email_error";
> include("trades-inputs.php");
> exit;
> }
>
> $row = mysql_fetch_array($result2);
>
> mysql_free_result($result2);
> }
> }
>



Reply With Quote
  #5 (permalink)  
Old 07-17-2003
Beauford.2005
 
Posts: n/a
Default RE: [PHP] Re: MySQL query problems

Not sure what the problem was, but I dug up a similar script I used for
something else and modifed it for this project, and voila. I then put
the two side by side and I still can't see where the problem is.

Thanks for the input.

-----Original Message-----
From: Nomadeous [mailto:nomadeous@free.fr]
Sent: July 16, 2003 5:31 PM
To: php-general@lists.php.net
Subject: [php] Re: MySQL query problems


But what's your prob ?
When you say the second one seems to never be executed ...
Does the line:
$row = mysql_fetch_array($result2);
launches a Php Error ?

And pay attention, because you're using mysql_fetch_array and
mysql_fetch_row, be sure that you are not treating the result in the
same way ;-)

"Beauford.2005" <beauford.2005@rogers.com> a écrit dans le message de
news: 000001c34bb5$5772a200$6401a8c0@p1...
> Hi,
>
> Not sure if the problem here is PHP or MySQL, but here we go. I am
> trying to do two queries on a database - one after the other, but the
> second one never seems to get executed. The two queries are identical
> except for two variables. I have checked my form and they are correct
> and are being sent to the PHP script the way they should be.
>
> The variables are $playerto, $playerfrom, $nameto, $namefrom. The 'TO'


> query is the one that doesn't work.
>
> Here is my code. Any help is appreciated.
>
> if ($namefrom != $nameto) {
> if ($playerfrom != $playerto) {
>
> include("2004server.inc");
> if($error) {
> include("trades-input.php");
> exit;
> }
>
> $query1 = "select manager.idn, manager.total,
> roster.idp, position, points from roster join reference
> join manager where manager.idn=reference.idn and
> reference.idp=roster.idp and manager.idn like '$namefrom' and
> roster.idp like '$playerfrom'";
>
> $result1 = mysql_query($query1) or $mysqlerror = mysql_error();
> if ($mysqlerror) {
> $error = "$d_base_error$email_error";
> include("trades-input.php");
> exit;
> }
>
> $line = mysql_fetch_row($result1);
>
> mysql_free_result($result1);
>
> $query2 = "select manager.idn, manager.total,
> roster.idp, position, points from roster join reference
> join manager where manager.idn=reference.idn and
> reference.idp=roster.idp and manager.idn like '$nameto' and roster.idp


> like '$playerto'";
>
> $result2 = mysql_query($query2) or $mysqlerror = mysql_error();
> if ($mysqlerror) {
> $error = "$d_base_error$email_error";
> include("trades-inputs.php");
> exit;
> }
>
> $row = mysql_fetch_array($result2);
>
> mysql_free_result($result2);
> }
> }
>




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

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




All times are GMT +1. The time now is 07:23 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0