Jump to content


  • Posts

  • Joined

  • Last visited

About Tanelorn

  • Birthday 05/13/1994

Profile Information

  • Gender
  • Location

Tanelorn's Achievements


Newbie (1/5)



  1. I've managed to solve this problem perhaps not the best way of solving it but for the task it's supposed to do it's okay $id = htmlentities($_SESSION['id']) ; $sql = "SELECT * FROM characters WHERE characters.owner = '$id'"; It shows everything exactly as I want it to so thank you all for the help ^^
  2. I'm well aware of that the on and where is completely redundant there I had so that it showed every character and the owner of the character. and the htmlentities is the current user logged in user. I don't want to show every character just the user that is currently logged in. If I switch to user id it will list every account which I don't want it to I want it to list of the user who is logged in atm. Theres the code $sql = "SELECT accounts.id, accounts.username, characters.owner, characters.name, characters.money FROM characters LEFT JOIN accounts ON accounts.id = characters.owner WHERE accounts.username = X ORDER BY owner ASC";
  3. MYSQL version: 5.5.24 I've got a problem. For my project in a class I want to show the characters of the person who is currently logged in. I get it to show every character in the database "characters" but not the logged in. I've tried to put this code in the WHERE but it will just ignore it and all of the other code jsut gets commented away when I do the "" to make it visible (in php) a friend of mine have written a C++ program that does this exact same thing altough I don't get it to work. So my question is what should I put in the WHERE to get the characters.name of the "current user" I've thought of making the: WHERE accounts.id = " . htmlentities($_SESSION['username'] ." Altough these two " makes so the rest of the code gets commented away and I've tried to put an extra " but nothing happens and I need the two " too make the htmlentities correct. I know this is both PHP and MYSQL but since it's the SQL part I need help with I put it here. If any admin see this as the wrong place to have my post please move it in that case or tell me to redo it at the right place
  4. I managed to solve the problem and thanks everyone for the information needed, much appreciated ^^
  5. Any idea how to solve it?
  6. Well after that this actually happend http://i.imgur.com/ISl0m.png
  7. An error occured while inserting your data. Please try again later. 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 'test )' at line 7 and it's the same code except that the now() is deleted from there since the other two is actually the values I need. And double quotes where are they? (in my code) Sorry for not seeing this mostlikely simple problem
  8. Yeah I just fixed that but I still get the same error but on line 7 atm not 8 but that is just because the "now()" was erased. And just to let everyone know this is for my school project so please don't expect me to understand everything that easy so I be real happy if you explain it thoroughly
  9. I tried to fix this by deleting the now() and I still get the same error... And thanks all for the help I really do appreciate it.
  10. Could you explain it more clear since english inst my main language and I'm still learning php and thanks this is actually the first problem I've gotten so far
  11. I got an error in my code and I'm not really sure of what it might be... this is the problem that I get I guess the problem is in the area that I will colour red in the code below. Since that is the 8th row of sql that is initiated I moved the green one to the end of the other row and the number switched from 8 to 7 so it is that code that is red that atm is what I see is the error so if someone could help me with this I would really appreciate it. <?php include '../../php/header2.php'; echo' <!--Mainbody--> <div align="center"class="box">'; echo '<h2>Create a topic</h2>'; if($_SESSION['signed_in'] == false) { echo 'Sorry, you have to be <a href="/forum/signin.php">signed in</a> to create a topic.'; } else { if($_SERVER['REQUEST_METHOD'] != 'POST') { $sql = "SELECT cat_id, cat_name, cat_description FROM categories"; $result = mysql_query($sql); if(!$result) { echo 'Error while selecting from database. Please try again later.'; } else { if(mysql_num_rows($result) == 0) { if($_SESSION['user_level'] == 1) { echo 'You have not created categories yet.'; } else { echo 'Before you can post a topic, you must wait for an admin to create some categories.'; } } else { echo '<form method="post" action=""> Subject: <input type="text" name="subcat_name" /><br /> Category:'; echo '<select name="subcat_cat">'; while($row = mysql_fetch_assoc($result)) { echo '<option value="' . $row['cat_id'] . '">' . $row['cat_name'] . '</option>'; } echo '</select><br />'; echo 'Message: <br /><textarea name="subcat_description" /></textarea><br /><br /> <input type="submit" value="Create subcategory" /> </form>'; } } } else { $query = "BEGIN WORK;"; $result = mysql_query($query); if(!$result) { echo 'An error occured while creating your topic. Please try again later.'; } else { $sql = "INSERT INTO subcategories (subcat_name, subcat_cat, subcat_description) VALUES('" . mysql_real_escape_string($_POST['subcat_name']) . "', NOW(), " . mysql_real_escape_string($_POST['subcat_cat']) . " " . mysql_real_escape_string($_POST['subcat_description']) . " )"; $result = mysql_query($sql); if(!$result) { echo 'An error occured while inserting your data. Please try again later.<br /><br />' . mysql_error(); $sql = "ROLLBACK;"; $result = mysql_query($sql); } else { $sql = "COMMIT;"; $result = mysql_query($sql); echo 'You have succesfully created <a href="subcategories.php?id='. $subcat_id . '">your new subcategorie</a>.'; } } } } ?> <?php echo '</div> <!--Bottom--> <div align="left"class="bottom"> </div>'; ?>
  • 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.