Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 107,708 PHP Programmers for FREE! Ask your question and get quick answers from experts. There are 1,131 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



mysql_fetch_array()

 
Reply to this topicStart new topic

mysql_fetch_array(), trying to join 2 tables in 2 different DBs together

Ladydice
post 9 Jul, 2008 - 12:07 AM
Post #1


New D.I.C Head

*
Joined: 25 Jun, 2008
Posts: 17


My Contributions


i've been having a hard time trying to join 2 tables in 2 different DBs together. This is the first time i'm doing this so please tell me if there's something wrng.

CODE

$result2=mysql_query("SELECT * FROM Cash.Payment
JOIN Contest.Details
ON Cash.Payment.INVOICE = Contest.Details.INVOICE  
WHERE Cash.Payment.USER_NAME = '$_COOKIE[ID_my_site]'
LIMIT $offset, $rowsPerPage");

while($row= mysql_fetch_array($result2)) {

echo "<td>" . $row['INVOICE']. "</td>";
echo "<td>" . $row['PAYMENT_STATUS']. "</td>";
echo "<td>" . $row['PAYMENT_DATE']. "</td>";
echo "<td>" . $row['AMOUNT']. "</td>";
echo "<td>" . $row['TRANS_ID']. "</td>";
echo "<td>" . $row['PAYER_STATUS']. "</td>";
echo "<td>" . $row['PAYER_STATUS']. "</td>";


i keep getting an error on my while statement.
error: mysql_fetch_array(): supplied argument is not a valid MySQL result resource

help would be much appreciated smile.gif
User is offlineProfile CardPM

Go to the top of the page


EvinOwen
post 11 Jul, 2008 - 01:40 PM
Post #2


New D.I.C Head

*
Joined: 1 Jul, 2008
Posts: 8



Thanked 1 times
My Contributions


the error you are getting is because there is a problem with your query. it means that you are passing a value to your mysql_fetch_array() function that is not the result of a mysql_query(), meaning that the query failed and has returned null. i would suggest checking to see if your result is null before attempting to access it, though its not necessary.

add 'or die(mysql_error())' after your mysql_query() function, and you can get the error from your query...

like this:

CODE

$result2 = mysql_query("SELECT * FROM Cash.Payment JOIN Contest.Details ON Cash.Payment.INVOICE = Contest.Details.INVOICE WHERE Cash.Payment.USER_NAME = '$_COOKIE[ID_my_site]' LIMIT $offset, $rowsPerPage") or die(mysql_error());
User is offlineProfile CardPM

Go to the top of the page

Ladydice
post 21 Jul, 2008 - 02:24 AM
Post #3


New D.I.C Head

*
Joined: 25 Jun, 2008
Posts: 17


My Contributions


QUOTE(EvinOwen @ 11 Jul, 2008 - 01:40 PM) *

the error you are getting is because there is a problem with your query. it means that you are passing a value to your mysql_fetch_array() function that is not the result of a mysql_query(), meaning that the query failed and has returned null. i would suggest checking to see if your result is null before attempting to access it, though its not necessary.

add 'or die(mysql_error())' after your mysql_query() function, and you can get the error from your query...

like this:

CODE

$result2 = mysql_query("SELECT * FROM Cash.Payment JOIN Contest.Details ON Cash.Payment.INVOICE = Contest.Details.INVOICE WHERE Cash.Payment.USER_NAME = '$_COOKIE[ID_my_site]' LIMIT $offset, $rowsPerPage") or die(mysql_error());



thanks alot for the tip.... biggrin.gif icon_up.gif
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 8/30/08 02:50AM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month