Jump to content

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

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.