Jump to content

help with php code.


seany123

Recommended Posts

right so im making a game and the code your about to see is a basic code to update some of the players values... money and city_id.

 

<?php
header("location: home.php");
include("lib.php");
$player = check_user($secret_key, $db);
?>

<?php
$query = $db->execute("update `players` set `money`=?, `city_id`=2 where `id`=?", array($player->money - 1000, $player->id ));
?>

 

The help i need is....

 

im wanting to make it so if the $player has less than 1000 money and/or city_id = 2.... then it would just do the redirect without doing the query.

 

how do i do this???

Link to comment
https://forums.phpfreaks.com/topic/134410-help-with-php-code/
Share on other sites

Is this what you mean...

 

include("lib.php");
$player = check_user($secret_key, $db);

if($player->money city_id == 2) {
     header("location: home.php");
}
else {
     $query = $db->execute("update `players` set `money`=?, `city_id`=2 where `id`=?", array($player->money - 1000, $player->id ));
}
?>

Link to comment
https://forums.phpfreaks.com/topic/134410-help-with-php-code/#findComment-699748
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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