Recently I have been trying to make my own online browser game somewhat similar to Travian, if anyone has ever played that. I have only recently started, and I am currently working on how a player would level up a resource field.
My problem is that my solution depends on retrieving the current data from the SQL table, and then update it. Unfortunately, all date comes back as a "Resource ID". I have tried finding some solutions online, but I have yet to find one that works.
My code is here. Please check it out:
<?php
session_start();
include("database.php");
include("createcamp.php");
/*This is trying to fetch the current level of "crop1,"
a resource field stored ina table called "Villages".
The variable $cname has a value in "createcamp.php",
and is used as the name for the player'svillage.*/
$level = mysql_query("SELECT crop1 FROM Villages
WHERE camp='$cname'");
$newlevel = $level++;
/*This function is supposed to update the level of
"crop1" I have hard-coded some values now,
but they will be replaced with variables.
The level is needed for this to happen*/
function resUpdt($resnum, $level){
$conn;
$result = mysql_query("UPDATE Villages SET $crop = '$newlevel' WHERE username = '$username'");
//$row = mysql_fetch_array($result);
//echo "$row";
}
switch($_GET['action']) {
case 'crop1': //case == $resnum;
resupdt(crop1, 0);
break;
}
?>
My problem is that without the SQL table returning values, it is impossible for me to complete the goal of this script.
Any and all ideas are appreciated as always.
Thanks in advance.
Cbeppe.
This post has been edited by Cbeppe: 13 December 2009 - 04:44 PM

New Topic/Question
Reply




MultiQuote



|