Jump to content
Can't remember your login details? Read more... ×

PHP and javascript problems

Recommended Posts



I have the following PHP code pasted here:




Which produces the following html code:




My problem is that the popup window is not created, or if it is created that it is empty. I have used JSON encode to try and strip bad characters and such, but it generates an empty document.write and an empty image source, when both PIC_URL and ARTICLE_DESC are definitely not empty. I am wondering if it is a problem of ARTICLE_DESC containing seperate script tags..if that is the problem how would I fix this?


Also, no image is displayed, despite PIC_URL being a correct image, this is because of an unclosed style tag, however I do not know why that is being generated, or how to prevent it. The html content in ARTICLE_DESC is outside of my control.

Share this post

Link to post
Share on other sites

Try the code below.

NB - I have commented all the Database parts and assigned my own test value to $row2['ARTICLE_DESC'] for testing purposes. Can't really help you with the picture side of things unless you provide me with either the database output or content. Good Luck


if (isset($_GET["cmd"]))
 $cmd = $_GET["cmd"];
 die("You should have a 'cmd' parameter in your URL");

$pk = $_GET["pk"];
$con = mysql_connect("localhost","test","geheim");
die('Connection failed because of' .mysql_error());
 $sql="SELECT * FROM Auctions WHERE ARTICLE_NO ='$pk'";
 $htmlset = mysql_query($sql2);
 $row2 = mysql_fetch_array($htmlset);
$row2['ARTICLE_DESC'] = 'This is the detailed description that should open in the window';

   function makewindows(){
     child1 = window.open ('about:blank');
     child1.document.write(" . "'".strip_tags($row2['ARTICLE_DESC'])."'" . ");	
//$result = mysql_query($sql);

//while ($row = mysql_fetch_array($result))
echo "<div id='leftlayer'>
 <strong>Article Number</strong> ".$row['ARTICLE_NO']."
   <p><strong>Article Name</strong></p> ".$row['ARTICLE_NAME']."
   <p><strong>Subtitle</strong></p> ".$row['SUBTITLE']."
   <p><strong>Username</strong></p> ".$row['USERNAME']."
   <p><strong>Total Selling</strong></p> ".$row['QUANT_TOTAL']."
   <p><strong>Total Sold</strong></p> ".$row['QUANT_SOLD']."

   <p><strong>Highest Bidder</strong></p> ".$row['BEST_BIDDER_ID']."
<div class='leftlayer2'>
 <strong>Current Bid</strong> ".$row['CURRENT_BID']."
 <p><strong>Start Price</strong></p> ".$row['START_PRICE']."
 <p><strong>Buyitnow Price</strong></p> ".$row['BUYITNOW_PRICE']."
 <p><strong>Bid Count</strong></p> ".$row['BID_COUNT']."
 <p><strong>Start Date</strong></p> ".$row['ACCESSSTARTS']."
 <p><strong>End Date</strong></p> ".$row['ACCESSENDS']."
 <p><strong>Original End</strong></p> ".$row['ACCESSORIGIN_END']."
 <p><strong>Auction Type</strong></p> ".$row['AUCTION_TYPE']."
<div class='leftlayer2'>
 <strong>Private Auction</strong></p> ".$row['PRIVATE_AUCTION']."
 <p><strong>Paypal Accepted</strong></p> ".$row['PAYPAL_ACCEPT']."
 <p><strong>Auction Watched</strong></p> ".$row['WATCH']."
 <p><strong>Finished</strong></p> ".$row['FINISHED']."
 <p><strong>Country</strong></p> ".$row['COUNTRYCODE']."
 <p><strong>Location</strong></p> ".$row['LOCATION']."
 <p><strong>Conditions</strong></p> ".$row['CONDITIONS']."
<div class='leftlayer2'>
 <strong>Auction Revised</strong></p> ".$row['REVISED']."
 <p><strong>Cancelled</strong></p> ".$row['PRE_TERMINATED']."
 <p><strong>Shipping to</strong></p> ".$row['SHIPPING_TO']."
 <p><strong>Fee Insertion</strong></p> ".$row['FEE_INSERTION']."
 <p><strong>Fee Final</strong></p> ".$row['FEE_FINAL']."
 <p><strong>Fee Listing</strong></p> ".$row['FEE_LISTING']."
 <p><a href='#' onclick='makewindows(); return false;'>Click for full description </a></p>

$lastImg = $row['PIC_URL'];
echo ("<div id='rightlayer'>Picture
<img src='".$lastImg."'>


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now