Jump to content

Chevy

Members
  • Posts

    167
  • Joined

  • Last visited

    Never

Everything posted by Chevy

  1. Hmm I am getting this error 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 'where reply.poster = users.username WHERE topicid='1' AND groupid='1'' at line 1
  2. Does anyone know how I could do this?
  3. [code] if (isset($_POST['submit'])){ mysql_query("INSERT INTO reply (groupid, topicid, poster, message, time) VALUES('$groupid', '$topicid', '$username', '$message', '$time') "); $posts = $user['posts']++; mysql_query("UPDATE users SET posts='$posts' WHERE username='$username'") or die(mysql_error()); } [/code]
  4. I have a table called users and when they post it adds one to the row in users called posts
  5. It is really early and I need to figure out a problem I am having...here is my code: [code] <?php session_start(); if ($_SESSION['logged']==yes){}else {echo "Please login!";exit;} mysql_connect("localhost", "_real", "hidden") or die(mysql_error()); mysql_select_db("_real") or die(mysql_error()); $username = $_SESSION['username']; $id = $_GET['id']; $topicid = $_GET['topicid']; $query = "SELECT * FROM reply WHERE topicid='$topicid' AND groupid='$id'"; $result = mysql_query($query) or die(mysql_error()); $query2 = "SELECT * FROM users WHERE username='$username'"; $result2 = mysql_query($query2) or die(mysql_error()); $user = mysql_fetch_array($result2); echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"1\">"; while($main = mysql_fetch_array($result)){ echo '<tr><td style="border:1px solid black;" width="100"> <center>'; echo "<b>";echo $main['poster'];echo "</b><br>"; echo "<img src=\"";echo $user['avatar'];echo "\"><br> Posts: <b>";echo $user['posts'];echo "</b> </center></td>"; echo '<td style="border:1px solid black;" width="450">'; echo "Posted On: <i>";echo $main['time'];echo "</i><hr>"; echo $main['message']; echo "</td></tr>"; } echo "</table>"; ?> [/code] Okay now when the user posts it adds 1 to a table called users, but they are all the same for every user when it shows up on the page (the post count is the same) and help? Yes I know my code is messy  ;D
  6. Chevy

    Stuck..

    Haha, I know that...What if I had 10 there? I want it to make a new line or <tr> every multiple of four like so: 1 2 3 4 5 6 7 8 9 10 11 12
  7. Chevy

    Stuck..

    I am making a game and I only want 4 things displayed on 1 line My Code Now: [code] <?php $frogs = 1; $level = 8; echo "<h3>Level $level</h3>"; echo '<table border="0" align="center"><tr>'; while ($frogs <= $level) { echo "<td>"; echo '<form action="" method="POST">'; echo 'Frog ';echo "$frogs"; echo '<br><input type="submit" name=';echo "\"$frogs\"";echo ' value="Choose This Frog!"> </td>'; $frogs = $frogs + 1; } echo "</tr></table>"; ?> [/code]
  8. You could use regex and strip_tags in your varibles of $_GET if they enter it in the URL [code] $varible = strip_tags($_GET['url']); if (!preg_match('/^\w+$/', $varible)) { echo "Only user letters, numbers and underscores!"; //Thats for what it says haha } [/code] Unless I read your last post wrong and this means nothing to you lol
  9. When you get undefined function image* it means the gd library isnt being used. Check the php.ini file. Make sure the php_gd.dll isnt commented out. Restarting apache should result in the image functions working. From: PHP.net
  10. or you can just do this [code] if ($something == NULL AND $something_else == NULL){ //Whatever [/code]
  11. [code] <?php if (isset($_POST['submit'])) { function cleanUp($input) {   return htmlspecialchars(strip_tags(stripslashes(trim($input))));// well no-one ever gets passed this :D } $shop_title = cleanUp($_POST['shop_name']); $shop_front = $_POST['shop_front']; $shop_front = str_replace("<", "[", $shop_front); $shop_front = str_replace(">", "]", $shop_front); $shop_desc = cleanUp($_POST['shop_desc']); $shop_desc = nl2br($shop_desc); $shop_size = cleanUp($_POST['shop_size']); $shop_location = cleanUP($_POST['shop_location']); $timestamp = strtotime("now"); $username = $logged['username']; if ( (empty($shop_title)) || (empty($shop_desc)) || (empty($shop_size)) || (empty($shop_location))) { include($_SERVER['DOCUMENT_ROOT']."/connect.php"); $sql2 = "SELECT * FROM shops WHERE owner = '" . $logged[username] . "'"; $result2 = mysql_query($sql2) or print ("Can't select table.<p>" . mysql_query() . "</p>"); $number = mysql_num_rows($result2); if ($number != 1) { include($_SERVER['DOCUMENT_ROOT'] . "/connect.php"); $sql = "INSERT INTO shops (timestamp, owner, shop_name, shop_desc, shop_front, shop_size, Shop_location) VALUES ('$timestamp','$username','$shop_title','$shop_desc','$shop_front','$shop_size','$shop_location')"; $result = mysql_query( $sql ) or die ( mysql_error());//exit, can also be used $id = mysql_insert_id(); $shop_size2 = $_POST['shop_size']; if ($shop_size2 == "4") { $price = "50"; } else if ($shop_size2 == "8") { $price = "100"; } else if ($shop_size2 == "12") { $price = "200"; } else if ($shop_size2 == "16") { $price = "300"; } else if ($shop_size2 == "20") { $price = "400"; } else if ($shop_size2 == "60") { $price = "600"; } include($_SERVER['DOCUMENT_ROOT']."/connect.php"); $sql4 = "SELECT * FROM users WHERE username = '" . $logged[username] . "'"; $result4 = mysql_query($sql4) or die ("Can't select table.<p>" . mysql_query() . "</p>");// use exit or die, print won't stop the script.. while($row4 = mysql_fetch_array($result4)) { $points = $row4['points']; } $equation = $points - $price; include($_SERVER['DOCUMENT_ROOT'] . "/connect.php"); $sql5 = "UPDATE users SET points='$equation' WHERE username='" . $logged[username] . "' LIMIT 1";// you could also just use $sql again, therefore they are called variables :P $result5 = mysql_query($sql5) or die (mysql_error());// same here, use $result instead of always incrementing if ($result5 != false) { echo "<span style=\"color: green;\">Success!  Your shop has been successfully created!It is located at <p><a href=\"shop.php?id=$id\">$address/shop.php?id=$id</a></span>"; } } else { echo "<span style=\"color: red;\">You Have already created a shop!</span>"; } } else { echo "<span style=\"color: red;\">You must fill in all the required fields.</span>"; } } ?> [/code] You do not need ('s or )'s in a -
  12. Thanks I figured it out :) But thank you a lot!
  13. Sorry for your time I found my error!
  14. Chevy

    How would i...

    Oh yeaa :D Thanks a lot!
  15. How would I got about banning spaces? [code]if (!ereg ("([0-9a-zA-Z_])", $username)) {[/code] thats all I want to allow is 0-9, a-z, A-Z and _'s....but spaces somehow find there way threw....can you help me?
  16. Thank you very much! That never even crossed my mind  ;D It has been a long day...
  17. ChaosXero - my previous post said it
  18. Yup and you can use it in any other statement example if ($user==Bob AND password==bobby){
  19. I tried [code]if (($latitude==1||2||3||4||5) && ($longitude==1||2||3||4||5)){[/code] No luck on 6,6 I still got the massage [code] $latitude = $row['latitude']; $longitude = $row['longitude']; $totalfish = $row['totalfish']; if ($process == play){ if (isset($_POST["right"])) {$latitude++; mysql_query("UPDATE table SET latitude='$latitude' WHERE username='$MySN'") or die(mysql_error());} if (isset($_POST["left"])) {$latitude--; mysql_query("UPDATE table SET latitude='$latitude' WHERE username='$MySN'") or die(mysql_error());} if (isset($_POST["up"])) {$longitude++; mysql_query("UPDATE table SET longitude='$longitude' WHERE username='$MySN'") or die(mysql_error());} if (isset($_POST["down"])) {$longitude--; mysql_query("UPDATE table SET longitude='$longitude' WHERE username='$MySN'") or die(mysql_error());} if ($latitude==1||2||3||4||5 AND $longitude==1||2||3||4||5){         echo "Testing this cordnate!"; } [/code]
  20. well $latitude and $longitude are varibles that take a row from mySQL
  21. I am trying to get multiple number is 1 if statement here is an example [code] if ($latitude==1||2||3||4||5 AND $longitude==1||2||3||4||5){ [/code] It doesn't work the way I want it to, I want every cordante from long 1, lat 1 to long 5,lat 5
  22. Yea I noticed it and fixed it before it works good
  23. Thank you! I actually like that one better tan mine now :)
  24. This is really bugging me so if you could reply that would be great :)
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.