Hi all,

I am trying to pass values to the cart. When I select add to cart the values show up in the url but does not direct the user to the shopping cart.

url output.
http://214.146.126.103/streetwise/result.php?itemname=CITROEN&returnurl=http%3A%2F%2F214.146.126.103%2Fpassenger.php&price=123.00&storeid=xxxxx&quantity=1[/url]

//passing variables from db
$m_id=$row{products_make};
	//echo $m_id;// test out put valid

	$p_id=$row{products_price};
	//echo $p_id;//test output valid
	
	
    
// Start of form processing of data to cart

echo "<form action=http://www.romancart.com/cart.asp method=post>\n";
echo"<input type=\"hidden\" name=\"itemname\" value=\"$m_id\">";
echo'<input type= hidden name=returnurl value="http://217.146.126.103/passenger.php">';
echo"<input type=\"hidden\" name=\"price\" value=\"$p_id\">";
echo"<input type=\"hidden\" name=\"storeid\" value=\"45983\">";
echo '&nbsp; &nbsp; &nbsp; Quantity:&nbsp; ';
echo '<select name="quantity">';
echo '<br>';
echo'<option>1';
echo'<option>2';
echo'<option>3';
echo'<option>4';
echo'<br>';
echo'<input type=submit value="Add to Basket">';
echo"</form>";

hope some can assist

thanks

David

First of all: use code tags?

I dont quite understand the problem, i dont know alot of asp (your form-handler is a .asp file) or something but you want to pass down information through a form to a form-handlers i assume.

First of all, there is NO url-output if you use the POST-method, only the GET-method passes information through the url.

You should also make the following line:

echo "<form action=http://www.romancart.com/cart.asp method=post>\n";

into

echo "<form action=\"http://www.romancart.com/cart.asp\" method=\"post\">\n";

And also change

echo'<input type= hidden name=returnurl value="http://217.146.126.103/passenger.php">';

into

echo "<input type=\"hidden\" name=\"returnurl\" value=\"http://217.146.126.103/passenger.php\">";

Hope this helps,

~Graphix

Hi Graphix,

Thanks for your feed back

I have amended the form action script to your specification.

The comment about "that you should have no output in the url if using post". That is how I understand the post function. but
When I select the add to basket button that is what the url displays for what ever reason instead of being forwarded to the cart.

echo "<form action=\"http://www.romancart.com/cart.asp\" method=\"post\">\n";
echo"<input type=\"hidden\" name=\"itemname\" value=\"$m_id\">";
//echo'<input type= \"hidden\" name=\"returnurl\" value=\"http://214.146.126.103/passenger.php\">';
echo"<input type=\"hidden\" name=\"price\" value=\"$p_id\">";
echo"<input type=\"hidden\" name=\"storeid\" value=\"xxxxxx\">";
echo '&nbsp; &nbsp; &nbsp; Quantity:&nbsp; ';
echo '<select name="quantity">';
echo '<br>';
echo'<option>1';
echo'<option>2';
echo'<option>3';
echo'<option>4';
echo'<br>';
echo "<input type=\"submit\" value=\"Add to Basket\">\n";
echo"</form>";

Thanks again I value your contribution

David

I think i found error:

echo '<br /><select name="quantity">';
echo'<option>1</option>';
echo'<option>2</option>';
echo'<option>3</option>';
echo'<option>4</option>';
echo'[B][I]</select>[/I][/B]<br />';

Hi Graphix, Thanks for pointing out the stupid close tag error. But the same problem exists.

I am not sure why I am getting the following output in the url.

What is clearly they are the values being past via the form, but don't seem to find the cart url address?

http://217.146.126.103/Streetwise/result.php?itemname=CITROEN&returnurl=http%3A%2F%2F217.146.126.103%2Fpassenger.php&price=123.00&storeid=45983&quantity=1

Thanks

David

Hi all,

I am trying a different approach by closing the PHP tags to use html to send data to the cart.

Using this method connects to the cart but the values are not passed

Any further help would be appriciated

Thanks in advance

David

//Passing values from form
	$m_id=$row{products_make};
	$p_id=$row{products_price};


?>
	<form action=http://www.romancart.com/cart.asp method=post>
  <p>
  <input type=hidden name=itemname value='<?=$m_id?>'>
  <input type=hidden name=returnurl value="http://217.146.126.103/Streetwise/pages/passenger.php">
  <input type=hidden name=price value='<?=$p_id?>'> 
  <input type=hidden name=storeid value=45983> 
  Quantity:&nbsp;
  <select name=quantity>
    <option>1</option>
      <option>2</option>
        <option>3</option>
          <option>4</option>
          </select>
  <br><br/>
  <input type=submit value='Add to Basket'>
  </p>
  <p>&nbsp; </p>

</form>
	<?php

echo "<form action=http://www.romancart.com/cart.asp method=post>\n";
echo"<input type=\"hidden\" name=\"itemname\" value=\"$m_id\">";
echo'<input type= hidden name=returnurl value="http://217.146.126.103/passenger.php">';
echo"<input type=\"hidden\" name=\"price\" value=\"$p_id\">";
echo"<input type=\"hidden\" name=\"storeid\" value=\"45983\">";

The above quote should turn into the below code:

echo '<form action="http://www.romancart.com/cart.asp" method="post">'."\n";
echo '<input type="hidden" name="itemname" value="'.$m_id.'">';
echo '<input type="hidden" name="returnurl" value="http://217.146.126.103/passenger.php">';
echo '<input type="hidden" name="price" value="'.$p_id.'">';
echo '<input type="hidden" name="storeid" value="45983">';

Hi Thanks for the reply

Both methods used produced the same result

When the add to cart button is selected I get the following results in the url

http://217.146.126.103/Streetwise/result.php?itemname=CITROEN&returnurl=http%3A%2F%2F217.146.126.103%2Fpassenger.php&price=123.00&storeid=45983&quantity=1

The correct values are being passed from the form but will not connect to the cart url
I will include all the code for this page it may help

<?php
//passed values from form
$category_id=$_POST['category_id'];
$make=$_POST['make'];

//Sanitize input values
$category_id=mysql_real_escape_string(stripslashes($_POST['category_id']));
$make=mysql_real_escape_string(stripslashes($_POST['make']));

//$result = mysql_query("SELECT * FROM products WHERE products_make ='$make'") or die(mysql_error());
//or
//$resultb = mysql_query("SELECT * FROM products WHERE products_make ='$make' AND products_category_id ='$category_id'") or die(mysql_error());
require('includes/header.php');// Include header

//setting user host and password values
$username = "**********";
$password = "******";
$hostname = "localhost"; 

//connection to the database
$dbhandle = mysql_connect($hostname, $username, $password)
 or die("Unable to connect to MySQL");
//echo "Connected to MySQL<br>";

//select a database to work with
$selected = mysql_select_db("Streetwise",$dbhandle)
  or die("Could not select Streetwise");

//execute the SQL query and return records
$result = mysql_query("SELECT * FROM products WHERE products_make ='$make'") or die(mysql_error());

//fetch tha data from the database

while ($row = mysql_fetch_array($result)) {
   
	require('includes/body.php');
	
	require('includes/vehicle_panel.php');
	// display the database output query
	echo '<div class="font">'.'<h3>'.$row{'products_type'}." ".$row{'products_make'}." ".$row{'products_model'}." ".$row{'products_year'}.'</h3>'.'</div>';
	echo "<h3>";
	//echo'<br>';
	echo '<div class="price" align="right">'.'<img src="images/odyssey/'.$row{'products_Image'}.'" alt="Car batteries" height="75" width="75" border="0" align="center">'."&nbsp; &nbsp; &nbsp; ".'</div>'."Price &pound;".$row{'products_price'}."&nbsp; &nbsp";
	echo "<br>";
	echo '<p>';
	echo '<br>';
	echo "<br>";
	echo "</h3>";
	echo '<form>';
	echo '<fieldset>';
	echo '<legend>Fitting Details </legend>';
	echo '<br>';
	echo '<div class="image" text-align="right">'.'<img src="images/'.$row{'products_other1'}.'" alt="Car batteries" height="90" width="100" border="0" align="right">'."</div>";
	echo '<br>';
	echo '<ul>';
	echo '<table>';
	echo '<tr>';
	echo '<td width="130">'.'<li>'."Weight".'</td>'.'<td width="100">'.$row{'products_weight'}."&nbsp;kg".'</li>'.'</td>';
	echo '</tr>';
	echo '<tr>';
	echo '<td width="130">'.'<li>'."Length".'</td>'.'<td width="100">'.$row{'products_length'}."mm".'</li>'.'</td>';
	echo '</tr>';
	echo '<tr>';
	echo '<td width="150">'.'<li>'."Width".'</td>'.'<td width="100">'.$row{'products_width'}."mm".'</li>'.'</td>';
	echo '</tr>';
	echo '<tr>';
	echo '<td width="150">'.'<li>'."Height".'</td>'.'<td width="100">'.$row{'products_height'}."mm".'</li>'.'</td>';
	echo '</tr>';
	echo '<tr>';
	echo '<td width="150">'.'<li>'."ah@20 hr rate".'</td>'.'<td width="100">'.$row{'products_ah_20hr'}."&nbsp;AMPS".'</li>'.'</td>';
	echo "</tr>";
	echo '<tr>';
	echo '<td width="150">'.'<li>'."S.A.E Cold Start".'</td>'.'<td width="100">'.$row{'products_sae_cold_start'}."&nbsp;AMPS ".'</li>'.'</td>';
	echo "</tr>";
	echo '<tr>';
	echo '<td width="150">'.'<li>'."Bench Amps".'</td>'.'<td width="100">'.$row{'products_bench_amps'}."&nbsp;AMPS".'</li>'.'</td>';
	echo "</tr>";
	echo '<tr>';
	echo '<td width="150">'.'<li>'."Base Hold Down".'</td>'.'<td width="100">'.$row{'products_base_holddown'}."".'</li>'.'</td>';
	echo "</tr>";
	echo '<tr>';
	echo '<td width="150">'.'<li>'."Layout".'</td>'.'<td width="100">'.$row{'products_layout'}."".'</li>'.'</td>';
	echo "</tr>";
	echo '<tr>';
	echo '<td width="150">'.'<li>'."Notes".'</td>'.'<td width="100">'.$row{'products_notes'}."&nbsp;".'<a href="notes.html">See&nbsp;Notes</a>'.'</li>'.'</td>';
	echo "</tr>";
	echo '</ul>';
	echo "</table>";
	echo'<br>';
	//Passing values to form
	$m_id=$row{products_make};
	$p_id=$row{products_price};
	echo $m_id;
	echo $p_id;
	
	//echo '<form action="http://www.romancart.com/cart.asp" method="post">'."\n";
	//echo '<input type="hidden" name="itemname" value="'.$m_id.'">';
	//echo '<input type="hidden" name="returnurl" value="http://217.146.126.103/passenger.php">';
	//echo '<input type="hidden" name="price" value="'.$p_id.'">';
	//echo '<input type="hidden" name="storeid" value="45983">';
	
		echo "<form action=\"http://www.romancart.com/cart.asp\" method=\"post\">\n";
			echo"<input type=\"hidden\" name=\"itemname\" value=\".$m_id.\">";
			echo"<input type= \"hidden\" name=\"returnurl\" value=\"http://217.146.126.103/passenger.php\">";
			echo"<input type=\"hidden\" name=\"price\" value=\".$p_id.\">";
			echo"<input type=\"hidden\" name=\"storeid\" value=\"45983\">";
			echo '&nbsp; &nbsp; &nbsp; Quantity:&nbsp; ';
			echo '<select name="quantity">';
	  		echo '<br/>';
	  		echo'<option>1</option>';
	  		echo'<option>2</option>';
	  		echo'<option>3</option>';
	  		echo'<option>4</option>';
	  		echo'<br/>';
			echo'</select>';
			echo "<input type=\"submit\" value=\"Add to Basket\">\n";
			echo"</form>";
			echo'</fieldset>';
	
	require('includes/vehicle_panel_exit.php');
	
   require('includes/lobody.php');
   
}
//close the connection
mysql_close($dbhandle);


?>
  <?php
  require('includes/footer.php');
  ?>

The above quote should turn into the below code:

echo '<form action="http://www.romancart.com/cart.asp" method="post">'."\n";
echo '<input type="hidden" name="itemname" value="'.$m_id.'">';
echo '<input type="hidden" name="returnurl" value="http://217.146.126.103/passenger.php">';
echo '<input type="hidden" name="price" value="'.$p_id.'">';
echo '<input type="hidden" name="storeid" value="45983">';

Wow, big bugs. Try the following:

<?php
//passed values from form
$category_id=$_POST['category_id'];
$make=$_POST['make'];

//Sanitize input values
$category_id=mysql_real_escape_string(stripslashes($_POST['category_id']));
$make=mysql_real_escape_string(stripslashes($_POST['make']));

//$result = mysql_query("SELECT * FROM products WHERE products_make ='$make'") or die(mysql_error());
//or
//$resultb = mysql_query("SELECT * FROM products WHERE products_make ='$make' AND products_category_id ='$category_id'") or die(mysql_error());
require('includes/header.php');// Include header

//setting user host and password values
$username = "**********";
$password = "******";
$hostname = "localhost"; 

//connection to the database
$dbhandle = mysql_connect($hostname, $username, $password)
 or die("Unable to connect to MySQL");
//echo "Connected to MySQL<br>";

//select a database to work with
$selected = mysql_select_db("Streetwise",$dbhandle)
  or die("Could not select Streetwise");

//execute the SQL query and return records
$result = mysql_query("SELECT * FROM products WHERE products_make ='$make'") or die(mysql_error());

//fetch tha data from the database

while ($row = mysql_fetch_assoc($result)) {
   
	require('includes/body.php');
	
	require('includes/vehicle_panel.php');
	// display the database output query
	echo '<div class="font">'.'<h3>'.$row['products_type']." ".$row['products_make']." ".$row['products_model']." ".$row['products_year'].'</h3>'.'</div>';
	echo "<h3>";
	//echo'<br>';
	echo '<div class="price" align="right">'.'<img src="images/odyssey/'.$row['products_Image'].'" alt="Car batteries" height="75" width="75" border="0" align="center">'."&nbsp; &nbsp; &nbsp; ".'</div>'."Price &pound;".$row['products_price']."&nbsp; &nbsp";
	echo "<br>";
	echo '<p>';
	echo '<br>';
	echo "<br>";
	echo "</h3>";
	echo '<form>';
	echo '<fieldset>';
	echo '<legend>Fitting Details </legend>';
	echo '<br>';
	echo '<div class="image" text-align="right">'.'<img src="images/'.$row['products_other1'].'" alt="Car batteries" height="90" width="100" border="0" align="right">'."</div>";
	echo '<br>';
	echo '<ul>';
	echo '<table>';
	echo '<tr>';
	echo '<td width="130">'.'<li>'."Weight".'</td>'.'<td width="100">'.$row['products_weight']."&nbsp;kg".'</li>'.'</td>';
	echo '</tr>';
	echo '<tr>';
	echo '<td width="130">'.'<li>'."Length".'</td>'.'<td width="100">'.$row['products_length']."mm".'</li>'.'</td>';
	echo '</tr>';
	echo '<tr>';
	echo '<td width="150">'.'<li>'."Width".'</td>'.'<td width="100">'.$row['products_width']."mm".'</li>'.'</td>';
	echo '</tr>';
	echo '<tr>';
	echo '<td width="150">'.'<li>'."Height".'</td>'.'<td width="100">'.$row['products_height']."mm".'</li>'.'</td>';
	echo '</tr>';
	echo '<tr>';
	echo '<td width="150">'.'<li>'."ah@20 hr rate".'</td>'.'<td width="100">'.$row['products_ah_20hr']."&nbsp;AMPS".'</li>'.'</td>';
	echo "</tr>";
	echo '<tr>';
	echo '<td width="150">'.'<li>'."S.A.E Cold Start".'</td>'.'<td width="100">'.$row['products_sae_cold_start']."&nbsp;AMPS ".'</li>'.'</td>';
	echo "</tr>";
	echo '<tr>';
	echo '<td width="150">'.'<li>'."Bench Amps".'</td>'.'<td width="100">'.$row['products_bench_amps']."&nbsp;AMPS".'</li>'.'</td>';
	echo "</tr>";
	echo '<tr>';
	echo '<td width="150">'.'<li>'."Base Hold Down".'</td>'.'<td width="100">'.$row['products_base_holddown']."".'</li>'.'</td>';
	echo "</tr>";
	echo '<tr>';
	echo '<td width="150">'.'<li>'."Layout".'</td>'.'<td width="100">'.$row['products_layout']."".'</li>'.'</td>';
	echo "</tr>";
	echo '<tr>';
	echo '<td width="150">'.'<li>'."Notes".'</td>'.'<td width="100">'.$row['products_notes']."&nbsp;".'<a href="notes.html">See&nbsp;Notes</a>'.'</li>'.'</td>';
	echo "</tr>";
	echo '</ul>';
	echo "</table>";
	echo'<br>';
	//Passing values to form
	$m_id=$row['products_make'];
	$p_id=$row['products_price'];
	echo $m_id;
	echo $p_id;
	
	//echo '<form action="http://www.romancart.com/cart.asp" method="post">'."\n";
	//echo '<input type="hidden" name="itemname" value="'.$m_id.'">';
	//echo '<input type="hidden" name="returnurl" value="http://217.146.126.103/passenger.php">';
	//echo '<input type="hidden" name="price" value="'.$p_id.'">';
	//echo '<input type="hidden" name="storeid" value="45983">';
	
		echo "<form action=\"http://www.romancart.com/cart.asp\" method=\"post\">\n";
			echo"<input type=\"hidden\" name=\"itemname\" value=\".$m_id.\">";
			echo"<input type= \"hidden\" name=\"returnurl\" value=\"http://217.146.126.103/passenger.php\">";
			echo"<input type=\"hidden\" name=\"price\" value=\".$p_id.\">";
			echo"<input type=\"hidden\" name=\"storeid\" value=\"45983\">";
			echo '&nbsp; &nbsp; &nbsp; Quantity:&nbsp; ';
			echo '<select name="quantity">';
	  		echo '<br/>';
	  		echo'<option>1</option>';
	  		echo'<option>2</option>';
	  		echo'<option>3</option>';
	  		echo'<option>4</option>';
	  		echo'<br/>';
			echo'</select>';
			echo "<input type=\"submit\" value=\"Add to Basket\">\n";
			echo"</form>";
			echo'</fieldset>';
	
	require('includes/vehicle_panel_exit.php');
	
   require('includes/lobody.php');
   
}
//close the connection
mysql_close($dbhandle);


?>
  <?php
  require('includes/footer.php');
  ?>

Also study my version of the code to learn how to use the arrays retrieved from the database.

Hi again,

I have tested the below script with the same output result

It may help if you look at the test site
http://217.146.126.103/Streetwise/result.php
and select the add to basket button (this may help

Cheers

David


Wow, big bugs. Try the following:

<?php
//passed values from form
$category_id=$_POST['category_id'];
$make=$_POST['make'];

//Sanitize input values
$category_id=mysql_real_escape_string(stripslashes($_POST['category_id']));
$make=mysql_real_escape_string(stripslashes($_POST['make']));

//$result = mysql_query("SELECT * FROM products WHERE products_make ='$make'") or die(mysql_error());
//or
//$resultb = mysql_query("SELECT * FROM products WHERE products_make ='$make' AND products_category_id ='$category_id'") or die(mysql_error());
require('includes/header.php');// Include header

//setting user host and password values
$username = "**********";
$password = "******";
$hostname = "localhost"; 

//connection to the database
$dbhandle = mysql_connect($hostname, $username, $password)
 or die("Unable to connect to MySQL");
//echo "Connected to MySQL<br>";

//select a database to work with
$selected = mysql_select_db("Streetwise",$dbhandle)
  or die("Could not select Streetwise");

//execute the SQL query and return records
$result = mysql_query("SELECT * FROM products WHERE products_make ='$make'") or die(mysql_error());

//fetch tha data from the database

while ($row = mysql_fetch_assoc($result)) {
   
	require('includes/body.php');
	
	require('includes/vehicle_panel.php');
	// display the database output query
	echo '<div class="font">'.'<h3>'.$row['products_type']." ".$row['products_make']." ".$row['products_model']." ".$row['products_year'].'</h3>'.'</div>';
	echo "<h3>";
	//echo'<br>';
	echo '<div class="price" align="right">'.'<img src="images/odyssey/'.$row['products_Image'].'" alt="Car batteries" height="75" width="75" border="0" align="center">'."&nbsp; &nbsp; &nbsp; ".'</div>'."Price &pound;".$row['products_price']."&nbsp; &nbsp";
	echo "<br>";
	echo '<p>';
	echo '<br>';
	echo "<br>";
	echo "</h3>";
	echo '<form>';
	echo '<fieldset>';
	echo '<legend>Fitting Details </legend>';
	echo '<br>';
	echo '<div class="image" text-align="right">'.'<img src="images/'.$row['products_other1'].'" alt="Car batteries" height="90" width="100" border="0" align="right">'."</div>";
	echo '<br>';
	echo '<ul>';
	echo '<table>';
	echo '<tr>';
	echo '<td width="130">'.'<li>'."Weight".'</td>'.'<td width="100">'.$row['products_weight']."&nbsp;kg".'</li>'.'</td>';
	echo '</tr>';
	echo '<tr>';
	echo '<td width="130">'.'<li>'."Length".'</td>'.'<td width="100">'.$row['products_length']."mm".'</li>'.'</td>';
	echo '</tr>';
	echo '<tr>';
	echo '<td width="150">'.'<li>'."Width".'</td>'.'<td width="100">'.$row['products_width']."mm".'</li>'.'</td>';
	echo '</tr>';
	echo '<tr>';
	echo '<td width="150">'.'<li>'."Height".'</td>'.'<td width="100">'.$row['products_height']."mm".'</li>'.'</td>';
	echo '</tr>';
	echo '<tr>';
	echo '<td width="150">'.'<li>'."ah@20 hr rate".'</td>'.'<td width="100">'.$row['products_ah_20hr']."&nbsp;AMPS".'</li>'.'</td>';
	echo "</tr>";
	echo '<tr>';
	echo '<td width="150">'.'<li>'."S.A.E Cold Start".'</td>'.'<td width="100">'.$row['products_sae_cold_start']."&nbsp;AMPS ".'</li>'.'</td>';
	echo "</tr>";
	echo '<tr>';
	echo '<td width="150">'.'<li>'."Bench Amps".'</td>'.'<td width="100">'.$row['products_bench_amps']."&nbsp;AMPS".'</li>'.'</td>';
	echo "</tr>";
	echo '<tr>';
	echo '<td width="150">'.'<li>'."Base Hold Down".'</td>'.'<td width="100">'.$row['products_base_holddown']."".'</li>'.'</td>';
	echo "</tr>";
	echo '<tr>';
	echo '<td width="150">'.'<li>'."Layout".'</td>'.'<td width="100">'.$row['products_layout']."".'</li>'.'</td>';
	echo "</tr>";
	echo '<tr>';
	echo '<td width="150">'.'<li>'."Notes".'</td>'.'<td width="100">'.$row['products_notes']."&nbsp;".'<a href="notes.html">See&nbsp;Notes</a>'.'</li>'.'</td>';
	echo "</tr>";
	echo '</ul>';
	echo "</table>";
	echo'<br>';
	//Passing values to form
	$m_id=$row['products_make'];
	$p_id=$row['products_price'];
	echo $m_id;
	echo $p_id;
	
	//echo '<form action="http://www.romancart.com/cart.asp" method="post">'."\n";
	//echo '<input type="hidden" name="itemname" value="'.$m_id.'">';
	//echo '<input type="hidden" name="returnurl" value="http://217.146.126.103/passenger.php">';
	//echo '<input type="hidden" name="price" value="'.$p_id.'">';
	//echo '<input type="hidden" name="storeid" value="45983">';
	
		echo "<form action=\"http://www.romancart.com/cart.asp\" method=\"post\">\n";
			echo"<input type=\"hidden\" name=\"itemname\" value=\".$m_id.\">";
			echo"<input type= \"hidden\" name=\"returnurl\" value=\"http://217.146.126.103/passenger.php\">";
			echo"<input type=\"hidden\" name=\"price\" value=\".$p_id.\">";
			echo"<input type=\"hidden\" name=\"storeid\" value=\"45983\">";
			echo '&nbsp; &nbsp; &nbsp; Quantity:&nbsp; ';
			echo '<select name="quantity">';
	  		echo '<br/>';
	  		echo'<option>1</option>';
	  		echo'<option>2</option>';
	  		echo'<option>3</option>';
	  		echo'<option>4</option>';
	  		echo'<br/>';
			echo'</select>';
			echo "<input type=\"submit\" value=\"Add to Basket\">\n";
			echo"</form>";
			echo'</fieldset>';
	
	require('includes/vehicle_panel_exit.php');
	
   require('includes/lobody.php');
   
}
//close the connection
mysql_close($dbhandle);


?>
  <?php
  require('includes/footer.php');
  ?>

Also study my version of the code to learn how to use the arrays retrieved from the database.

Do all your columns begin with products_ or is that your table name because you don't use your table name in the $row array.

Hi

The table name is called products

each field in the table will start with i.e products_id, products_make, products_price etc

Hope this helps

David

Do all your columns begin with products_ or is that your table name because you don't use your table name in the $row array.

Try just before the while loop each of the following codes but will need to be done separatley:

die(mysql_num_rows($result));
$ddd=mysql_fetch_assoc($result);
echo '<xmp>';
print_r($ddd);
echo '</xmp>';

And let me know of the results of when each of those code are on line 33.

line 33 :die(mysql_num_rows($result));

No output from DB all HTML ok

Line 33:

$ddd=mysql_fetch_assoc($result);
echo '<xmp>';
print_r($ddd);
echo '</xmp>';

Output:Array ( [products_id] =&gt; 4 [products_make] =&gt; CITROEN [products_model] =&gt; C3 [products_year] =&gt; 2004 [products_type] =&gt; 036 [products_price] =&gt; 123.00 [products_ah_20hr] =&gt; 16 [products_sae_cold_start] =&gt; 23 [products_bench_amps] =&gt; 10 [products_length] =&gt; 12 [products_width] =&gt; 100 [products_height] =&gt; 100 [products_weight] =&gt; 15.0 [products_layout] =&gt; 0 [products_terminals] =&gt; 1 [products_base_holddown] =&gt; B4 [products_notes] =&gt; 1,7 [products_ah_5hr] =&gt; [products_ah_cap] =&gt; 1 [products_pulse_amps] =&gt; [products_reserve_capacity] =&gt; [products_Image] =&gt; ODY-PC310.jpg [products_quantity] =&gt; 1 [products_last_modified] =&gt; [products_date_added] =&gt; [products_other1] =&gt; layout0.jpg [products_other2] =&gt; [products_other3] =&gt; [products_other4] =&gt; [products_output_voltage] =&gt; )  


followed by the db contents displayed as normal

cheer

David

while ($row = mysql_fetch_assoc($result)) {

Try just before the while loop each of the following codes but will need to be done separatley:

die(mysql_num_rows($result));
$ddd=mysql_fetch_assoc($result);
echo '<xmp>';
print_r($ddd);
echo '</xmp>';

And let me know of the results of when each of those code are on line 33.

The only thing I can suggest is try commenting the two require functions which are directly below the while loop as the array $row might be over-written or something.

Hi

I have just tried what you suggested and commented out the require functions and the problem still exisits.

Thanks again for sticking with me on this

Cheers

David

The only thing I can suggest is try commenting the two require functions which are directly below the while loop as the array $row might be over-written or something.

Hi again

Trying to analyse the source code, is there a big problem with it and would you have approached it differently?

Cheers

David

The only thing I can suggest is try commenting the two require functions which are directly below the while loop as the array $row might be over-written or something.

Well if the $row array (not far after the while()) wasn't displaying it's value and yet $row yields it's values on print_r, logic would say that it is the 2 includes above $row. But if this isn't the case I wouldn't have a clue and would try commenting sections at a time.

Hi i have been testing the souce code over the weekend and I have eliminated all but essential code to make the db run correctly

I have gradually removed comments from the top down. When I reach the while loop and echo the output from the result I get a blank white screen.

From what I have mentioned does anything stand out.

Thanks in advance

David

<?php
//passed values from form
$category_id=$_POST['category_id'];
$make=$_POST['make'];

//Sanitize input values
$category_id=mysql_real_escape_string(stripslashes($_POST['category_id']));
$make=mysql_real_escape_string(stripslashes($_POST['make']));

//$result = mysql_query("SELECT * FROM products WHERE products_make ='$make'") or die(mysql_error());
//or
//$resultb = mysql_query("SELECT * FROM products WHERE products_make ='$make' AND products_category_id ='$category_id'") or die(mysql_error());

require('includes/header.php');// Include header

//setting user host and password values
$username = "******";
$password = "******";
$hostname = "localhost"; 

//connection to the database
$dbhandle = mysql_connect($hostname, $username, $password)or die("Unable to connect to MySQL");
echo "Connected to MySQL<br>";

//select a database to work with
$selected = mysql_select_db("Streetwise",$dbhandle)or die("Could not select Streetwise");

// test ok up to here

//execute the SQL query and return records
$result = mysql_query("SELECT * FROM products WHERE products_make ='$make'")or die(mysql_error());


echo $result;
echo $make;


//fetch tha data from the database

while ($row = mysql_fetch_array($result)) {
   
	//require('includes/body.php');
	
//	require('includes/vehicle_panel.php');
	// display the database output query
	echo '<div class="font">'.'<h3>'.$row{'products_type'}.' '.$row{'products_make'}.' '.$row{'products_model'}.' '.$row{'products_year'}.'</h3>'.'</div>';
	

?>


<form action="http://www.romancart.com/cart.asp" method="post">
  <p>
  <input type=hidden name=itemname value='Odyssey PC1200'>
  <input type=hidden name=returnurl value="http://217.146.126.103/Streetwise/pages/odyssey.html">
  <input type=hidden name=price value=126.00> 
  <input type=hidden name=storeid value=45983> 
    Quantity:&nbsp;
  <select name=quantity>
    <option>1</option>
      <option>2</option>
        <option>3</option>
          <option>4</option>
          </select>
  <br><br/>
  <input type=submit value='Add to Basket'>
  </p>
  <p>&nbsp; </p>
</form>
 <?php
  require('includes/footer.php');
  ?>
</body>
</html>

Well if the $row array (not far after the while()) wasn't displaying it's value and yet $row yields it's values on print_r, logic would say that it is the 2 includes above $row. But if this isn't the case I wouldn't have a clue and would try commenting sections at a time.

$row{'products_type'}

WTH - You rebugged your code by not studing the code in post #9. The array formatting you used (example in above quote) should be as follows:

$row['products_type']

Notice how the brackets are different. That's one of your biggest problems but do this in addition to what you were doing before.

Hi
Thanks for the that I had copied and pasted the changes maybe into a new web page so I am not sure that how that happened.

I have uploaded a word document

and displayed in the url is my domain followed by the correct information that needs to passed to the cart.

What I have noticed is that the form action should show as follows in the url

<form action="http://www.romancart.com/cart.asp" method="post">'."\n";

but what it is showing is:

[url]http://217.146.126.103/Streetwise/result.php?itemname=.CITROEN.&returnurl=http%3A%2F%2F217.146.126.103%2Fpassenger.php&price=.123.00.&storeid=45983&quantity=1[/url]

could there be logical answer for this?

Cheers

David

Those are two separate pieces of code. The first code is the form submission location and the second code is a hyperlink. So they are completley unrelated. However in the hyperlink it appears that it is showing the ip of your server instead of the domain name.

Hi Again, so what action would cause that to happen outside of the form.

Would you have any ideas.

Thanks

David

Hi Again, so what action would cause that to happen outside of the form.

What's outside the form now?

Edit: I forgot to check the previous page. Will reply soon.

Hi Again, so what action would cause that to happen outside of the form.

I can't see that hyperlink in your code anywhere so it is probably part of your template or something because I can't see that link in your code.

Hi

The form outputcode is as below, so I am also very puzzled as well.

When you say template are you reffering my header includes etc

Cheers

David

<form action="http://www.romancart.com/cart.asp" method="post">'."\n";

I can't see that hyperlink in your code anywhere so it is probably part of your template or something because I can't see that link in your code.

When I say template I refer to all of the include() and require() files. That is your best bet.

Hi

What I have done is isolate all the includes, css Javascript and the buy link still produces the same result.

thanks

David

When I say template I refer to all of the include() and require() files. That is your best bet.

I thought I would confirm this, so your getting some unexpected hyperlink in your page which needs deleting or changing. Also by any chance does your url at any stage match the one that's output.

Hi,

I have just discovered a work around which works!!!

I am not sure if it is the best solution.

The link only seems to work if I keep

echo "<form action=\"http://www.romancart.com/cart.asp\" method=\"post\">\n";
echo"</form>";

There sure is a bug ?

Has anyone come across this before

Cheers

David

// ////////////// These form tags must remain ////////////////////////////////////////////////
			echo "<form action=\"http://www.romancart.com/cart.asp\" method=\"post\">\n";
			echo"</form>";
	// ///////////////////////////////////////////////////////////////////////////////////////////////////////////		
			echo "<form action=\"http://www.romancart.com/cart.asp\" method=\"post\">\n";
			echo"<input type=\"hidden\" name=\"itemname\" value=\"$m_id\">";
			echo"<input type= \"hidden\" name=\"returnurl\" value=\"http://217.146.126.103/Streetwise/passenger.php\">";
			echo"<input type=\"hidden\" name=\"price\" value=\"$p_id\">";
			echo"<input type=\"hidden\" name=\"storeid\" value=\"45983\">";
			echo '&nbsp; &nbsp; &nbsp; Quantity:&nbsp; ';
			echo '<select name="quantity">';
	  		echo '<br/>';
	  		echo'<option>1</option>';
	  		echo'<option>2</option>';
	  		echo'<option>3</option>';
	  		echo'<option>4</option>';
	  		echo'<br/>';
			echo'</select>';
			echo "<input type=\"submit\" value=\"Add to Basket\">\n";
			echo"</form>";
	echo'</fieldset>';

I thought I would confirm this, so your getting some unexpected hyperlink in your page which needs deleting or changing. Also by any chance does your url at any stage match the one that's output.

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.