Page 1 of 1

XP addition form, gives an error.

Posted: Thu Jul 08, 2010 11:43 pm
by thereaper87
Hello there, first post! :D

I have two pages, the first is submitxp.php which looks like this:

Code: Select all

<?php include("../../tophead.php"); ?>
<form id="addxp" method="post" action="addxp.php">
<input type="submit" value="Add">
</form>
The tophead.php is just the page where the user session is stored.

Then addxp.php is this

Code: Select all

<?php
session_start();
include('../database.php'); 
$userid = $_SESSION['user']; 

$query = "UPDATE `user` SET `xp`=(`xp`+100) WHERE `id` = $userid LIMIT 1";
$result = mysql_query($query) or die('Query Failed');
?>
But when I try it out, it gives the built in "Query Failed" error. I don't know why. I am very n00bish to php so bare with me please. Thanks a million, you have no idea how happy this will make me when it works.

Re: XP addition form, gives an error.

Posted: Fri Jul 09, 2010 1:28 am
by requinix
Have you consulted mysql_error to see what the problem is?

(And you need to use

Code: Select all

, not [php])