Jump to content

Having variable problem. I think.


iStriide

Recommended Posts

I'm not sure what is going on in this code, but for some reason it is not echoing my variable. I'm probably just having a total brain fart right now.

<?php

<?php

$opponent_check = isset($_POST['player_username']);

$session = isset($_SESSION['user']);

if($opponent_check){

include_once('connect.php');

$find_player = "SELECT * FROM stats WHERE Username = '$session'";
$s = mysql_fetch_array(mysql_query($find_player)) or trigger_error(mysql_error());

$player = $s['Username'];
$player_HBS = $s['HBS'];
$player_level = $s['Level'];
$player_level_image = $s['Level_Image'];
$player_skill = $s['Skill'];
$player_attack = $s['Attack'];
$player_defense = $s['Defense'];
$player_strength = $s['Strength'];
$player_speed = $s['Speed'];
$player_accuracy = $s['Accuracy'];
$player_range = $s['Range'];

echo $player;

}else{

echo "

You didn't start a battle.<br/><br/>
<a href='index.php'>Back to Matchmaking</a>
<br/><br/>

";

}

?>

?>

 

My error is: Notice: in C:\xampp\htdocs\halobattles\headtohead.php on line 277 which is the fetch array line.

Link to comment
https://forums.phpfreaks.com/topic/245251-having-variable-problem-i-think/
Share on other sites

this:

$opponent_check = isset($_POST['player_username']);

$session = isset($_SESSION['user']);

should be this:

if(isset($_POST['player_username']))
   $opponent_check = $_POST['player_username'];

if(isset($_SESSION['user']))
   $session = $_SESSION['user'];

 

Also this:

if($opponent_check){

should be this:

if(isset($opponent_check)){

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.