I'm trying to make a item shop for my rpg I have a table called itemslist with 3 columns itemname, itemprice, image,
So at the moment i have 1 entry in there itemname is Potion itemprice is 1000 and image is hey just to test with.
The image column I'm having problems with. For some reason it is echoing out has 1 and not hey. Even tho in phpmyadmin its hey. All columns are var except for the price.
The problem is if I change the price to 99 it will echo out he image has 9 if i change itemprice to 10 it will echo out the column image has 0. Even tho in the db the column image is hey and the price is 10 it will echo out he price has 10 and the image has 0 on the page for some reason its getting the last number of the price and thinking that is the image column
include_once('config.php');
$item = $_POST['item'];
$item = mysql_real_escape_string($_POST['item']);
$item2 = preg_replace('/[^a-z]/i', null, $item);
/// Get the item price
$sql55 = "SELECT * FROM itemslist WHERE itemname='$item2'";
$result55 = mysql_query($sql55) or die(mysql_error());
$itemprice = mysql_fetch_array($result55);
$sql555 = "SELECT * FROM users WHERE username='".$_SESSION['username']." '";
$result555 = mysql_query($sql555) or die(mysql_error());
$usermoney = mysql_fetch_array($result555);
$itemname = $itemprice['itemname'] ;
$itemprice = $itemprice['itemprice'] ;
$itemimage = $itemprice['image'] ;
echo $itemimage ;
if ($usermoney['money'] > $itemprice['itemprice']) {
echo "You have just bought a ";
echo $itemname ;
mysql_query("INSERT INTO `items` (`item`, `belongsto`, `itemimage`) VALUES ('$itemname','".$_SESSION['username']."','$itemimage')") or die(mysql_error());
$result23123 = mysql_query("UPDATE users SET money=money-$itemprice WHERE username = '{$_SESSION['username']}'")
or die(mysql_error());
}else{
echo"Your to poor to buy this item";
die;
}
In side config.php I have the session start and mysql connect.
Table structure
itemslist
table
itemname, itemprice, image
Then for items table its item ,belongsto,itemimage
from itemslist and the name of it and insert it into then items table. But the problem is if the itemprice has a number in it lets say 12 then i echo out the column next to it which is image and image will show the number 2 ( the 2 from the end of the itemprice)
There are no errors showing on page. But has i have said its echoign out that the image is 2 when in the db its hey. The column for the image is var so do not know why its echoing out has 2