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 5 of 5

Thread: PHP / MySQL

  1. #1
    Regular Coder the-dream's Avatar
    Join Date
    Mar 2007
    Location
    Northamptonshire, UK
    Posts
    477
    Thanks
    8
    Thanked 4 Times in 4 Posts

    PHP / MySQL

    Hey Guys!

    I cannot get my code to work, I don't get any errors! I'm sure its some really simple but I just can't spot it!

    PHP Code:
    <?php
    include('includes/dbconnect.php');
    $user $_SESSION['MM_Username'];

    if(isset(
    $_GET['del'])) {
    $del_id $_GET['del'];
    mysql_query("UPDATE favs SET user = '' WHERE id = '$del_id' AND user = '$user'") or die('<div class="passbad">Sorry there was an error!</div>');
    echo 
    '<div class="addfav">The selected favorite was successfully deleted! <a href="favs.php">Close</a>!</div><br />';
    }

    $result mysql_query("SELECT * FROM favs WHERE user = '$user' ORDER BY title ASC") or die('<div class="passbad">Sorry there was an error!</div>');
     echo 
    '<div class="bb">';
    while(
    $row mysql_fetch_array($result)) {
    echo 
    '<div class="itemcontianer" style="border-left: #333333 1px solid; border-right: #333333 1px solid;">
     <table cellpadding="0" cellspacing="0" width="780">
         <tr>
             <td>
                 <div class="itemtitle"0>
                     <a href="'
    .$row['url'].'">'.$row['title'].'</a>
                 </div>
                 
                 <div class="itemdescription">
                     '
    .$row['description'].'
                 </div>
         </div>
         </td>
         <td align="right" valign="middle">
         <div align="right">
         <a href="favs.php?del='
    .$row['id'].'" return false;" class="menulink"><img src="images/del.gif" border="0" /></a>&nbsp;&nbsp;&nbsp;&nbsp;</div></td></tr></table></div>';
    }
    echo 
    '</div>';

    ?>
    Thanks,
    ~ Christian

  • #2
    Banned
    Join Date
    Feb 2008
    Location
    Winnipeg, Canada
    Posts
    396
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Well I don't see a SESSION_START() but you are using session variables...

  • #3
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    I cannot get my code to work, I don't get any errors!
    Code:
    Doctor, doctor. I'm sick, please fix me!
    Versus.

    Code:
    Doctor, my leg stopped moving. Please make it move again.

  • #4
    Regular Coder
    Join Date
    Aug 2002
    Location
    Oregon, United States of America
    Posts
    882
    Thanks
    1
    Thanked 9 Times in 9 Posts
    aedrin is trying to be funny, but what I think he is trying to say, is that even without errors, you can still tell us what it is supposed to do, and what it is/isn't doing instead.

    Errors may be turned off, but the things I see are these:
    (As mentioned,) You are using SESSION variables without starting the session.
    You are not verifing that your query worked before you try to use it. Try this:
    PHP Code:
    while($result && mysql_num_rows($result)>=&& $row mysql_fetch_array($result)) 
    If I'm postin here, I NEED YOUR HELP!!

  • #5
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    aedrin is trying to be funny
    While I was trying to insert some humor, I was hoping the-dream would figure out what I was saying by himself. He's been around for quite a while, but still makes the same mistakes as newcomers make (untested queries...).


  •  

    Posting Permissions

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