Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Images

Image Display problem - Binary characters

images php coding issues or problems here.

Moderators: macek, egami, gesf

Image Display problem - Binary characters

Postby orchidcho18 » Fri Nov 30, 2012 6:20 am

Hello ...
I am new here and i'm having a problem with displaying image stored in the database. The image is showing in binary character. I dont know how to fix it.
Can anyone help please..

here is the code

<?php

session_start();

$page = 'b_index.php';
//mysql_connect("opinejewellerycom.fatcowmysql.com" , "opinejewellery" , "tRYAGAIN18!") or die(mysql_error());
mysql_connect("localhost" , "root" , "4321") or die(mysql_error());
mysql_select_db('cart') or die(mysql_error());
//echo "Done!";

if (isset($_GET['add'])){
//echo "bla";
$quantity = mysql_query('SELECT id, quantity FROM products WHERE id='.mysql_real_escape_string((int)$_GET['add']));
while ($quantity_row = mysql_fetch_assoc($quantity)){
if($quantity_row['quantity']!=$_SESSION['cart_'.(int)$_GET['add']]){
$_SESSION['cart_'.(int)$_GET['add']]+='1';
}
}
header ('Location: '.$page);

}

if (isset($_GET['remove'])){
$_SESSION['cart_'.(int)$_GET['remove']]--;
header ('Location: '.$page);
}

if (isset($_GET['delete'])){
$_SESSION['cart_'.(int)$_GET['delete']]='0';
header ('Location: '.$page);
}



function products() {
//$get = mysql_query('SELECT id, name, description, price FROM products WHERE quantity > 0 ORDER BY id');
$get = mysql_query("SELECT id, name, description, price, image,imagetype FROM products where quantity > 0 ORDER BY id, id='$id'");
if(mysql_num_rows($get)==0) {
echo "there is no products to display";
}
else {
while ($get_row = mysql_fetch_assoc($get)) {
header('Content-type:'.$get_row['imagetype']);
echo $get_row['image'];
echo '<p>'.$get_row['name'].'<br />'.$get_row['description'].'<br />&pound;'.number_format($get_row['price'], 2).' <a href="b_cart.php?add='.$get_row['id'].'">Add </a></p>'.'<br />';

}
}
}



function paypal_items(){
$num = 0;
foreach($_SESSION as $name => $value){
if ($value!=0){
if (substr($name, 0, 5)=='cart_'){
$id = substr($name, 5, (strlen($name)-5));
$get = mysql_query('SELECT id, name, price FROM products WHERE id='.mysql_real_escape_string((int)$id));
while ($get_row = mysql_fetch_assoc($get)){
$num++;
echo '<input type="hidden" name="item_number_'.$num.'" value="'.$id.'">';
echo '<input type="hidden" name="item_name_'.$num.'" value="'.$get_row['name'].'">';
echo '<input type="hidden" name="amount_'.$num.'" value="'.$get_row['price'].'">';
echo '<input type="hidden" name="shipping_'.$num.'" value="'.$get_row['shipping'].'">';
echo '<input type="hidden" name="shipping2_'.$num.'" value="'.$get_row['shipping'].'">';
echo '<input type="hidden" name="quantity_'.$num.'" value="'.$value.'">';


}
}

}
}
}

function cart(){
foreach($_SESSION as $name => $value){
if ($value>0){
if (substr($name, 0, 5)=='cart_'){
$id = substr($name, 5, (strlen($name)-5));
$get = mysql_query('SELECT id, name, price FROM products WHERE id='.mysql_real_escape_string((int)$id));
while ($get_row = mysql_fetch_assoc($get)){
$sub = $get_row['price']*$value;
echo $get_row['name'].' x '.$value.' @ &pound;'.number_format($get_row['price'], 2).' = &pound;'.number_format($sub, 2).'<a href="b_cart.php?remove='.$id.'">[-]</a> <a href="b_cart.php?add='.$id.'">[+]</a> <a href="b_cart.php?delete='.$id.'">[Delete]</a> <br />';

}

}
//$total = '';
$total += $sub;

}

}
if ($total == 0){
echo "Your Cart is empty";
}
else {
echo '<p>Total: &pound;'.number_format($total, 2).'</p>';

?>
<p>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="theedenaccessories1@gmail.com">
<?php paypal_items(); ?>
<input type="hidden" name="currency_code" value="GBP">
<input type="hidden" name="amount" value="<?php echo $total; ?>">
<input type="image" src="http://www.paypal.com/en_US/i/btn/x-click-but01.gif" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>
</p>
<?php

}

}

?>

---------------
these are my database fields in the table called 'products' .
id name description price shipping quantity image imagetype
orchidcho18
New php-forum User
New php-forum User
 
Posts: 1
Joined: Fri Nov 30, 2012 5:48 am

Return to PHP coding => Images

Who is online

Users browsing this forum: No registered users and 0 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.