Jump to content

Recommended Posts

Hey Guys,

 

Here's my code:

<?php

$host = "localhost";
$name = "username";
$pass = "password";
$db = "badasstoolz";

$con = mysql_connect($host,$name,$pass);
if (!$con)
{
die('Failed to Connect:' . mysql_error());
}

$selectdb = mysql_select_db($db);
if (!$selectdb)
{
die('Failed to Select Database:' . mysql_error());
}

if(isset($_POST['submitBtn']))
{
$charactername = $_POST['charactername'];
$charactername = mysql_real_escape_string($charactername);
$location = $_POST['location'];
$checkdb = mysql_query("SELECT * FROM characters where name = '$charactername'");
if (!$checkdb)
{
die('Character Name Incorrect:' . mysql_error());
}
else
{

$checkgold = mysql_query("SELECT gold FROM characters WHERE name = '$charactername'");
$gold = mysql_result($checkgold, 0);
if (!$checkdb)
{
die('Could Not Find Gold Amount:' . mysql_error());
}
if ($gold < 10000)
{
echo "Not Enough Gold";
}
else{
if($_POST['location'] == "stormwind"){
$move = mysql_query("UPDATE characters SET positionX = '-8913.230469', positionY = '554.632996', positionZ = '93.795525', mapId = '0', zoneId = '1519', orientation = '0.600044' WHERE name = '$charactername'");
}
elseif($_POST['location'] == "darnassus"){
$move = mysql_query("UPDATE characters SET positionX = '1502.709961', positionY = '-4415.419922', positionZ = '21.552721', mapId = '1', zoneId = '1637', orientation = '0.000000' WHERE name = '$charactername'");
}
elseif($_POST['location'] == "ironforge"){
$move = mysql_query("UPDATE characters SET positionX = '1502.709961', positionY = '-4415.419922', positionZ = '21.552721', mapId = '1', zoneId = '1637', orientation = '0.000000' WHERE name = '$charactername'");
}
elseif($_POST['location'] == "exodar"){
$move = mysql_query("UPDATE characters SET positionX = '1502.709961', positionY = '-4415.419922', positionZ = '21.552721', mapId = '1', zoneId = '1637', orientation = '0.000000' WHERE name = '$charactername'");
}
elseif($_POST['location'] == "orgrimmar"){
$move = mysql_query("UPDATE characters SET positionX = '1502.709961', positionY = '-4415.419922', positionZ = '21.552721', mapId = '1', zoneId = '1637', orientation = '0.000000' WHERE name = '$charactername'");
}
elseif($_POST['location'] == "thunderbluff"){
$move = mysql_query("UPDATE characters SET positionX = '1502.709961', positionY = '-4415.419922', positionZ = '21.552721', mapId = '1', zoneId = '1637', orientation = '0.000000' WHERE name = '$charactername'");
}
elseif($_POST['location'] == "silvermoon"){
$move = mysql_query("UPDATE characters SET positionX = '1502.709961', positionY = '-4415.419922', positionZ = '21.552721', mapId = '1', zoneId = '1637', orientation = '0.000000' WHERE name = '$charactername'");
}
elseif($_POST['location'] == "undercity"){
$move = mysql_query("UPDATE characters SET positionX = '1502.709961', positionY = '-4415.419922', positionZ = '21.552721', mapId = '1', zoneId = '1637', orientation = '0.000000' WHERE name = '$charactername'");
}
elseif($_POST['location'] == "dalaran"){
$move = mysql_query("UPDATE characters SET positionX = '1502.709961', positionY = '-4415.419922', positionZ = '21.552721', mapId = '1', zoneId = '1637', orientation = '0.000000' WHERE name = '$charactername'");
}
elseif($_POST['location'] == "shattrath"){
$move = mysql_query("UPDATE characters SET positionX = '1502.709961', positionY = '-4415.419922', positionZ = '21.552721', mapId = '1', zoneId = '1637', orientation = '0.000000' WHERE name = '$charactername'");
}
else
{
echo "You did not select a Location";
}
if (!$move)
{
die('Failed to Move Player:' . mysql_error());
}	
else
{
$amount = 10000;
$query = "UPDATE characters SET gold = gold - " . $amount . " WHERE name = '" . $charactername . "' AND gold >= '" . $amount . "';";
echo "You succesfully moved your character";
}
}
}
}

?>

 

Ok, this script is supposed to get their name from a field (username) that is in another php document, and teleport them to the location they select in a dropdown on the other page (location).

 

It is then supposed to check if they have more then 10,000 gold.

 

if they dont, it should tell them that they don't have enough.

 

if they do, it finds out which location they picked, and updates that in the characters database.

 

Then, if it is succesful, it is supposed to deduct 10,000 gold from their account.

 

This DOESN'T seem to be happening. I put in 100,000 gold in the DB and it says  I have enough but 30,000 gold is not enough. AND it is not deducting gold.

 

Help would be great!

Cody

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.