PHP and MYSQL

Associate
Joined
4 Mar 2003
Posts
1,484
Hi All,

could do with a little help, i've coded some php to pull results from mysql database, the problem is i keep getting the following error:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /content/StartupHostPlus/p/r/propertywherehouse.com/web/products.php on line 48

Code:
<?php

	// This page will list all of the items
	// from the items table. Each item will have
	// a link to add it to the cart

	include("db.php");
	
	// Get a connection to the database
	$cxn = @ConnectToDb($dbServer, $dbUser, $dbPass, $dbName);
	$result = mysql_query("select * from 'propwh'");
	?>
		
		<table width="750" cellspacing="0" cellpadding="0" border="0">
			<tr>
				<td width="25%" height="25" bgcolor="#CCCCCC">
					<font face="verdana" size="1" color="white">
						&nbsp;&nbsp;<b>Product</b>
					</font>
				</td>


				<td width="30%" height="25" bgcolor="#CCCCCC">
					<font face="verdana" size="1" color="white">
						&nbsp;&nbsp;<b>Image</b>
					</font>
				</td>


				<td width="10%" height="25" bgcolor="#CCCCCC">
					<font face="verdana" size="1" color="white">
						<b>Price</b>
					</font>
				</td>
				<td width="35%" height="25" bgcolor="#CCCCCC">
					<font face="verdana" size="1" color="white">
						<b>Description</b>
					</font>
				
			</tr>
			</table>
<br>
			<table width="750" cellspacing="0" cellpadding="0" border="0">
			
			<?php
			while($row = mysql_fetch_array($result))
			{
			?>
				<tr>
					<td width="25%" height="25">
						<font face="verdana" size="1" color="black">
							<?php echo $row["Location"]; ?>
						</font>
					</td>

					 <td width="30%" height="25"> 
<font face="verdana" size="1" color="black">
                        <a href="<?php echo $row['ref']; ?>" target"_blank" ><img border="0" img src="<?php echo $row["itemImage1"]; ?> "></a> 
</font>                    
</td>  




					<td width="10%" height="25">
						<font face="verdana" size="1" color="black">
							£<?php echo $row["itemPrice"]; ?>
						</font>
					</td>
					<td width="35%" height="25">
						<font face="verdana" size="1" color="black">
							<?php echo $row["itemDesc"]; ?>
						</font>
					</td>

					
				</tr>
				<tr>
					<td width="100%" colspan="5">
						<hr size="1" color="black" NOSHADE>
					</td>
				</tr>
			<?php
			}
		?>
			<tr>
				<td width="100%" colspan="4">
					<font face="verdana" size="1" color="black">
						<a href="cart.php">Your Shopping Cart &gt;&gt;</a>
					</font>
				</td>
			</tr>
		</table>

</center>

</body>

</html>

line 48 is:

while($row = mysql_fetch_array($result))


any ideas?

Thanks for your help in advance.
 
marc2003 said:
i don't know what's wrong. i'm using a similar query on a page of mine, and using your method works fine. :p

i think your php is fine. time to check the db/query perhaps? :)

you were right lol

$result = mysql_query("select * from 'propwh'");

I removed the quotes so it looked like

$result = mysql_query("select * from propwh");

it now works :D
 
Back
Top Bottom