Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Undefined Variable

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #30498
    CoolAsCarlito
    Participant

    Okay so I echoed the query and it ran successfully showing up as:

    SELECT ebw.manager_id AS managerid, ebw.finisher AS finisher, ebw.setup AS setup, ebw.music AS music FROM efed_bio_wrestling AS ebw LEFT JOIN efed_bio AS bio ON ( ebw.bio_id = bio.id) WHERE ebw.bio_id = 6

    managerid:18
    finisher: Joker’s Wild
    setup: Joker’s Card
    music: Still Frame by Trapt.

    Now since it has managerid which is a variable I’m sure I want it to go back into efed_bio and match it to the id field and when it does then get the charactername field value. I thought from the following query I did that.


    if($managerid != ''){
    $query = "SELECT * FROM `efed_bio` WHERE id = '$managerid'";
    $result = mysql_query($query);
    echo $query;
    $row = mysql_fetch_assoc($result);
    $manager = $row;
    }
    else{
    $manager = 'None';
    }

    However it’s still saying that the variable managerid is undefined.

    Here’s the entire function:


    if ($style=='singles') {
    $query = "SELECT ebw.manager_id AS managerid, ebw.finisher AS finisher, ebw.setup AS setup, ebw.music AS music FROM efed_bio_wrestling AS ebw LEFT JOIN efed_bio AS bio ON ( ebw.bio_id = bio.id) WHERE ebw.bio_id = $id";
    $result = mysql_query($query) or die(mysql_error());
    echo $query;
    if($managerid != ''){
    $query = "SELECT * FROM `efed_bio` WHERE id = '$managerid'";
    $result = mysql_query($query);
    echo $query;
    $row = mysql_fetch_assoc($result);
    $manager = $row;
    }
    else{
    $manager = 'None';
    }
    while ($row = mysql_fetch_array($result))
    {
    ?>

    Wrestling






















    Manager/Valet:
    Finisher:
    Setup:
    Entrance Music:


    #78421
    kylewiedman
    Member

    I don’t see where you ever set the variable $managerid… perhaps something like this is what you where going for????


    $query = "SELECT ebw.manager_id AS managerid, ebw.finisher AS finisher, ebw.setup AS setup, ebw.music AS music FROM efed_bio_wrestling AS ebw LEFT JOIN efed_bio AS bio ON ( ebw.bio_id = bio.id) WHERE ebw.bio_id = $id";
    $result = mysql_query($query) or die(mysql_error());
    $row = mysql_fetch_assoc($result);
    $managerid = $row;

    if($managerid != ''){

    #78422
    CoolAsCarlito
    Participant

    That worked however I need to figure out with the managerid if its 0 then that’s when it puts None

    #78143
    armin.hackmann
    Participant

    Hi,

    if you change your script to this, you should get what you want:

    if ( $managerid > 0 ) {

    Hope, this helps! :)

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘Back End’ is closed to new topics and replies.