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 17
  1. #1
    Senior Member
    Join Date
    Aug 2011
    Posts
    217
    Member #
    29153
    Liked
    4 times
    $result = mysql_query("SELECT * FROM subjects WHERE userid = '$user'");
    if (!$result) {
    echo "You have not added any subjects yet.";
    }



    There is nothing in the table subjects so it should give me the message. But it doesn't.

    It was working but seems to have stopped without my doing anything to it.

  2.  

  3. #2
    Senior Member Zboost's Avatar
    Join Date
    Apr 2011
    Location
    Houston
    Posts
    246
    Member #
    27459
    Liked
    20 times
    Could you post more of the code, or is that it? I don't see why it should not work.

  4. #3
    Senior Member
    Join Date
    Aug 2011
    Posts
    217
    Member #
    29153
    Liked
    4 times
    Quote Originally Posted by Zboost, post: 222686
    Could you post more of the code, or is that it? I don't see why it should not work.
    <span class="heading">Subjects</span>

    <?php
    $con = mysql_connect("myconnect","mydb","mypw");
    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }

    mysql_select_db("studyquestion", $con);


    $result = mysql_query("SELECT * FROM subjects WHERE userid = '$user'");
    if (!$result) {
    echo "You have not added any subjects yet.";
    }
    else {
    while ($row = mysql_fetch_array($result)) {
    $subject = $row['subject'];
    echo "<a href=\"topics.php?subject=$subject\">", $row['subject'], "</a><br>";
    }
    }

    ?>

    The only thing I changed was the connection info.

  5. #4
    Senior Member
    Join Date
    Aug 2011
    Posts
    217
    Member #
    29153
    Liked
    4 times
    I did add a php.ini and .htaccess. These had in them,

    Quote Originally Posted by php.ini
    register_globals = On
    Quote Originally Posted by .htaccess
    SuPHP_ConfigPath /home/acc_username/public_html/php.ini

  6. #5
    Senior Member Zboost's Avatar
    Join Date
    Apr 2011
    Location
    Houston
    Posts
    246
    Member #
    27459
    Liked
    20 times
    Is the problem that it says there is no subjects when there is data there? Where is $user being defined?

  7. #6
    Senior Member
    Join Date
    Aug 2011
    Posts
    217
    Member #
    29153
    Liked
    4 times
    Quote Originally Posted by Zboost, post: 222690
    Is the problem that it says there is no subjects when there is data there? Where is $user being defined?
    The page that calls this page in an include defines it

    $user = $_SESSION['username'];

  8. #7
    Senior Member
    Join Date
    Aug 2011
    Posts
    217
    Member #
    29153
    Liked
    4 times
    Under the else clause, I added:

    echo "went to 'else'";

    When I ran the page, I get the message. It's not reading the if parameters for some reason.

  9. #8
    Senior Member Zboost's Avatar
    Join Date
    Apr 2011
    Location
    Houston
    Posts
    246
    Member #
    27459
    Liked
    20 times
    Is it calling the user Id or the username. So I would assume userid would != username which is what I see it trying to do.

  10. #9
    Senior Member
    Join Date
    Aug 2011
    Posts
    217
    Member #
    29153
    Liked
    4 times
    Quote Originally Posted by Zboost, post: 222694
    Is it calling the user Id or the username. So I would assume userid would != username which is what I see it trying to do.
    If I echo $user I get the username. If I add some subjects, I get the subjects. If I delete them I should, get the message that there are no subjects. Instead I get a blank message since there is nothing to execute in the else.

  11. #10
    Senior Member Zboost's Avatar
    Join Date
    Apr 2011
    Location
    Houston
    Posts
    246
    Member #
    27459
    Liked
    20 times
    So then the userid is the users name or a string not an int which an userid usually would be. I just assumed. Im on my phone so im just making ideas I can't test lol.


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 10:09 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com