Member Avatar for nova37
include ("config.php"); 
// select data from database   
$w3db = mysql_query( "SELECT * FROM w3dbx" )     
or die("SELECT Error: ".mysql_error());
$worth = mysql_query( "SELECT * FROM worth" )    
or die("SELECT Error: ".mysql_error());
$w3db_rows = mysql_query($w3db);               
$worth_rows = mysql_query($worth);				
// fetching data 
//while ($get_infox = mysql_fetch_assoc($resultx) && $get_info = mysql_fetch_assoc($result))
while ($get_w3db = mysql_fetch_array($w3db_rows,MYSQL_ASSOC) && $get_worth = mysql_fetch_array($worth_rows,MYSQL_ASSOC))
{

error :: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource ... line #
please check the code i do not know whats wrong with it seems to be perfect to me but getting error do not why ???

A few things - firstly you have out your die on the next line, php needs to be on one line, secondly you are running your mysql_query twice and thirdly you are trying to run two queries in your while loop.

This should work (unless there are other problems):

include ("config.php"); 
// select data from database   
$w3db = mysql_query( "SELECT * FROM w3dbx" ) or die("SELECT Error: ".mysql_error());
$worth = mysql_query( "SELECT * FROM worth" ) or die("SELECT Error: ".mysql_error());
			
// fetching data 
//while ($get_infox = mysql_fetch_assoc($resultx) && $get_info = mysql_fetch_assoc($result))
while ($get_w3db = mysql_fetch_array($w3db)) {
// code here
}
while ($get_worth = mysql_fetch_array($worth)) {
// code here
}

If you need to display the two sets of query results together you will either have to change your query to one using joins of run your second query within your first while loop.

@simplypixie:

firstly you have out your die on the next line, php needs to be on one line

Just a note: not true. You can use whitespace, including line breaks just fine.

thirdly you are trying to run two queries in your while loop.

I really really don't recommend this, but using the two fetches in the while also works... just DO NOT USE IT (can get very messy)...

Member Avatar for nova37

ya i know we can use two fetches in one while loop ... but i do not know whats wrong here... the same technique i use in my other codes and they work fine , but here do not know what wrong

pritaes:

Just a note: not true. You can use whitespace, including line breaks just fine.

Actually, yes I don't know why I put that as I have linebreaks in my code all the time.

I have never realised (and there used) multiple fetches in a while loop so my apologies as I didn't think it was acceptable as I have never seen it before.

darkc99:

Have you re-formatted your code to remove the duplicate mysql_query as I said?

Member Avatar for nova37

ya thanks

now its working but have one another problem with xml

$city = $book->Location->CityData->city; // city
$postal_code = $book->Location->CityData->postal_code; // postal code
$time_zone = $book->Location->CityData->time_zone; // time zone
$area_code = $book->Location->CityData->area_code; // area code

Notice: Trying to get property of non-object in line # ..

any other way to assign xml data to php variables so that exported to database

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.