-
Posts
1,842 -
Joined
-
Last visited
Posts posted by marcus
-
-
timestamps and last locations.
-
<?php include (CreatePath("includes/memberfunctions.php")); if ($_mem->CheckUsername($_POST['username'])) { if ($_mem->CheckPasswords($_POST['password'], $_POST['repassword'])) { //LINE ERROR if ($_mem->CheckEmailAddress($_POST['email'])) { if ($_mem->Register()) { echo "done"; } else { echo "not registered"; } } else { echo "email not entered"; } } else { echo "passwords do not match"; } } else { echo "username taken"; } ?>
You didn't end one of your if statements.
-
So you've tried loading your TrueTypeFont file into the document? Well it's most likely going to be hard to accomplish because the characters are not of use of the English alphabet.
-
Ok, I am trying to prevent users from refreshing to continue to buy an item. I haven't run into this problem before but now it's giving me messages that shouldn't pop up.
<?php session_start(); $need_log = 1; $page = "Town Square"; include "/home/********/public_html/global.php"; $act = $_GET['act']; layout('header'); if (!$act) { $sql = "SELECT * FROM `shops` WHERE `location`='1' ORDER BY `name`"; $res = mysql_query($sql) or die(mysql_error()); echo "<table border=\"0\" cellspacing=\"3\" cellpadding=\"3\" class=\"forum\">\n"; echo "<tr><td colspan=\"4\" align=\"center\" class=\"forum_title\">Town Square</td></tr>\n"; echo "<tr>\n"; $x = 1; while ($row = mysql_fetch_assoc($res)) { echo "<td align=\"center\" valign=\"top\"><a href=\"/town/index.php?act=shop&id={$row['id']}\" style=\"text-decoration:none;\"><img border=\"0\" src=\"/images/shops/lolshop.jpg\" alt=\"" . strip3($row['desc']) . "\"><br>" . strip3($row['name']) . "</a></td>\n"; if ($x == 4) { echo "</tr><tr>\n"; $x = 0; } $x++; } echo "</tr>\n"; echo "</table>\n"; } else { if ($act == 'shop') { $id = protect($_GET['id']); if ($id) { $sql = "SELECT * FROM `shops` WHERE `id`='{$id}'"; $res = mysql_query($sql) or die(mysql_error()); if (mysql_num_rows($res) == 0) { echo "Invalid shop!\n"; } else { $row = mysql_fetch_assoc($res); $sql2 = "SELECT * FROM `shop_stock` WHERE `shop_id`='{$id}' AND `quantity` > 0"; $res2 = mysql_query($sql2) or die(mysql_error()); echo "<table border=\"0\" cellspacing=\"3\" cellpadding=\"3\" class=\"forum\">\n"; echo "<tr><td colspan=\"4\" align=\"center\" class=\"forum_title\">" . strip3($row['name']) . "</td></tr>\n"; echo "<tr><td colspan=\"4\" align=\"center\"><em>" . strip3($row['desc']) . "</em></td></tr>\n"; $count = mysql_num_rows($res2); if (mysql_num_rows($res2) == 0) { echo "<tr><td align=\"center\">Sorry, we're fresh out! Come back in a few minutes.</td></tr>\n"; } else { echo "<tr>\n"; $x = 1; $sizzle = 4 / $count; while ($row2 = mysql_fetch_assoc($res2)) { echo "<td align=\"center\" valign=\"top\"><a href=\"/town/index.php?act=buy&id={$row2['id']}&key={$row2['key']}&t=" . time() . "\">" . shopItem($row2['item_id'], $row2['price'], $row2['quantity']) . "</td>\n"; if ($x == 4) { echo "</tr><tr>\n"; $x = 0; } $x++; } echo "</tr>\n"; } echo "</table>\n"; } } else { echo "No shop supplied!\n"; } } if ($act == 'buy') { $id = protect($_GET['id']); $key = protect($_GET['key']); $time = $_GET['t']; if ($id && $key) { if (!$_POST['submit']) { $_SESSION['buy'] == 'yes'; // set session here $sql = "SELECT * FROM `shop_stock` WHERE `id`='{$id}' AND `key`='{$key}' AND `quantity` > 0"; $res = mysql_query($sql) or die(mysql_error()); if (mysql_num_rows($res) == 0) { echo "Item does not exist!\n"; } else { $row = mysql_fetch_assoc($res); echo "<table border=\"0\" cellspacing=\"3\" cellpadding=\"3\" class=\"forum\">\n"; echo "<form method=\"post\" action=\"/town/index.php?act=buy&id={$id}&key={$key}&t={$time}\">\n"; echo "<tr><td colspan=\"2\" align=\"center\" class=\"forum_title\">Buying an Item</td></tr>\n"; if ($_GET['err']) { if ($_GET['err'] == '1') { echo "<tr><td colspan=\"2\" align=\"center\" valign=\"middle\"><font color=\"red\">You cannot afford this item</font></td></tr>\n"; } if ($_GET['err'] == '2') { echo "<tr><td colspan=\"2\" align=\"center\" valign=\"middle\"><font color=\"red\">Your haggle is too low</font></td></tr>\n"; } if ($_GET['err'] == '3') { echo "<tr><td colspan=\"2\" align=\"center\" valign=\"middle\"><font color=\"red\">Your haggle is too high</font></td></tr>\n"; } if ($_GET['err'] == '4') { echo "<tr><td colspan=\"2\" align=\"center\" valign=\"middle\"><font color=\"red\">You have 50 or more items in your inventory!</font></td></tr>\n"; } } echo "<tr><td align=\"center\" valign=\"middle\">" . iNn($row['item_id']) . "</td>\n"; echo "<td align=\"left\" valign=\"middle\">\n"; echo " <table border=\"0\" cellspacing=\"3\" cellpadding=\"3\">\n"; echo " <tr><td>Cost</td><td>" . number_format($row['price']) . " cP</td></tr>\n"; echo " <tr><td>Haggle</td><td><input type=\"text\" name=\"haggle\" class=\"forum_submit\"></td></tr>\n"; echo " <tr><td colspan=\"2\"><input type=\"submit\" name=\"submit\" value=\"Haggle and Buy\" class=\"forum_submit\"></td></tr>\n"; echo " </table>\n"; echo "</td></tr>\n"; echo "</form></table>\n"; } } else { if (!$_SESSION['buy']) { // checks if session exists or not echo "You cannot refresh to buy an item!"; } else { $sql = "SELECT * FROM `shop_stock` WHERE `id`='{$id}' AND `key`='{$key}' AND `quantity` > 0"; $res = mysql_query($sql) or die(mysql_error()); if (mysql_num_rows($res) == 0) { echo "Item does not exist!\n"; } else { $haggle = floor($_POST['haggle']); $row = mysql_fetch_assoc($res); $price = $row['price']; $quantity = $row['quantity']; $min_price = $price * .90; $max_price = $price + ($price * .1); $rarity = itemInfo($row['item_id'], "rarity"); $shop = $row['shop_id']; $item_id = $row['item_id']; $num = mysql_num_rows(mysql_query("SELECT * FROM `user_items` WHERE `place`='inventory' AND `uid`='{$_COOKIE['uid']}'")); $row2 = mysql_fetch_assoc(mysql_query("SELECT points FROM `users` WHERE `id`='{$_COOKIE['uid']}'")); if ($haggle > $row2['points']) { header("Location: /town/index.php?act=buy&id=$id&key=$key&t=$time&err=1"); } else { if ($haggle < $min_price) { header("Location: /town/index.php?act=buy&id=$id&key=$key&t=$time&err=2"); } else { if ($haggle > $max_price) { header("Location: /town/index.php?act=buy&id=$id&key=$key&t=$time&err=3"); } else { if ($num >= 50) { header("Location: /town/index.php?act=buy&id=$id&key=$key&t=$time&err=4"); } else { give_points($_COOKIE['uid'], -$haggle); if ($quantity - 1 <= 0) { $sql2 = "DELETE FROM `shop_stock` WHERE `id`='{$id}' AND `key`='{$key}'"; } else { $sql2 = "UPDATE `shop_stock` SET `quantity`=`quantity`-1 WHERE `id`='{$id}' AND `key`='{$key}'"; } if ($rarity >= 100) { $seconds = time() - $row['time']; $sql3 = "INSERT INTO `rare_item_log` (`uid`,`item_id`,`seconds`) VALUES('{$_COOKIE['uid']}','{$row['item_id']}','$seconds');"; $res3 = mysql_query($sql3) or die(mysql_error()); } $res2 = mysql_query($sql2) or die(mysql_error()); $sql4 = "INSERT INTO `user_items` (`uid`,`item_id`,`place`,`price`,`time`) VALUES('{$_COOKIE['uid']}','{$row['item_id']}','inventory','0','" . time() . "');"; $res4 = mysql_query($sql4) or die(mysql_error()); if ($row['item_id'] == '46') { __avatar($_COOKIE['uid'], '5'); } echo "<table border=\"0\" cellspacing=\"3\" cellpadding=\"3\" class=\"forum\">\n"; echo "<tr><td align=\"center\" class=\"forum_title\">Successful</td></tr>\n"; echo "<tr><td align=\"center\">" . iNn($item_id) . "</td></tr>\n"; echo "<tr><td align=\"center\">You have successfully bought this item for <b>" . number_format($haggle) . "</b> cP! <a href=\"/town/index.php?act=shop&id={$shop}\">Click here</a> to return the shop.</td></tr>\n"; echo "</table>\n"; session_destroy(); // session is destroyed } } } } } } } } else { echo "Invalid item!\n"; } } } layout('footer'); ?>
I commented the lines that start and create the problem.
It seems the session is not passing when the form is submitted.
-
Your fault not ours.
$whateveryourqueryvariableiscalled = mysql_query("w/e") or die(mysql_error());
-
<?php // connect to db $num_fields = mysql_num_fields($query_result); if ($num_fields) { //build the order by row echo "<tr>"; for ($i = 0; $i < $num_fields; $i++) { $colname = mysql_field_name($query_result, $i); //build a default header for both ascending and descending link $orderlink = ("<a href=\"" . $_SERVER["PHP_SELF"] . "?columnname=" . $colname . "&sort=desc\" title=\"Sort the records in descending order\">Sort descending</a>"); $orderlink .= " "; $orderlink .= ("<a href=\"" . $_SERVER["PHP_SELF"] . "?columnname=" . $colname . "&sort=asc\" title=\"Sort the records in ascending order\">Sort ascending</a>"); if ($_GET['columnname'] == $colname) { if ($order == "asc") { $orderlink = ("<a href=\"" . $_SERVER["PHP_SELF"] . "?columnname=" . $colname . " &sort=desc\" title=\"Sort the records in descending order\">Sort descending</a>"); // default replaced by single link } else { $orderlink = ("<a href=\"" . $_SERVER["PHP_SELF"] . "?columnname=" . $colname . "&sort=asc\" title=\"Sort the records in ascending order\">Sort ascending</a>"); } } echo "<td>" . $orderlink . "</td>"; // place each link-couplein a new cell } echo "</tr>"; } else { echo "Empty recordset"; } //and then here comes your code to display the records from the recordset. while ($row = @mysql_fetch_array($query_result)) { echo "<tr align=\"center\" bgcolor=\"$row[colourcode]\"> <td align=\"left\"><font size=\"2\" face=\"Verdana, Arial, Helvetica, sans-serif\" color=\"#006699\"> $row[CustomerID]</font></td> <td align=\"left\"><font size=\"2\" face=\"Verdana, Arial, Helvetica, sans-serif\" color=\"#006699\"> $row[Name]</font></td> <td align=\"left\"><font size=\"2\" face=\"Verdana, Arial, Helvetica, sans-serif\" color=\"#006699\"> $row[Address]</font></td> <td align=\"left\"><font size=\"2\" face=\"Verdana, Arial, Helvetica, sans-serif\" color=\"#006699\"> $row[Postcode]</font></td> <td align=\"left\"><font size=\"2\" face=\"Verdana, Arial, Helvetica, sans-serif\" color=\"#006699\"> $row[Telephone]</font></td> <td align=\"left\"><font size=\"2\" face=\"Verdana, Arial, Helvetica, sans-serif\" color=\"#006699\"> $row[Email]</font></td> </tr>"; } ?>
neat too.
-
Oh i see.
$sql = "SELECT text FORM `worksheets` WHERE `id`='".$_SESSION['id']."' AND `something`='".$title."'"; $res = mysql_query($sql) or die(mysql_error()); $row = mysql_fetch_assoc($res); // you only selected text, so you can only return text $sql2 = "INSERT INTO `table` (`text`) VALUES('".$row['text']."')"; $res2 = mysql_query($sql2) or die(mysql_error());
-
FCKEditor is a good one.
-
Tinker, that's going to echo 16 lines because you're working with the foreach statement
-
$sql = "INSERT INTO `table` (`name`,`flavor`) VALUES('marcus','chocolatey')"; $res = mysql_query($sql) or die(mysql_error()); $id = mysql_insert_id(); $sql2 = "SELECT * FROM `table` WHERE `id`='".$id."'"; $res2 = mysql_query($sql2) or die(mysql_error()); $row = mysql_fetch_assoc($res2); echo "Your name is " . $row['name'] . " and your favorite flavor is " . $row['flavor'];
-
<?php $array = array('porn','sex','whatever','else'); $string = "whatever porn or sex is"; foreach($array AS $bad){ if(preg_match("/$bad/is",$string)){ $error = TRUE; } } if($error){ echo "Your search contained 'sexy' words!"; }else { echo "Your search is confirmed a-okay!"; } ?>
tested, it's working.
-
<?php function session($user, $login = 'yes'){ $_SESSION['user'] = $user; $_SESSION['login'] = $login; } session('marcus'); echo "<pre>\n"; print_r($_SESSION); echo "</pre>\n"; session('billy','no'); echo "<pre>\n"; print_r($_SESSION); echo "</pre>\n"; ?>
My results:
Array ( [user] => marcus [login] => yes ) Array ( [user] => billy [login] => no )
-
<?php $string = 'monkeys pie potato grape loser lemonade woot pie'; $ex = explode("\n",$string); shuffle($ex); echo $ex[rand(0,count($ex))]; ?>
Random line from the string variable. You can include a text file instead. So like:
<?php $file = file('this-file.txt'); shuffle($file); echo $file[rand(0,count($file))]; ?>
-
It's escaping the brackets to be correct format for regex. Then if
[b]text[/b]
is found somewheres in the variable, it will replace it with the strong HTML.
-
Did you even bother looking at his code layout?
Index includes homepage, while homepage includes links.
-
<?php function bbcode_format($post) { $post = htmlentities($post); $simple_search = array( '/\[b\](.*?)\[\/b\]/is' ); $simple_replace = array( '<strong>$1</strong>' ); // Do simple BBCode's $post = preg_replace ($simple_search, $simple_replace, $post); return $post; } $post = "[b]hello[/b]"; $p = bbcode_format($post); echo $post."<br>"; echo $p."<br>"; ?>
-
echo "Welcome " . $myusername ." <a href=\"/login_success.php\">Convert Your Grade</a>\n";
-
You could do an assortment of arrays.
<?php $lang = array( 'en' => array( 'title' => 'Your Page', 'content' => 'I Love Lemonade' ), 'fr' => array( 'title' => 'Title in French', 'content' => 'Lemonade I Love' ) ); $set_lang = "en"; echo "Title: " . $lang[$set_lang]['title'] . "<br>\n"; echo "Content: " . $lang[$set_lang]['content']; ?>
-
You got session_start(); on each page?
-
Use IPN
-
<input type="text" name="inIngredient[]" value="whatever" class="new-ingredients" /> <input type="text" name="inIngredient[]" value="whatever" class="new-ingredients" /> <input type="text" name="inIngredient[]" value="whatever" class="new-ingredients" /> <input type="text" name="inIngredient[]" value="whatever" class="new-ingredients" />
$ingredients = $_POST['inIngredient']; foreach($ingredients AS $ingredient){ echo $ingredient . "<br />\n"; }
-
mail(to,subject,message,headers);
-
why not just something like:
$range = range(6,16); $variable = "hello!"; if(in_array(strlen($variable),$range)){ // OMG }else { // FAIL }
-
It's forwarded, so only the first example will work.
[SOLVED] Syntax error, unexpected '{'
in PHP Coding Help
Posted
that one.