Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: Q and A page

  1. #1
    New to the CF scene
    Join Date
    Jun 2013
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Angry Q and A page

    Hello, I am currently creating a questions and answers page, and I have so far created a couple of databases, and partly the answers page and question page, however when I try to do the delete page, I can't get the "select" feature to work, and I don't know why.Could someone please tell me what I've done wrong with this code, and how to correct it, as I've spent ages on it, and I'm just getting more and more confused?

    What I want, is to get the select feature working properly down the bottom, so it selects the id of "14" from the database (Just for the moment until I'm ready to do the rest)

    (obviously this is only a snippet of the code itself)


    <tr><th><input class="ask" onClick="parent.location='index.php' "type="submit" name="submitBtn" form action="<?php echo $_SERVER['PHP_SELF']; ?>" value="Delete" /><td><FORM>
    <INPUT TYPE="button" class="ask" value="Cancel" onClick="parent.location='index.php'">
    </FORM>The Selected Question is laid out below:</td></tr>

    </tr>
    <td><tr><?php while ($row = $MyDb->f_GetRecord($result)) { }?><?php$sql = "SELECT *
    FROM guestbook
    WHERE id=14";?></td></tr>

    Thanks, Chris

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,028
    Thanks
    75
    Thanked 4,325 Times in 4,291 Posts
    I can't make any sense out of that.

    What is the point of your $sql variable? You never use it.

    Where does $result come from? You didn't bother to show that.

    And this makes me really nervous:
    ... so far created a couple of databases...
    Why would you need more than one database??? Multiple tables, perhaps. Likely, even. But multiple databases????
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    All you've done is create a text string. You need to send it to mysql as a query, using PHP's mysql_query() function.

    HTH
    Dan
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,028
    Thanks
    75
    Thanked 4,325 Times in 4,291 Posts
    Excepting, of course, the mysql_query() is obsolete. Need to move to mysqli functions ASAP.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •