Jump to content

If statement trouble


Xtremer360

Recommended Posts

I'm trying to figure out why my entire if statement is not working properly. What is happening when I run my form is that it puts it into the first if statement regardless of what the value of $style is and I don't know why. The other parts of the for submission works BUT my if statement. And inside of firebug it is passing the RIGHT post data so it has the correct value for style each time.

 

<?php

// Include the database page
require ('../inc/dbconfig.php');

if (isset($_POST['submitcharacter'])) {
    $charactername = mysqli_real_escape_string($dbc, $_POST['charactername']);
    $charactershortname = mysqli_real_escape_string($dbc, $_POST['charactershortname']);
    $sortorder = mysqli_real_escape_string($dbc, $_POST['sortorder']);
    $style = mysqli_real_escape_string($dbc, $_POST['style']);
    $status = mysqli_real_escape_string($dbc, $_POST['status']);
    $alignment = mysqli_real_escape_string($dbc, $_POST['alignment']);
    $division = mysqli_real_escape_string($dbc, $_POST['division']);

    $query = "INSERT INTO `characters` (charactername, charactershortname, status_id, style_id, division_id, alignment_id, sortorder, creator_id, datecreated) VALUES ('$charactername','$charactershortname','$status','$style','$division', '$alignment', '$sortorder', 1, NOW())";
    mysqli_query($dbc, $query);
    $query_id = mysqli_insert_id($dbc); 
    $query1 = "INSERT INTO `allies` (character_id) VALUES (".$query_id.")";
    mysqli_query($dbc, $query1);  
    $query2 = "INSERT INTO `rivals` (character_id) VALUES (".$query_id.")";
    mysqli_query($dbc, $query2);  
    if ($style = 1) {
        $query3 = "INSERT INTO `singles` (character_id) VALUES (".$query_id.")";
        mysqli_query($dbc, $query3);  
     } elseif ($style = 2) {
        $query4 = "INSERT INTO `tagteams` (character_id) VALUES (".$query_id.")";
        mysqli_query($dbc, $query4);
     } elseif ($style = 3) {       
        $query5 = "INSERT INTO `managers` (character_id) VALUES (".$query_id.")";
        mysqli_query($dbc, $query5);        }       
     } elseif ($style = 4) {
        $query6 = "INSERT INTO `stables` (character_id) VALUES (".$query_id.")";
        mysqli_query($dbc, $query6);  
     } elseif ($style = 5) {
        $query7 = "INSERT INTO `referees` (character_id) VALUES (".$query_id.")";
        mysqli_query($dbc, $query7);  
     } else {
        $query8 = "INSERT INTO `staff` (character_id) VALUES (".$query_id.")";
        mysqli_query($dbc, $query8);   
     }
        
?>

Link to comment
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.