Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 19
  1. #1
    Senior Member
    Join Date
    Nov 2013
    Posts
    146
    Member #
    37737
    Liked
    15 times

    Something just wnet HORRIBLY wrong!

    wdf-randomstuff.jpg

    I was testing the code to close the ticket and now everywhere on every page of the project there are random letters and numbers all over the code...

    I don't understand why?

    full size image: http://i.imgur.com/juoWbpm.png

    close button code

    PHP Code:
    <p><a href="<?=$_SERVER['PHP_SELF']?>?tid=<?php echo $_GET['tid']; ?>&amp;close=1"><button type="button" class="btn btn-default">Close Ticket</button></a></p>
    close ticket code

    PHP Code:
    if (isset($_GET['close'])) {
        
    $viewcloseticketsql="UPDATE tickets SET status = ('<span class=\"label label-default\">Closed</span>') WHERE tid = '$tid'";
        
    $mysqli->query($viewcloseticketsql);  
        echo 
    "<div class=\"alert alert-warning\" role=\"alert\">Ticket closed!</div>";

    Last edited by noodles415; Sep 02nd, 2014 at 09:08 AM.

  2.  

  3. #2
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,865
    Member #
    5580
    Liked
    731 times
    I can't troubleshoot your code without seeing the entire script, but I will say this ....

    Your column called 'status' should just be a code of some kind ... example: 1
    0 (or nothing) means it is opened, and when you close it, just write (set) that column to a 1

    When you display your page and query the "status" column, you let PHP alter the HTML based on the status 'code'.

    Example:

    ... query happens to get all columns for a given row ...

    then output the HTML depending on the value of 'status' ...

    PHP Code:
    if($result['status']==1){
    echo 
    "<span class=\"label label-default\">Closed</span>";
    }
    else{
    echo 
    "<span class=\"label label-default\">Not Closed</span>";



    If you are doing other things like that throughout your script, I would assume you're writing strange binary ascii values into a column of the wrong type.


  4. #3
    Senior Member
    Join Date
    Nov 2013
    Posts
    146
    Member #
    37737
    Liked
    15 times
    Quote Originally Posted by mlseim View Post
    I can't troubleshoot your code without seeing the entire script, but I will say this ....

    Your column called 'status' should just be a code of some kind ... example: 1
    0 (or nothing) means it is opened, and when you close it, just write (set) that column to a 1

    When you display your page and query the "status" column, you let PHP alter the HTML based on the status 'code'.

    Example:

    ... query happens to get all columns for a given row ...

    then output the HTML depending on the value of 'status' ...

    PHP Code:
    if($result['status']==1){
    echo 
    "<span class=\"label label-default\">Closed</span>";
    }
    else{
    echo 
    "<span class=\"label label-default\">Not Closed</span>";



    If you are doing other things like that throughout your script, I would assume you're writing strange binary ascii values into a column of the wrong type.
    Ooh, you couldn't just let me be lazy :'( that's a really good idea though. I'm going to fix that now, I see how I could be scrwing things up! Either way the issue seems to have resolved itself.

    I do see that I could do the if/else with 0/1 but I want to have a lot of statuses

    0 = closed
    1 = open
    2 = answered
    3 = in progress
    4 = escalated for management review

    Actually preferably it could reference a seperate database table that i set up for this, so i can add/remove/edit status whenever i feel like it from the admin area of my system...

    so I'm not sure how I would code this since i have more than once option. Could you please point me in the right direction for this? thank you, i really appreciate it!
    Last edited by noodles415; Sep 02nd, 2014 at 07:34 PM.

  5. #4
    Junior Member Jetstorm's Avatar
    Join Date
    Aug 2014
    Posts
    22
    Member #
    39972
    You can use a switch statement for multiple options.
    You can read about it here PHP: switch - Manual
    On that page there's also an example how to use multiple options with if...elseif if you don't like the switch idea.

  6. #5
    Senior Member
    Join Date
    Nov 2013
    Posts
    146
    Member #
    37737
    Liked
    15 times
    Quote Originally Posted by Jetstorm View Post
    You can use a switch statement for multiple options.
    You can read about it here PHP: switch - Manual
    On that page there's also an example how to use multiple options with if...elseif if you don't like the switch idea.
    Okay, I get how the switch statements works, but how would I incporated that with data from the MySQL database?

  7. #6
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,865
    Member #
    5580
    Liked
    731 times
    I see what you're doing now ...

    Make your 'status' column a 'text type' column and enter the words you showed me as your status ...

    closed
    open
    answered
    in progress
    escalated for management review

    You can use those words instead of 'code numbers' as I suggested.

    My point is to NOT use HTML as the text in your database tables.

    When the row is queried, whatever text is in the 'status' column can be displayed as the status.

    You will still need to use logic in your PHP to decide what happens when a particular status is active.

    If the status is "closed", you don't want want the user to be able to "escalate" it ... since it's already closed.
    That type of logic would be handled by your PHP script.


  8. #7
    Senior Member
    Join Date
    Nov 2013
    Posts
    146
    Member #
    37737
    Liked
    15 times
    Quote Originally Posted by mlseim View Post
    I see what you're doing now ...

    Make your 'status' column a 'text type' column and enter the words you showed me as your status ...

    closed
    open
    answered
    in progress
    escalated for management review

    You can use those words instead of 'code numbers' as I suggested.

    My point is to NOT use HTML as the text in your database tables.

    When the row is queried, whatever text is in the 'status' column can be displayed as the status.

    You will still need to use logic in your PHP to decide what happens when a particular status is active.

    If the status is "closed", you don't want want the user to be able to "escalate" it ... since it's already closed.
    That type of logic would be handled by your PHP script.
    well its complicated because i want the fancy bootstrap labels youk now? otherwsie yeah that would work just fine. clients open tickets from the open tickets page. they can close tickets any time. adding a reply after closing ticket would set it open again
    only from admin side would other status be available
    if admin/staff answers it would be set to answered. admin could also set in progress or management review client would never need to do that

    i'm not going to work on my program tonight because i am depressed i wont get anything done i am angry at myself right now i had a tough day and i don't want to get more angry. i'll check in once i've figured out the status. thanks again for the help i really appreciate you taking the time to help me learn along the way for free. im' glad i'm not getting paid for this and i have no deadline on it, just making it to learn, but i feel so useless and helpless not just in php/mysql but in my day job and company too... ok i'm going to sign off before i rant on here.

    all the best and good night
    Last edited by noodles415; Sep 03rd, 2014 at 10:28 PM.

  9. #8
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,865
    Member #
    5580
    Liked
    731 times
    OK ...
    I don't know you or your life situation, but you're taking the time to learn scripting ... but it's just scripting. You should not take it quite so seriously.

    It seems like you may have started-out with a scripting project that might be a bit more advanced than a typical person might take-on when learning PHP.

    Take a step-back and look at some of the positive things you've accomplished ... what you know now, that you didn't know before. You learn something new everyday.


  10. #9
    Senior Member
    Join Date
    Nov 2013
    Posts
    146
    Member #
    37737
    Liked
    15 times
    Quote Originally Posted by mlseim View Post
    OK ...
    I don't know you or your life situation, but you're taking the time to learn scripting ... but it's just scripting. You should not take it quite so seriously.

    It seems like you may have started-out with a scripting project that might be a bit more advanced than a typical person might take-on when learning PHP.

    Take a step-back and look at some of the positive things you've accomplished ... what you know now, that you didn't know before. You learn something new everyday.
    Nah, yesterday had nothing to do with PHP/MySQL Just had a crappy day. Today is better - I'll be working on this tonight.

  11. #10
    Senior Member
    Join Date
    Nov 2013
    Posts
    146
    Member #
    37737
    Liked
    15 times
    Quote Originally Posted by mlseim View Post
    I see what you're doing now ...

    Make your 'status' column a 'text type' column and enter the words you showed me as your status ...

    closed
    open
    answered
    in progress
    escalated for management review

    You can use those words instead of 'code numbers' as I suggested.

    My point is to NOT use HTML as the text in your database tables.

    When the row is queried, whatever text is in the 'status' column can be displayed as the status.

    You will still need to use logic in your PHP to decide what happens when a particular status is active.

    If the status is "closed", you don't want want the user to be able to "escalate" it ... since it's already closed.
    That type of logic would be handled by your PHP script.
    Alright, so here is my switch statement. I tested to make sure $status was correct by echo'ing it and it was fine so I know that is not the problem. My problem now is that both Open and Closed are displayed at the same time though it should really only be showing one of them at a time.

    PHP Code:
    $status $row['status'];

      switch (
    $status) {
        case 
    0:
            echo 
    "<td><span class=\"label label-default\">Closed</span></td>";
        case 
    1:
            echo 
    "<td><span class=\"label label-success\">Open</span></td>";
      } 


Page 1 of 2 1 2 LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 07:04 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com