Jump to content

Recommended Posts

Hi everyone,

 

I am working on what I suppose I could call a data entry form.  The client is a book store and they want to be able to enter books and have some fields maintain their values after clicking the submit button.  For example if they have multiple books of the genre 'Mystery' they want this dropdown menu to remain selected on 'Mystery' after they click submit. 

 

I have been able to get this to work EXCEPT the client also has the option of entering the ISBN number of a book in a 'lookup' text field, clicking a button called 'lookup' and the information is retrieved from a public book database.  This is where I have the problem with the session variables.  The first php form they reach (when logging in) is called 'addbook.php'.  This form is blank and if they enter all of the information and click 'Submit' the information in fields with an (*) are maintained when they are returned to the form.  However, if they use the 'lookup' field they are sent to a similar form called addbook_lookup.php which has an 'include' (xmlparser_rc2.php) that looks up the data from the public database and then fills in the form with that data.  It is here that any variables that they input from the prior page should also be maintain, however, I believe the xmlparser_rc2.php script is overwriting the session variables for those fields designated with the (*).  I am not sure what to do.

 

Here is the flow:

 

Without using the lookup field

addbook.php -> 'Submit' -> submitbook.php -> addbook.php (fields with an * are maintained)

 

Using the lookup field

addbook.php -> 'Lookup' -> addbook_lookup.php w/ include xmlparser_rc2.php -> 'Submit' -> submitbook.php -> addbook.php (fields with an * are NOT maintained)

 

Here is the code:

 

1st form - addbook.php

 


<?php
global $title,$author,$subject,$month,$year,$subject,$publisher,$commentary;

$title = $author = $subject = $month = $year = $subject = $publisher = $commentary ="";

$isbn=$HTTP_POST_VARS['isbn'];
if ($isbn != "") {
include 'xmlparser_rc2.php';
}
?>


<div align="center"><font face="Verdana, Arial, Helvetica, sans-serif">Add Book (<font color="#FF0000"><b>* </b></font>items will be 

repeated)</font></div>
<form name="lookupform" method="post" action="addbook_lookup.php">
<span class="formcontent">ISBN new:</span>
<?php
echo '<input name="isbn" type="text" value="'.$isbn.'" id="isbn">'; 
?>
<input type="submit" name="Submit2" value="Lookup" >
</form>

<form name="form1" method="post" action="submitbook.php">
<p><b></b></p>
<table width="100%" border="0">

<tr>
<td><input type="submit" name="Submit" value="Submit"><input name="" value="Clear" type="reset" onClick="location='addbook.php'" onMouseDown="<?php session_destroy(); ?>"></td>
<td>
<?php echo '<input name="isbn" type="hidden" value="'.$isbn.'">'; ?>

</td>
</tr>

<tr>
<td><span class="formcontent">J&J Price:</span></td>
<td><input name="priceAct" type="text" id="priceAct" maxlength="20"></td>
</tr>

<tr>
<td><span class="formcontent">Number of copies:</span></td>
<td><input name="copies" type="text" id="copies" size="4" maxlength="3"></td>
</tr>
<tr>
<td width="22%"><span class="formcontent">Title:</span> </td>
<td width="78%">
<?php
echo '<input name="title" type="text" id="title" size="50" value="'.$title.'">';
?>
</td>
</tr>
<tr>
<td><span class="formcontent">Author:</span></td>
<td>
<?php
echo '<input name="author" type="text" id="author" size="50" value="'.$author.'" maxlength="200">';
?>
</td>
</tr>
<tr>
<td><span class="formcontent">Publisher:</span></td>
<td>
<?php
echo '<input name="publisher" type="text" id="publisher" size="50" value="'.$publisher.'" maxlength="100">';
?>
</td>
</tr>
<tr>
<td><span class="formcontent">Distributor:</span></td>
<td>
<?php

if (isset ($_SESSION['distributor'])) {
echo '<input name="distributor" type="text" id="distributor" value="'.$_SESSION['distributor'].'">';

} else {
echo '<input name="distributor" type="text" id="distributor" value="" maxlength="20">';

}echo '<font color="#FF0000"><b> *</b></font>';
?>
</td>
</tr>

<tr>
<td><span class="formcontent">Commentary:</span></td>
<td><textarea name="commentary" cols="50" rows="5" id="commentary"><?php echo $commentary ?></textarea></td>
</tr>
<tr>
<td><span class="formcontent">Image</span></td>
<td>
<?php
if ($isbn == "") {
echo '<input name="image" type="text" id="image" value="na.gif" maxlength="50">';
} else {
echo '<input name="image" type="text" id="image" value="'.$isbn.'.jpg" maxlength="50">';
}
?>
</td>
</tr>

<tr>
<td><span class="formcontent">Theme:</span></td>
<td>
<select name="theme" id="theme">
<?php
$database=mysql_pconnect('localhost','jandj_root');
mysql_select_db('bookthemes');


if (isset ($_SESSION['theme'])) {
echo '<option value="'.$_SESSION['theme'].'" " selected">'.$_SESSION['theme'].'</option>';

$sql = "SELECT * FROM jandj_jandj.bookthemes WHERE theme != '".$_SESSION['theme']."'";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)){
echo '<option value="'.$row['theme'].'">'.$row['theme'].'</option>';
}

} else { 

echo '<option value="" "selected">Choose Theme</option>';
$sql = "SELECT * FROM jandj_jandj.bookthemes";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)){
echo '<option value="'.$row['theme'].'">'.$row['theme'].'</option>';
}

}
?> 
</select><font color="#FF0000"><b> *</b></font>


</td>
</tr>
<tr>
<td><span class="formcontent">Recommended:</span></td>
<td><input name="recommend" type="checkbox" id="recommend" value="1"></td>
</tr>
<tr>
<td><span class="formcontent">Reference Num:</span></td>
<td><input name="referenceNum" type="text" id="referenceNum" value="0" maxlength="20"></td>
</tr>
<tr>
<td><span class="formcontent">Tracking Num:</span></td>
<td><input name="trackingNumber" type="text" id="trackingNumber" value="000000000000" maxlength="20"></td>
</tr>
<tr>
<td><span class="formcontent">Grade Level:</span></td>
<td>
<select name="gradeLevel" id="gradeLevel">
<?php
$database=mysql_pconnect('localhost','jandj_root');
mysql_select_db('gradelevel');


if (isset ($_SESSION['gradeLevel'])) {
echo '<option value="'.$_SESSION['gradeLevel'].'" " selected">'.$_SESSION['gradeLevel'].'</option>';

$sql = "SELECT * FROM jandj_jandj.gradelevel WHERE gradelevel != '".$_SESSION['gradeLevel']."'";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)){
echo '<option value="'.$row['gradelevel'].'">'.$row['gradelevel'].'</option>';
}

} else { 

echo '<option value="" "selected">Choose Grade</option>';
$sql = "SELECT * FROM jandj_jandj.gradelevel";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)){
echo '<option value="'.$row['gradelevel'].'">'.$row['gradelevel'].'</option>';
}

}
?> 
</select> <font color="#FF0000"><b> *</b></font>

</td>
</tr>

<tr>
<td><span class="formcontent">New/Used:</span></td>
<td>
<select name="newUsed" id="newUsed">
<?php
$database=mysql_pconnect('localhost','jandj_root');
mysql_select_db('newUsed');


if (isset ($_SESSION['newUsed'])) {
echo '<option value="'.$_SESSION['newUsed'].'" " selected">'.$_SESSION['newUsed'].'</option>';

$sql = "SELECT * FROM jandj_jandj.newUsed WHERE newUsed != '".$_SESSION['newUsed']."'";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)){
echo '<option value="'.$row['newUsed'].'">'.$row['newUsed'].'</option>';
}

} else { 

echo '<option value="" "selected">Choose New or Used</option>';
$sql = "SELECT * FROM jandj_jandj.newUsed";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)){
echo '<option value="'.$row['newUsed'].'">'.$row['newUsed'].'</option>';
}

}
?> 
</select> <font color="#FF0000"><b> *</b></font>

</td>
</tr>

<tr>
<td><span class="formcontent">Special Promotions:</span></td>
<td>
<select name="specPromo" id="specPromo">
<?php
$database=mysql_pconnect('localhost','jandj_root');
mysql_select_db('specPromo');


if (isset ($_SESSION['specPromo'])) {
echo '<option value="'.$_SESSION['specPromo'].'" " selected">'.$_SESSION['specPromo'].'</option>';

$sql = "SELECT * FROM jandj_jandj.specPromo WHERE specPromo != '".$_SESSION['specPromo']."'";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)){
echo '<option value="'.$row['specPromo'].'">'.$row['specPromo'].'</option>';
}

} else { 

echo '<option value="" "selected">Choose Promotion</option>';
$sql = "SELECT * FROM jandj_jandj.specPromo";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)){
echo '<option value="'.$row['specPromo'].'">'.$row['specPromo'].'</option>';
}

}
?>  
</select> <font color="#FF0000"><b> *</b></font>

</td>
</tr>

<tr>
<td><span class="formcontent">Shipping Delay:</span></td>
<td>

<?php

if (isset ($_SESSION['shippingDelay'])) {
echo '<input name="shippingDelay" type="text" id="shippingDelay" value="'.$_SESSION['shippingDelay'].'">';

} else {
echo '<input name="shippingDelay" type="text" id="shippingDelay" value="" size="4" maxlength="4">';

}echo '<font color="#FF0000"><b> *</b></font>';
?> 

 

From here if they enter information for a new book and just click 'Submit' the variables are sent to this php script which puts the information into the MySQL database:

 

2nd submitbook.php -

 

<?php

session_start();

$title=$HTTP_POST_VARS['title'];
$isbn=$HTTP_POST_VARS['isbn'];
$author=$HTTP_POST_VARS['author'];
$publisher=$HTTP_POST_VARS['publisher'];
$commentary=$HTTP_POST_VARS['commentary'];
$image=$HTTP_POST_VARS['image'];
$theme=$HTTP_POST_VARS['theme'];
$recommend=$HTTP_POST_VARS['recommend'];
$referenceNum=$HTTP_POST_VARS['referenceNum'];
$pricePub=$HTTP_POST_VARS['pricePub'];
$priceAct=$HTTP_POST_VARS['priceAct'];
$day=$HTTP_POST_VARS['day'];
$month=$HTTP_POST_VARS['month'];
$year=$HTTP_POST_VARS['year'];
$trackingNumber=$HTTP_POST_VARS['trackingNumber'];
$gradeLevel=$HTTP_POST_VARS['gradeLevel'];
$copies=$HTTP_POST_VARS['copies'];
$shippingDelay=$HTTP_POST_VARS['shippingDelay'];
$distributor=$HTTP_POST_VARS['distributor'];
$display=$HTTP_POST_VARS['display'];
$newUsed=$HTTP_POST_VARS['newUsed'];
$specPromo=$HTTP_POST_VARS['specPromo'];
$date=$year."-".$month."-".$day;

$tempdate = getdate( );
$entryDate = $tempdate['year'].'-'.$tempdate['mon'].'-'.$tempdate['mday'];

//Connect to database
$database=mysql_pconnect('localhost','jandj_root');
if (!$database)
{ 
header('Location: errorbook?type=1.php');  
exit;
}

mysql_select_db('books');
$query="select * from jandj_jandj.books";
$result=mysql_query($query);
$column=mysql_fetch_array($result);
$i = 0;
while ($i<$copies) {
$submit="INSERT INTO jandj_jandj.books VALUES ('','".$title."','".$isbn."','".$author."','".$date."','".$commentary."','','".$image."','','".$theme."','".$recommend."','".$referenceNum."','".$pricePub."','".$priceAct."','".$publisher."','".$trackingNumber."','".$gradeLevel."','".$shippingDelay."','".$distributor."','".$display."','".$entryDate."','".$newUsed."','".$specPromo."')";
$i++;
$result=mysql_query($submit) or die("Error submitting books: ".mysql_error());
}


if ($result)
{
// Data submitted.  Returning to main book page.';
         //unset($_SESSION['theme']);
         
         $_SESSION["distributor"] = "$distributor";
         $_SESSION["theme"] = "$theme";
         $_SESSION["gradeLevel"] = "$gradeLevel";
         $_SESSION["newUsed"] = "$newUsed";
         $_SESSION["specPromo"] = "$specPromo";
         $_SESSION["shippingDelay"] = "$shippingDelay";
         header('Location: addbook.php');


} else {
// header('Location: errorbook.php?type=2');  
echo 'Error submitting book info!<br>
$result = '.$result;
}



?>

 

Now if the user uses the 'Lookup' field they will be directed to this code (addbook_lookup.php) which is basically the same as 'addbook.php' but has an include called 'xmlparser_rc2.php'.  Once the information is retrieved they will click 'Submit' and the variables will be sent to 'submitbook.php' just like the 'addbook.php' page.

 

3rd using lookup field addbook_lookup.php -

 

<?php
global $title,$author,$subject,$month,$year,$subject,$publisher,$commentary;

$title = $author = $subject = $month = $year = $subject = $publisher = $commentary ="";

$isbn=$HTTP_POST_VARS['isbn'];

if ($isbn != "") {
// First strip any - from the number
$newISBN = str_replace("-", "", $isbn);
//echo 'strlen($newISBN) = '.strlen($newISBN);
if (strlen($newISBN) > 10) { // Then if the resulting code is longer than the normal ISBN 
	// ... strip off first three digits and anything after the 13th digit
	$subISBN = substr($newISBN, 3, 9); 
	//echo '$subISBN = '.$subISBN;
	//echo '<br>';
	$total = 0;
	for ($i = 0; $i<10; $i++) {
		$a = substr($subISBN,$i,1);
		$d=  $a*(10-$i);
		//echo '$a = '.$a.'  a*(11-i) = '.$d;
		//echo '<br>';

		$total = $total + $d;
	}
	 $b = ($total % 11); 
	if ($b==0) {$b= 11;}
	$c = 11 - $b;
	// Add the check digit to the end of the ISBN number
	$subISBN .= $c;
	$isbn = $subISBN;
	// end of change number
	//echo 'scanned barcode = '.$newISBN;
	//echo '<br>';
	//echo '$total = '.$total;
	//echo '<br>';
	//echo '$b = '.$b;
	//echo '<br>';
	//echo '$c = '.$c;
	//echo '<br>';
	//echo 'final isbn = '.$isbn;

} else { $isbn = $newISBN;} // end of convert to proper ISBN
include 'xmlparser_rc2.php';
}
?>


<div align="center"><font face="Verdana, Arial, Helvetica, sans-serif">Add Book (<font color="#FF0000"><b>* </b></font>items will be repeated)</font></div>
<form name="lookupform" method="post" action="addbook_lookup.php">
  <span class="formcontent">ISBN:</span> 
<?php echo '<input name="isbn" type="text" value="'.$isbn.'" id="isbn">'; ?>
    <input type="submit" name="Submit2" value="Lookup">
</form>

<form name="form1" method="post" action="submitbook.php">
  <p><b></b></p>
  <table width="100%" border="0">
    
    <tr> 
      <td><input type="submit" name="Submit" value="Submit">
  <input name="" value="Clear" type="reset" onClick="location='addbook.php'" onMouseDown="<?php session_destroy(); ?>"></td>
      <td>
  	<?php echo '<input name="isbn" type="hidden" value="'.$isbn.'">'; ?>

</td>
    </tr>
    <tr>
      <td><span class="formcontent">J&J Price:</span></td>
      <td><input name="priceAct" type="text" id="priceAct" maxlength="20"></td>
    </tr>

<!--publisher price deleted -->

      <tr>
      <td><span class="formcontent">Number of copies:</span></td>
      <td><input name="copies" type="text" id="copies" size="4" maxlength="3"></td>
    </tr>
<tr> 
      <td width="22%"><span class="formcontent">Title:</span>	  </td>
      <td width="78%">
  	  <?php
	   echo '<input name="title" type="text" id="title" size="50" value="'.$title.'">';
	  ?>
      </td>
    </tr>
    <tr>
      <td><span class="formcontent">Author:</span></td>
      <td>
  <?php
   echo '<input name="author" type="text" id="author" size="50" value="'.$author.'" maxlength="200">';
  ?>
  </td>
    </tr>
    <tr>
      <td><span class="formcontent">Publisher:</span></td>
      <td>	  
  <?php
   echo '<input name="publisher" type="text" id="publisher" size="50" value="'.$publisher.'" maxlength="100">';
  ?>
  </td>
    </tr>
	 <tr>
      <td><span class="formcontent">Distributor:</span></td>
      <td>	  
<?php

if (isset ($_SESSION['distributor'])) {
echo '<input name="distributor" type="text" id="distributor" value="'.$_SESSION['distributor'].'">';

} else {
echo '<input name="distributor" type="text" id="distributor" value="" maxlength="20">';

}echo '<font color="#FF0000"><b> *</b></font>';
?>
  </td>
    </tr>
    <tr>
      <td><span class="formcontent">Commentary:</span></td>
  <?php 
  // Check for www.powells.com in commentary string.  If there is this indicates too much commentary was grabbed from the site
  if (strpos($commentary,"owells.com") != '') {
  	echo '<font color="#FF0000">
			<b>Warning!</b> The commentary contains the text "www.powells.com" 
			which indicates an error in the capture of the commentary text. Please check the commentary
        		text and edit or delete as needed.</font><br><br>';
	}
	?>
      <td><textarea name="commentary" cols="50" rows="5" id="commentary"><?php echo $commentary ?></textarea>
        </td>
    </tr>
    <tr>
      <td><span class="formcontent">Image</span></td>
      <td>
  	<?php
      	if ($isbn == "") { 
		echo '<input name="image" type="text" id="image" value="na.gif" maxlength="50">'; 
	} else {
		echo '<input name="image" type="text" id="image" value="'.$isbn.'.jpg" maxlength="50">'; 		
	}
	?>
  </td>
    </tr>
<tr>
<td><span class="formcontent">Theme:</span></td>
<td>
<select name="theme" id="theme">
<?php
$database=mysql_pconnect('localhost','jandj_root');
mysql_select_db('bookthemes');


if (isset ($_SESSION['theme'])) {
echo '<option value="'.$_SESSION['theme'].'" " selected">'.$_SESSION['theme'].'</option>';

$sql = "SELECT * FROM jandj_jandj.bookthemes WHERE theme != '".$_SESSION['theme']."'";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)){
echo '<option value="'.$row['theme'].'">'.$row['theme'].'</option>';
}

} else { 

echo '<option value="" "selected">Choose Theme</option>';
$sql = "SELECT * FROM jandj_jandj.bookthemes";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)){
echo '<option value="'.$row['theme'].'">'.$row['theme'].'</option>';
}

}
?> 
</select><font color="#FF0000"><b> *</b></font>


</td>
</tr>
    <tr>
      <td><span class="formcontent">Recommended:</span></td>
      <td><input name="recommend" type="checkbox" id="recommend" value="1"></td>
    </tr>
    <tr>
      <td><span class="formcontent">Reference Num:</span></td>
      <td><input name="referenceNum" type="text" id="referenceNum" value="0" maxlength="20"></td>
    </tr>
	<tr>
      <td><span class="formcontent">Tracking Num:</span></td>
      <td><input name="trackingNumber" type="text" id="trackingNumber" value="000000000000" maxlength="20"></td>
    </tr>
<tr>
<td><span class="formcontent">Grade Level:</span></td>
<td>
<select name="gradeLevel" id="gradeLevel">
<?php
$database=mysql_pconnect('localhost','jandj_root');
mysql_select_db('gradelevel');


if (isset ($_SESSION['gradeLevel'])) {
echo '<option value="'.$_SESSION['gradeLevel'].'" " selected">'.$_SESSION['gradeLevel'].'</option>';

$sql = "SELECT * FROM jandj_jandj.gradelevel WHERE gradelevel != '".$_SESSION['gradeLevel']."'";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)){
echo '<option value="'.$row['gradelevel'].'">'.$row['gradelevel'].'</option>';
}

} else { 

echo '<option value="" "selected">Choose Grade</option>';
$sql = "SELECT * FROM jandj_jandj.gradelevel";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)){
echo '<option value="'.$row['gradelevel'].'">'.$row['gradelevel'].'</option>';
}

}
?> 
</select> <font color="#FF0000"><b> *</b></font>

</td>
</tr>
<tr>
<td><span class="formcontent">New/Used:</span></td>
<td>
<select name="newUsed" id="newUsed">
<?php
$database=mysql_pconnect('localhost','jandj_root');
mysql_select_db('newUsed');


if (isset ($_SESSION['newUsed'])) {
echo '<option value="'.$_SESSION['newUsed'].'" " selected">'.$_SESSION['newUsed'].'</option>';

$sql = "SELECT * FROM jandj_jandj.newUsed WHERE newUsed != '".$_SESSION['newUsed']."'";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)){
echo '<option value="'.$row['newUsed'].'">'.$row['newUsed'].'</option>';
}

} else { 

echo '<option value="" "selected">Choose New or Used</option>';
$sql = "SELECT * FROM jandj_jandj.newUsed";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)){
echo '<option value="'.$row['newUsed'].'">'.$row['newUsed'].'</option>';
}

}
?> 
</select> <font color="#FF0000"><b> *</b></font>

</td>
</tr>

<tr>
<td><span class="formcontent">Special Promotions:</span></td>
<td>
<select name="specPromo" id="specPromo">
<?php
$database=mysql_pconnect('localhost','jandj_root');
mysql_select_db('specPromo');


if (isset ($_SESSION['specPromo'])) {
echo '<option value="'.$_SESSION['specPromo'].'" " selected">'.$_SESSION['specPromo'].'</option>';

$sql = "SELECT * FROM jandj_jandj.specPromo WHERE specPromo != '".$_SESSION['specPromo']."'";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)){
echo '<option value="'.$row['specPromo'].'">'.$row['specPromo'].'</option>';
}

} else { 

echo '<option value="" "selected">Choose Promotion</option>';
$sql = "SELECT * FROM jandj_jandj.specPromo";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)){
echo '<option value="'.$row['specPromo'].'">'.$row['specPromo'].'</option>';
}

}
?>  
</select> <font color="#FF0000"><b> *</b></font>

</td>
</tr>

<tr>
<td><span class="formcontent">Shipping Delay:</span></td>
<td>

<?php

if (isset ($_SESSION['shippingDelay'])) {
echo '<input name="shippingDelay" type="text" id="shippingDelay" value="'.$_SESSION['shippingDelay'].'">';

} else {
echo '<input name="shippingDelay" type="text" id="shippingDelay" value="" size="4" maxlength="4">';

}echo '<font color="#FF0000"><b> *</b></font>';
?> 

 

Finally this is the 'xmlparser_rc2.php' include which I think is messing with my session variables -

 

<?php
// echo "<p>Start parsing the XML</p>";



if(!($xmlparser = xml_parser_create()))
{
die("Cannot create parser");
}

function start_tag($parser, $name, $attribs) {
// echo "Current tag: ".$name."<br />";
global $current;
$current = $name;

}

function end_tag($parser,$name) {
// echo "Reached ending tag ".$name."<br /><br />";
}

function tag_contents($parser, $data) {
global $current;
global $title;
global $author;
global $publisher;
global $commentary;
// echo "<p>current = ".$current."</p>";
if ($current == "TITLE") {$title = $data; }	
if ($current == "AUTHORSTEXT") {$author = $data; }	
if ($current == "PUBLISHERTEXT") {$publisher = $data; }	
if ($current == "SUMMARY") {$commentary = $data; }	
}

function LoadJPEG ($imgURL) {

   ##-- Get Image file from Port 80 --##
   $fp = fopen($imgURL, "are");
   $imageFile = fread ($fp, 3000000);
   fclose($fp);

   ##-- Create a temporary file on disk --##
  // $tmpfname = tempnam ("/home/jandj/", "IMG");

   ##-- Put image data into the temp file --##
  // $fp = fopen($tmpfname, "w");
$fp = fopen("my.jpg", "w");
   fwrite($fp, $imageFile);
   fclose($fp);

   ##-- Load Image from Disk with GD library --##
   $im = imagecreatefromjpeg ($tmpfname);
// $im = imagecreatefromjpeg ($imageFile);

   ##-- Delete Temporary File --##
  // unlink($tmpfname);

   ##-- Check for errors --##
   if (!$im) {
       print "Could not create JPEG image $imgURL";
   }

   //return $im;
 return $imageFile;
}




xml_set_element_handler($xmlparser, "start_tag", "end_tag");
xml_set_character_data_handler($xmlparser, "tag_contents");

$filename = "http://isbndb.com/api/books.xml?access_key=58W2HDAC&results=texts&index1=isbn&value1=".$isbn;
if (!($fp = fopen($filename, "are"))) {die("cannot open ".$filename);}

while ($data = fread($fp, 4096)) {
$data = eregi_replace(">"."[[:space:]]+"."<","><",$data);
if (!xml_parse($xmlparser, $data, feof($fp))) {
	$reason = xml_error_string(xml_get_error_code($xmlparser));
	$reason .= xml_get_current_line_number($xmlparser);
	die($reason);
}
}
xml_parser_free($xmlparser);


// $imageData = LoadJPEG("http://images-eu.amazon.com/images/P/0552149438.00.LZZZZZZZ.jpg");

// Header( "Content-Type: image/jpeg");

// imagejpeg($imageData, '', 100);


echo '<img src="http://images-eu.amazon.com/images/P/'.$isbn.'.02.LZZZZZZZ.jpg" width="158" height="250">';
?>

 

Any and ALL help would be appreciated!!!!  I have spent days and weeks on this and I can't seem to figure out the problem...

 

Thanks in advance folks,

 

 

M

Thanks for the quick responses,

 

All pages have: <?php session_start(); ?> at the top of the pages (no spaces either)

 

Except the xmlparser_rc2.php script does not have the <?php session_start(); ?>.  Could this be the problem?

 

Any other ideas?

 

 

M

Hi all,

 

Another thing, it seems to me that the only difference between the two pages 'addbook.php' and 'addbook_lookup.php' is the use of the 'xmlparser_rc2.php' script.

 

Can anyone determine if somehow the 'xmlparser_rc2.php' script is overwriting the session variables:

 

$_SESSION['distributor']

$_SESSION['theme']

$_SESSION['gradeLevel']

$_SESSION['newUsed']

$_SESSION['specPromo']

 

I simply don't see why I am unable to extract the values in the session variables 'if they are there' and display them.  And, if they are not there, why???

 

Thanks for any and all help guys...

 

M

Hi everyone,

 

I'm still struggling with this problem.  :-\

 

The session variables are available to me in the addbook.php page but not the addbook_lookup.php page.  I don't understand why.  The difference between the two pages is that addbook_lookup.php has an include 'xmlparser_rc2.php' which retrieves book data from an outside page.  This information is then returned to addbook_lookup.php and when it does my session variables are empty???

 

Please, any ideas???

 

 

M

what you do... is

print_r($_SESSION);

include();

print_r($_SESSION);

 

if it does empty... you know its something in that file, go in there, start at the bottom and print_r($_SESSION); if its empty, move it a line up, till you find where its unseting...

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.