XP addition form, gives an error.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
thereaper87
Forum Newbie
Posts: 1
Joined: Thu Jul 08, 2010 11:36 pm

XP addition form, gives an error.

Post 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.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: XP addition form, gives an error.

Post by requinix »

Have you consulted mysql_error to see what the problem is?

(And you need to use

Code: Select all

, not [php])
Post Reply