...some info in a table doesnt work..
hmm you see the $id is from the url the rest is either in the script or the db.... its meant to get the current balance... and work out how much it should go up and then updat eit to the new baance.. it errors.. any one see why?
Code:
<?php
$dbc = mysql_connect('localhost', '', '') or die("Couldn't connect to database");
mysql_select_db('GAME') or die("Couldn't select database");
$query ="SELECT * FROM founds WHERE id=$id";
$query ="UPDATE founds SET balance = $income WHERE id =$id";
$result = mysql_query($query) or die("There is an error with you account, please contact support and inform them of this");
while ($r = mysql_fetch_array($result)) {
extract($r);
$fincome = $extractors * 2000 ;
$sincome = $extractors * $advanced ;
$income = $fincome + $sincome ;
echo("Account Balance Updated");
?>
Well other than a couple of missing semi-colons at the ends of two lines I don't see anything else wrong. I've never used the extract function before. I usually just pull the data out of the array like so:
while ($row = mysql_fetch_array($result)) {
$yaks = $row["tablecolumnname"];
}
__________________
Spookster
CodingForums Supreme Overlord
All Hail Spookster
Who gave you that Ugging infraction? Yeah that's right it was me!
oh thanks spooks, for all yer help.
wich.. hm ok i put that code you typed in a file and ran it and got
Parse error: parse error in c:\phpdev\www\public\game\hourlyfounds.php on line 8
That simply means that your query: "select * from founds where id=$id" didn't return any results, so either you have no data in you table matching id to $id, or $id has an inapropriate value or the table 'founds' doesn't exist...
Try using this, that should give you some more info:
Code:
<?php
$dbc = mysql_connect('localhost', '', '') or die("Couldn't connect to database");
mysql_select_db('GAME') or die("Couldn't select database");
$query ="SELECT * FROM founds WHERE id=$id";
$result = mysql_query($query);
if (!$result)
die(mysql_error());
while ($r = mysql_fetch_array($result)) {
extract($r);
$fincome = $extractors * 2000 ;
$sincome = $extractors * $advanced ;
$income = $fincome + $sincome ;
$query ="UPDATE founds SET balance = $income WHERE id = $id";
$result = mysql_query($query);
if (!$result)
die(mysql_error());
}
echo("Account Balance Updated");
?>