avatar.alex
Members-
Posts
156 -
Joined
-
Last visited
Never
Everything posted by avatar.alex
-
I can't seem to find a tutorial on basics of making a module based php system. Like how to fetch and execute the module.
-
Thank you so much.
-
Ok this code doesn't look wrong but i cant figure out whats going on? <?php //connect.php $server = 'localhost'; $username = 'admin'; $password = 'pass'; $database = 'gms'; if(!mysql_connect($server, $username, $password)) { exit('Error: could not establish database connection'); } if(!mysql_select_db($database) { exit('Error: could not select the database'); } ?> ERROR Parse error: syntax error, unexpected '{' in /home/adee67/public_html/forum/connect.php on line 13
-
Im getting this error when I put this in. I cant seem to figure it out? #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'user_name']) . "', '" . sha1($_POST['user_pass']) . "', '" . mys' at line 3
-
There is an error on line 36 which is the first line below. I want to be able to pull information from the same id using shops.php?shopid=1 while ($item = $query->fetchrow() && $shop = $shops->fetchrow()) { include("templates/private_header.php"); print "<fieldset>\n"; print "<legend><b>" . $shop['name'] . "</b></legend>\n"; print "<table width=\"100%\">\n"; print "<tr><td width=\"85%\">"; print $shop['country'] . "\n<br />"; print "<b>Effectiveness:</b> " . $shop['npc_name'] . "\n"; print "</td><td width=\"15%\">"; print "<b>Price:</b> " . $shop['npc_dialog'] . "<br />"; print "</td></tr>\n"; print "</table>"; print "</fieldset>\n<br />"; echo "<fieldset>\n"; echo "<legend><b>" . $item['name'] . "</b></legend>\n"; echo "<table width=\"100%\">\n"; echo "<tr><td width=\"85%\">"; echo $item['description'] . "\n<br />"; echo "<b>Effectiveness:</b> " . $item['effectiveness'] . "\n"; echo "</td><td width=\"15%\">"; echo "<b>Price:</b> " . $item['price'] . "<br />"; echo "<a href=\"shop_serv.php?act=buy&id=" . $item['id'] . "\">Buy</a><br />"; echo "</td></tr>\n"; echo "</table>"; echo "</fieldset>\n<br />"; include("templates/private_footer.php"); }
-
its working. Is there a way to bring up the same ID for two different tables for example shops.php?shopid=1 brings the info from table shops and blueprint_items from the same id.
-
I can't find anything wrong with this but its not displaying anything on the page. And there are no errors. Could someone review it? <?php /*************************************/ /* ezRPG script */ /* Written by AlexDee */ /* http://code.google.com/p/ezrpg */ /* http://www.ezrpgproject.com/ */ /*************************************/ include("lib.php"); define("PAGENAME", "Shop"); $player = check_user($secret_key, $db); if(!isset($_GET['shopid'])) { header("Location: cities.php"); } $id = $_GET['shopid']; $query = $db->execute("select `id`, `shopid`,`name`, `description`, `effectiveness`, `price` from `blueprint_items` where `shopid`=?", array($_GET['shopid'])); if ($query->recordcount() == 0) { header("Location: cities.php"); } else { switch($_GET['act']) { case "buy": if (!$_GET['id']) //No item ID { header("Location: shop.php"); break; } //Select the item from the database $query = $db->execute("select `id`, `name`, `price` from `blueprint_items` where `id`=?", array($_GET['id'])); //Invalid item (it doesn't exist) if ($query->recordcount() == 0) { header("Location: shop.php"); break; } $item = $query->fetchrow(); if ($item['price'] > $player->gold) { include("templates/private_header.php"); echo "<b>Shop Keeper:</b><br />\n"; echo "<i>Sorry, but you cannot afford this!</i><br /><br />\n"; echo "<a href=\"inventory.php\">Return to inventory</a> | <a href=\"shop.php\">Return to shop</a>"; include("templates/private_footer.php"); break; } $query1 = $db->execute("update `players` set `gold`=? where `id`=?", array($player->gold - $item['price'], $player->id)); $insert['player_id'] = $player->id; $insert['item_id'] = $item['id']; $query2 = $db->autoexecute('items', $insert, 'INSERT'); if ($query1 && $query2) //If successful { $player = check_user($secret_key, $db); //Get new user stats include("templates/private_header.php"); echo "<b>Shop Keeper:</b><br />\n"; echo "<i>Thank you, enjoy your new <b>" . $item['name'] . "</b>!</i><br /><br />\n"; echo "<a href=\"inventory.php\">Return to inventory</a> | <a href=\"shop.php\">Return to shop</a>"; include("templates/private_footer.php"); break; } else { //Error logging here } break; case "sell": if (!$_GET['id']) //No item ID { header("Location: shop.php"); break; } //Select the item from the database $query = $db->execute("select items.id, blueprint_items.name, blueprint_items.price from `blueprint_items`, `items` where items.item_id=blueprint_items.id and items.player_id=? and items.id=?", array($player->id, $_GET['id'])); //Either item doesn't exist, or item doesn't belong to user if ($query->recordcount() == 0) { include("templates/private_header.php"); echo "Sorry, that item does not exist!"; include("templates/private_footer.php"); break; } $sell = $query->fetchrow(); //Get item info //Check to make sure clicking Sell wasn't an accident if (!$_POST['sure']) { include("templates/private_header.php"); echo "Are you sure you want to sell your <b>" . $sell['name'] . "</b> for <b>" . floor($sell['price']/2) . "</b> gold?<br /><br />\n"; echo "<form method=\"post\" action=\"shop.php?act=sell&id=" . $sell['id'] . "\">\n"; echo "<input type=\"submit\" name=\"sure\" value=\"Yes, I am sure!\" />\n"; echo "</form>\n"; include("templates/private_footer.php"); break; } //Delete item from database, add gold to player's account $query = $db->execute("delete from `items` where `id`=?", array($sell['id'])); $query = $db->execute("update `players` set `gold`=? where `id`=?", array($player->gold + floor($sell['price']/2), $player->id)); $player = check_user($secret_key, $db); //Get updated user info include("templates/private_header.php"); echo "You have sold your <b>" . $sell['name'] . "</b> for <b>" . floor($sell['price']/2) . "</b> gold.<br /><br />\n"; echo "<a href=\"inventory.php\">Return to inventory</a> | <a href=\"shop.php\">Return to shop</a>"; include("templates/private_footer.php"); break; while ($item = $query->fetchrow()) { echo "<fieldset>\n"; echo "<legend><b>" . $item['name'] . "</b></legend>\n"; echo "<table width=\"100%\">\n"; echo "<tr><td width=\"85%\">"; echo $item['description'] . "\n<br />"; echo "<b>Effectiveness:</b> " . $item['effectiveness'] . "\n"; echo "</td><td width=\"15%\">"; echo "<b>Price:</b> " . $item['price'] . "<br />"; echo "<a href=\"shops.php?shopid=" . $item['price'] . "act=buy&id=" . $item['id'] . "\">Buy</a><br />"; echo "</td></tr>\n"; echo "</table>"; echo "</fieldset>\n<br />"; } } } ?>
-
nothing is showing up lol. It says 404 Not Found but the screen is white.
-
<?php /*************************************/ /* ezRPG script */ /* Written by AlexDee */ /* http://code.google.com/p/ezrpg */ /* http://www.ezrpgproject.com/ */ /*************************************/ include("lib.php"); define("PAGENAME", "Shop"); $player = check_user($secret_key, $db); if(!isset($_GET['shopid'])) { header("Location: cities.php"); } $id = $_GET['shopid']; $query = $db->execute("select `id`, `shopid`,`name`, `price` from `blueprint_items` where `shopid`=?", $_GET['shopid']); if ($query->recordcount() == 0) { header("Location: cities.php"); } else { $item = $query->fetchrow(); while ($item = $query->fetchrow()) { echo "<fieldset>\n"; echo "<legend><b>" . $item['name'] . "</b></legend>\n"; echo "<table width=\"100%\">\n"; echo "<tr><td width=\"85%\">"; echo $item['description'] . "\n<br />"; echo "<b>Effectiveness:</b> " . $item['effectiveness'] . "\n"; echo "</td><td width=\"15%\">"; echo "<b>Price:</b> " . $item['price'] . "<br />"; echo "<a href=\"shop.php?act=buy&id=" . $item['id'] . "\">Buy</a><br />"; echo "</td></tr>\n"; echo "</table>"; echo "</fieldset>\n<br />"; } } ?>/code]
-
Ok I set the item in the db: UPDATE `alexdee_game`.`blueprint_items` SET `shopid` = '1' WHERE `blueprint_items`.`id` =3 LIMIT 1 ; and typed in shops.php?shopid=1 and it redirected me to the cities.php?
-
so it should bring up the items just from the shop their assigned.
-
OK im confused now. In order to have items in the shop could I set the shop id from the blueprint_items to the id in the shops table, so then all the items in the blueprint_items will know to show themselves on the page?
-
Ok this isn't going into the table CREATE TABLE `shops` ( `id` int(6) NOT NULL auto_increment, `city_id` int(11) NOT NULL, `keepers_name` text collate latin1_general_ci NOT NULL, `keepers_dialog` text collate latin1_general_ci NOT NULL, PRIMARY KEY (`id`), } ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=9
-
because once I get done figuring all the bugs out im going to have the individual shops in cities. Individual cities.
-
I feel like Im missing something? <? /*************************************/ /* ezRPG script */ /* Written by AlexDee */ /* http://code.google.com/p/ezrpg */ /* http://www.ezrpgproject.com/ */ /*************************************/ include("lib.php"); define("PAGENAME", "Shop"); $player = check_user($secret_key, $db); $id = $_GET['shopid']; { header("Location: citys.php"); } else { $query = $db->execute("select `id`, `shopid`,`name`, `price` from `blueprint_items` where `id`=?", array($_GET['shopid'])); if ($query->recordcount() == 0) { header("Location: cities.php"); } else { $item = $query->fetchrow(); while ($item = $query->fetchrow()) { echo "<fieldset>\n"; echo "<legend><b>" . $item['name'] . "</b></legend>\n"; echo "<table width=\"100%\">\n"; echo "<tr><td width=\"85%\">"; echo $item['description'] . "\n<br />"; echo "<b>Effectiveness:</b> " . $item['effectiveness'] . "\n"; echo "</td><td width=\"15%\">"; echo "<b>Price:</b> " . $item['price'] . "<br />"; echo "<a href=\"shop.php?act=buy&id=" . $item['id'] . "\">Buy</a><br />"; echo "</td></tr>\n"; echo "</table>"; echo "</fieldset>\n<br />"; } ?>
-
So it would be easier to just add a shop ID to the items table. Then how would I go about displaying those items by on the page? I suck at understanding displaying the table info from the id (shops.php?id=X)
-
Ok i am building a mod for my game and I am making it so that there are individual shops. One table is the shop and the other is the items. How would I display the items from the items table on the page if I am using the shop table. I want to be able to put the items into the shop. So only the items from the shop will display and not all the items. I think in the blueprint_items I should add shop_id or in the add_item.php figure a way to add the item id to the shops table. I don't know how to approach this. Shop Table: CREATE TABLE `shops` ( `id` int(6) NOT NULL auto_increment, `weapons_id` `armor_id` `city_id` `keepers_name` `keepers_dialog` `` PRIMARY KEY (`id`), UNIQUE KEY Items Table: CREATE TABLE `blueprint_items` ( `id` int(11) NOT NULL auto_increment, `name` varchar(255) collate latin1_general_ci NOT NULL, `description` text collate latin1_general_ci NOT NULL, `type` enum('weapon','armour') collate latin1_general_ci NOT NULL, `effectiveness` int(11) NOT NULL, `price` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=3 ;
-
im using this thing called adodb.
-
Same error on register.php sorry.
-
<?php /*************************************/ /* ezRPG script */ /* Written by Zeggy */ /* http://code.google.com/p/ezrpg */ /* http://www.ezrpgproject.com/ */ /*************************************/ include("lib.php"); define("PAGENAME", "Register"); $msg1 = "<font color=\"red\">"; //Username error? $msg2 = "<font color=\"red\">"; //Password error? $msg3 = "<font color=\"red\">"; //Verify Password error? $msg4 = "<font color=\"red\">"; //Email error? $msg5 = "<font color=\"red\">"; //Verify Email error? $error = 0; if ($_POST['register']) { //Check if username has already been used $query = $db->execute("select `id` from `players` where `username`=?", array($_POST['username'])); //Check username if (!$_POST['username']) { //If username isn't filled in... $msg1 .= "You need to fill in your username!<br />\n"; //Add to error message $error = 1; //Set error check } else if (strlen($_POST['username']) < 3) { //If username is too short... $msg1 .= "Your username must be longer than 3 characters!<br />\n"; //Add to error message $error = 1; //Set error check } else if (!preg_match("/^[-_a-zA-Z0-9]+$/", $_POST['username'])) { //If username contains illegal characters... $msg1 .= "Your username may contain only alphanumerical characters!<br />\n"; //Add to error message $error = 1; //Set error check } else if ($query->recordcount() > 0) { $msg1 .= "That username has already been used. Please create only one account, Creating more than one account will get all your accounts deleted!<br />\n"; $error = 1; //Set error check } //Check password if (!$_POST['password']) { //If password isn't filled in... $msg2 .= "You need to fill in your password!<br />\n"; //Add to error message $error = 1; //Set error check } else if ($_POST['password'] != $_POST['password2']) { $msg3 .= "You didn't type in both passwords correctly!<br />\n"; $error = 1; } else if (strlen($_POST['password']) < 3) { //If password is too short... $msg2 .= "Your password must be longer than 3 characters!!<br />\n"; //Add to error message $error = 1; //Set error check } else if (!preg_match("/^[-_a-zA-Z0-9]+$/", $_POST['password'])) { //If password contains illegal characters... $msg2 .= "Your password may contain only alphanumerical characters!<br />\n"; //Add to error message $error = 1; //Set error check } //Check email if (!$_POST['email']) { //If email address isn't filled in... $msg4 .= "You need to fill in your email!<br />\n"; //Add to error message $error = 1; //Set error check } else if ($_POST['email'] != $_POST['email2']) { $msg5 .= "You didn't type in both email address correctly!"; $error = 1; } else if (strlen($_POST['email']) < 3) { //If email is too short... $msg4 .= "Your email must be longer than 3 characters!<br />\n"; //Add to error message $error = 1; //Set error check } else if (!preg_match("/^[-!#$%&\'*+\\.\/0-9=?A-Z^_`{|}~]+@([-0-9A-Z]+\.)+([0-9A-Z]){2,4}$/i", $_POST['email'])) { $msg4 .= "Your email format is wrong!<br />\n"; //Add to error message $error = 1; //Set error check } else { //Check if email has already been used $query = $db->execute("select `id` from `players` where `email`=?", array($_POST['email'])); if ($query->recordcount() > 0) { $msg4 .= "That email has already been used. Please create only one account, Creating more than one account will get all your accounts deleted!<br />\n"; $error = 1; //Set error check } } if ($error == 0) { $insert['username'] = $_POST['username']; $insert['password'] = sha1($_POST['password']); $insert['email'] = $_POST['email']; $insert['registered'] = time(); $insert['last_active'] = time(); $insert['ip'] = $_SERVER['REMOTE_ADDR']; $query = $db->autoexecute('players', $insert, 'INSERT'); if (!$query) { $could_not_register = "Sorry, you could not register! Please contact the admin!<br /><br />"; } else { $insertid = $db->Insert_ID(); include("templates/header.php"); echo "Congratulations! You have successfully registered!<br />You may login to the game now."; include("templates/footer.php"); exit; } } } $msg1 .= "</font>"; //Username error? $msg2 .= "</font>"; //Password error? $msg3 .= "</font>"; //Verify Password error? $msg4 .= "</font>"; //Email error? $msg5 .= "</font>"; //Verify Email error? include("templates/header.php"); ?> <?=$could_not_register?> <form method="POST" action="register.php"> <table width="100%"> <tr><td width="40%"><b>Username</b>:</td><td><input type="text" name="username" value="<?=$_POST['username'];?>" /></td></tr> <tr><td colspan="2">Enter the username that you will use to login to your game. Only alpha-numerical characters are allowed.<br /><?=$msg1;?><br /></td></tr> <tr><td width="40%"><b>Password</b>:</td><td><input type="password" name="password" value="<?=$_POST['password'];?>" /></td></tr> <tr><td colspan="2">Type in your desired password. Only alpha-numerical characters are allowed.<br /><?=$msg2;?><br /></td></tr> <tr><td width="40%"><b>Verify Password</b>:</td><td><input type="password" name="password2" value="<?=$_POST['password2'];?>" /></td></tr> <tr><td colspan="2">Please re-type your password.<br /><?=$msg3;?><br /></td></tr> <tr><td width="40%"><b>Email</b>:</td><td><input type="text" name="email" value="<?=$_POST['email'];?>" /></td></tr> <tr><td colspan="2">Enter your email address. Only alpha-numerical characters are allowed.<br /><?=$msg4;?><br /></td></tr> <tr><td width="40%"><b>Verify Email</b>:</td><td><input type="text" name="email2" value="<?=$_POST['email2'];?>" /></td></tr> <tr><td colspan="2">Please re-type your email address.<br /><?=$msg5;?><br /></td></tr> <tr><td colspan="2" align="center"><input type="submit" name="register" value="Register!"></td></tr> </table> </form> <?php include("templates/footer.php"); ?> Here's the error in the above too. Fatal error: Call to a member function recordcount() on a non-object in /home/alexdee/public_html/game/register.php on line 38
-
I have an error I can't figure out the problem? Fatal error: Call to a member function recordcount() on a non-object in /home/alexdee/public_html/game/index.php on line 30
-
Ok this is what I have my page is just blank. It won't even show anything on view source. <?php $log = $_SESSION["userCakeUser"] $usergroup = mysql_query("SELECT Group_ID FROM userCake_Users WHERE login='$log'"); $result=mysql_query($usergroup) $group=mysql_result($result,0,"Group_ID") if ($group == 2) { ?>
-
I have, but the whole page is blank? Not even a error? <?php $log = $_SESSION["userCakeUser"] $usergroup = mysql_query("SELECT Group_ID FROM userCake_Users WHERE login='$log'"); $result=mysql_query($usergroup) $group=mysql_result($result,0,"Group_ID") if ($group == 2) { ?>
-
OK whats the usergroup for? would that be the Group_id or User_id or totally different?
-
this is my session session_start(); //Global User Object Var //loggedInUser can be used globally if constructed if(isset($_SESSION["userCakeUser"]) && is_object($_SESSION["userCakeUser"])) $loggedInUser = $_SESSION["userCakeUser"]; else $loggedInUser = NULL; So I could take the $_SESSION["userCakeUser"]; and = it to $login?