tags:

views:

374

answers:

4

Hello,

I have this code

<?php
session_start();
if (isset($_GET["cmd"]))
  $cmd = $_GET["cmd"];
else
  die("You should have a 'cmd' parameter in your URL");
 $pk = $_GET["pk"];
$con = mysql_connect("localhost","root","geheim");
if(!$con)
{
die('Connection failed because of' .mysql_error());
}
mysql_select_db("ebay",$con);
if($cmd=="GetAuctionData")
{
echo "<table border='1' width='100%'>
<tr>
<th>Username</th>
<th>Start Date</th>
<th>Description</th>
</tr>";
$sql="SELECT * FROM Auctions WHERE ARTICLE_NO ='$pk'";
$result = mysql_query($sql);
while ($row = mysql_fetch_array($result))
{
echo "<tr>
<td>".$row['USERNAME']."</td>
<td>".$row['ARTICLE_NO']."</td>
<td>".$row['ARTICLE_NAME']."</td>
<td>".$row['SUBTITLE']."</td>
<td>".$row['CURRENT_BID']."</td>
<td>".$row['START_PRICE']."</td>
<td>".$row['BID_COUNT']."</td>
<td>".$row['QUANT_TOTAL']."</td>
<td>".$row['QUANT_SOLD']."</td>
<td>".$row['ACCESSSTARTS']."</td>
<td>".$row['ACCESSENDS']."</td>
<td>".$row['ACCESSORIGIN_END']."</td>
<td>".$row['USERNAME']."</td>
<td>".$row['BEST_BIDDER_ID']."</td>
<td>".$row['FINISHED']."</td>
<td>".$row['WATCH']."</td>
<td>".$row['BUYITNOW_PRICE']."</td>
<td>".$row['PIC_URL']."</td>
<td>".$row['PRIVATE_AUCTION']."</td>
<td>".$row['AUCTION_TYPE']."</td>
<td>".$row['ACCESSINSERT_DATE']."</td>
<td>".$row['ACCESSUPDATE_DATE']."</td>
<td>".$row['CAT_1_ID']."</td>
<td>".$row['CAT_2_ID']."</td>
<td>".$row['ARTICLE_DESC']."</td>
<td>".$row['COUNTRYCODE']."</td>
<td>".$row['LOCATION']."</td>
<td>".$row['CONDITIONS']."</td>
<td>".$row['REVISED']."</td>
<td>".$row['PAYPAL_ACCEPT']."</td>
<td>".$row['PRE_TERMINATED']."</td>
<td>".$row['SHIPPING_TO']."</td>
<td>".$row['FEE_INSERTION']."</td>
<td>".$row['FEE_FINAL']."</td>
<td>".$row['FEE_LISTING']."</td>
<td>".$row['PIC_XXL']."</td>
<td>".$row['PIC_DIASHOW']."</td>
<td>".$row['PIC_COUNT']."</td>
<td>".$row['ITEM_SITE_ID']."</td>
<td>".$row['STARTS']."</td>
<td>".$row['ENDS']."</td>
<td>".$row['ORIGIN_END']."</td>
</tr>
<tr><td></td></tr>";

}
echo "</table>";
echo "<img src=".$row['PIC_URL'].">";
}
mysql_close($con);
?>

Here is the generated html:

<table border='1' width='100%'>
<tr>
<th>Username</th>
<th>Start Date</th>
<th>Description</th>
</tr><tr>
<td>fashionticker1</td>
<td>220288560247</td>
<td>Ed Hardy Herren Shirt Rock & Roll Weiss XXL Neu & OVP</td>
<td></td>
<td>0.00</td>
<td>49.00</td>
<td>0</td>
<td>1</td>
<td>0</td>
<td>1.10.2008 16:22:09</td>
<td>6.10.2008 16:22:09</td>
<td>6.10.2008 16:22:09</td>
<td>fashionticker1</td>
<td>0</td>
<td>1</td>
<td>0</td>
<td>59.00</td>
<td>http://storage.supremeauction.com/flash/ebay2/10/49/76/10497654/13895964e.jpg&lt;/td&gt;
<td>0</td>
<td>1</td>
<td>6.10.2008 16:21:47</td>
<td>6.10.2008 16:28:31</td>
<td>32315</td>
<td>0</td>
<td><!-- +++++++++++++++++++++++++ Bitte ändern Sie im eigenen Interesse nichts an diesem Code! ++++++++++++++++++++++++ -->
<!-- +++++++++++++++++++++++++ Das kann massive Fehldarstellungen ihrer Auktion zur Folge haben! +++++++++++++++++++ -->
<!-- +++++++++++++++++++++++++ ++++++++++++++++++++++++++ Ihr Supreme Team +++++++++++++++++++++++++++++++++++++++++ -->
</td>
<td>
<br>
<br>
<style ty</td>
<td>float: right;
</td>
<td>margin: 0px;
</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>padding:5px; 
</td>
<td>0.00</td>
<td>0.00</td>
<td>0.00</td>
<td>0</td>
<td>0</td>
<td>font-size: 12px;
</td>
<td>color: #333333;
}
#h</td>
<td>0000-00-00 00:00:00</td>
<td>0000-00-00 00:00:00</td>
<td>0000-00-00 00:00:00</td>
</tr>
<tr><td></td></tr></table><img src=>

Whatever I do, I can not get an image to display, and when PIC_URL is empty, it only displays a placeholder image above the table, and I want it below.

+1  A: 

It should be:

echo "<img src=\"".$row['PIC_URL']."\">";
Philip Morton
This produces correct html, but no image is displayed.
Joshxtothe4
can you paste the HTML? I'll guess either the HTML is incorrect or the image doesn't exist on the given URL
Paul Dixon
The image definitely exists, I have pasted the html here: http://www.nomorepasting.com/getpaste.php?pasteid=22292
Joshxtothe4
+1  A: 

<style ty</td> looks like the problem to me.

Greg
that is not my doing, but part of the data that contains html markup. Why would it be preventing an image from showing if the image is outsideof the database?
Joshxtothe4
This is correct - the browser (tested in FF) seems to ignore the rest of the html as the tag is not closed. Maybe you can call strip_tags() or htmlentities() on that bad html data.
Tom Haigh
+1  A: 

You are generating that img tag outside of your while loop, which ends when $row is false. In other words, you'll only reach that code when $row doesn't contain any information because you've finished reading rows!

Either output a cell for the image, or output a new row with a single cell for the image spanning the entire row.

Paul Dixon
if i leave it in the loop nothing is displayed still
Joshxtothe4
+1  A: 
while ($row = mysql_fetch_array($result))
{
*snip*
}
echo "</table>";
echo "<img src=".$row['PIC_URL'].">";

Because the loop finished, $row is false. You need to change it to something like.

while ($row = mysql_fetch_array($result))
{
*snip*
$lastImg = $row['PIC_URL'];
}
echo "</table>";
echo "<img src=\"$lastImg\">";

Im starting to doubt you have a valid PIC_URL returned by yer database query. You should try this, see if you get any valid pictures from the url's, and especially if the last url in the list is valid.

while ($row = mysql_fetch_array($result))
{
    *snip*
    $images[] = $row['PIC_URL'];
}
echo "</table>";
?><p>Are these valid urls you can open in yer browser?</p><pre><?php
    print_r($images);
?></pre><?php
OIS
Still no image is displayed, although it generates correct html and there is definitely an image at the url
Joshxtothe4
You have to check:is there an attribute called PIC_URL returned with the query?does the last row in your query have a valid picture?does the url work if you put it in a browser?
OIS
The html is correct, and when I take the image url that is generated in the html it works fine,PIC_URL is returned with the query, I have changed to layers from a table but the problem is the same.
Joshxtothe4