mr_mind Posted December 4, 2007 Share Posted December 4, 2007 alright now did you check over that to make sure that all of the data being pulled and checked is correct. i have no idea what your table layout is and im working with what code you gave me Link to comment https://forums.phpfreaks.com/topic/79924-mysql-displaying-anything-over-0/page/2/#findComment-405736 Share on other sites More sharing options...
Deanznet Posted December 4, 2007 Author Share Posted December 4, 2007 Checking now but stay with me $item_exists_query = mysql_query("SELECT * FROM items WHERE item_name='$item'"); the last part where it says $item should that be $itemID since $itemID is the name? if i change it to that than it says cannot find item Link to comment https://forums.phpfreaks.com/topic/79924-mysql-displaying-anything-over-0/page/2/#findComment-405737 Share on other sites More sharing options...
mr_mind Posted December 4, 2007 Share Posted December 4, 2007 no because the code function item_exists($item) { Defines $item as whatever is passed to it and then uses the variable data passed in the function variable Link to comment https://forums.phpfreaks.com/topic/79924-mysql-displaying-anything-over-0/page/2/#findComment-405742 Share on other sites More sharing options...
Deanznet Posted December 4, 2007 Author Share Posted December 4, 2007 Alright, Now i get You do not have enough money maybe theirs a problem now with the sql? Link to comment https://forums.phpfreaks.com/topic/79924-mysql-displaying-anything-over-0/page/2/#findComment-405744 Share on other sites More sharing options...
mr_mind Posted December 4, 2007 Share Posted December 4, 2007 This is where your cash is defined. check to see if these values are correct. $user_info_query = mysql_query("SELECT * FROM phpbb_users WHERE user_id='$user_id'"); $user_info_array = mysql_fetch_array($user_info_query); $user_cash = $user_info_array['user_points']; then check to see if the price of the item is correct: $price_query = mysql_query("SELECT * FROM items WHERE item_name='$itemID'"); $price_array = mysql_fetch_array($price_query); $price = $price_array['item_price']; Edit: disregard what was previously in this post. it was incorrect Link to comment https://forums.phpfreaks.com/topic/79924-mysql-displaying-anything-over-0/page/2/#findComment-405745 Share on other sites More sharing options...
Deanznet Posted December 4, 2007 Author Share Posted December 4, 2007 Still getting You do not have enough money The money is located in the phpbb_user column in the user_points table. Link to comment https://forums.phpfreaks.com/topic/79924-mysql-displaying-anything-over-0/page/2/#findComment-405746 Share on other sites More sharing options...
mr_mind Posted December 4, 2007 Share Posted December 4, 2007 NOTE: You must set $user_id as your user_d through whichever way you show the user id of the user logged in Link to comment https://forums.phpfreaks.com/topic/79924-mysql-displaying-anything-over-0/page/2/#findComment-405747 Share on other sites More sharing options...
Deanznet Posted December 4, 2007 Author Share Posted December 4, 2007 $user_id should be the id of the user thats loged in should work fine. but it not it still says money Link to comment https://forums.phpfreaks.com/topic/79924-mysql-displaying-anything-over-0/page/2/#findComment-405749 Share on other sites More sharing options...
mr_mind Posted December 4, 2007 Share Posted December 4, 2007 $user_id should be the id of the user thats loged in should work fine. but it not it still says money what is the code which sets $user_id? Link to comment https://forums.phpfreaks.com/topic/79924-mysql-displaying-anything-over-0/page/2/#findComment-405750 Share on other sites More sharing options...
Deanznet Posted December 4, 2007 Author Share Posted December 4, 2007 Im using phpbb session so its $user_id = $userdata['user_id']; also when i do echo "$user_id"; it echos my id Items price also displays in green along with stock Link to comment https://forums.phpfreaks.com/topic/79924-mysql-displaying-anything-over-0/page/2/#findComment-405751 Share on other sites More sharing options...
mr_mind Posted December 4, 2007 Share Posted December 4, 2007 Sorry i looked at the error checking and the error for You ave no money was swapped with Item out of stock so check this info: the query is: mysql_query("SELECT * FROM items WHERE item_name='$itemID'"); and the row is: item_quantity. is this correct? Link to comment https://forums.phpfreaks.com/topic/79924-mysql-displaying-anything-over-0/page/2/#findComment-405759 Share on other sites More sharing options...
Deanznet Posted December 4, 2007 Author Share Posted December 4, 2007 Im lost lol here are my tables CREATE TABLE `items` ( `item_id` int( NOT NULL default '0', `item_desc` varchar(255) NOT NULL default '', `item_price` int( NOT NULL default '0', `item_quantity` int( NOT NULL default '0', `item_picture` varchar(255) NOT NULL default '', `item_sellback` int( NOT NULL default '0', `item_in_shop` tinyint(2) NOT NULL default '0', `item_name` varchar(255) NOT NULL default '' `item_id` int( NOT NULL default '0', `item_name` varchar(255) NOT NULL default '', `user_owner_id` int( NOT NULL default '0', `item_quantity` int( NOT NULL default '0' And than phpbb_user with user_points Link to comment https://forums.phpfreaks.com/topic/79924-mysql-displaying-anything-over-0/page/2/#findComment-405762 Share on other sites More sharing options...
mr_mind Posted December 4, 2007 Share Posted December 4, 2007 ahh theres the mistake. the sql query had "WHERE item_name='$itemID'" and item_name should have been item_id replace this line: $price_query = mysql_query("SELECT * FROM items WHERE item_name='$itemID'"); with this line: $price_query = mysql_query("SELECT * FROM items WHERE item_id='$itemID'"); Link to comment https://forums.phpfreaks.com/topic/79924-mysql-displaying-anything-over-0/page/2/#findComment-405772 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.