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 14 of 14
  1. #1
    THM
    THM is offline
    New Coder
    Join Date
    Jun 2006
    Location
    Philladelphia
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    MYSQL database not loading, and stopping general page from loading!

    PHP Code:
    <?PHP
    include("$connect");

    $sql "SELECT * FROM `TABLE_pm` WHERE touser = '".$_SESSION['username']."' LIMIT 0 , 30";
    while (
    $r mysql_query($sql))

    $to $r['touser'];
    $from $r['fromuser'];
    $subject $r['subject'];
    $date $r['date'];
    $msg $r['message'];

    echo 
    "$to";

    ?>
    any ideas on whats wrong? Its not only that it won't work, but the page won't even load with this code in there. Is there something I'm doing drastically wrong? Please get back to me on your own time, when its good for you. Thank you.

    Ok, new way of it loading. NOW its trying to get me to download the page.
    Last edited by THM; 11-28-2006 at 01:26 AM. Reason: PHP tags

  • #2
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,746
    Thanks
    18
    Thanked 155 Times in 146 Posts
    Can you post the exact error message that you are getting?
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!

  • #3
    THM
    THM is offline
    New Coder
    Join Date
    Jun 2006
    Location
    Philladelphia
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It is not an error message, its just either taking forever to load, or trying to get me to download it. It seems to be the while tag, so i'm wondering if their is another way to do this besides that?

  • #4
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,746
    Thanks
    18
    Thanked 155 Times in 146 Posts
    Post the full code then...

    and you're missing opening and closing brackets for your while loop:

    <?PHP
    include("$connect");

    $sql = "SELECT * FROM `TABLE_pm` WHERE touser = '".$_SESSION['username']."' LIMIT 0 , 30";
    while (
    $r = mysql_query($sql))
    {
    $to = $r['touser'];
    $from = $r['fromuser'];
    $subject = $r['subject'];
    $date = $r['date'];
    $msg = $r['message'];

    echo
    "$to";

    }

    ?>

    Edit: Also, wild guess, you might be having problems withthis line:

    include("$connect");

    Try substituting $connect with the actual file/path name, like this:

    include '/path/file.php';
    Last edited by chump2877; 11-28-2006 at 01:35 AM.
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!

  • #5
    THM
    THM is offline
    New Coder
    Join Date
    Jun 2006
    Location
    Philladelphia
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    it is an actual directory, i just don't want to post it on here because.. well, i've heard you should give as little as you can, by replacing with variables and such.

    Also, I am going to try that. I'll see if it works.

    UPDATE
    Nope, It didn't work. Its making me try and download it again. And that is the full code for now, I am just starting but i want to get the tables working right first.
    Last edited by THM; 11-28-2006 at 01:55 AM.

  • #6
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,746
    Thanks
    18
    Thanked 155 Times in 146 Posts
    Quote Originally Posted by THM View Post
    it is an actual directory
    you can;t include an entire directory in a PHP file.

    the format is:

    PHP Code:
    include 'file.php'
    or

    PHP Code:
    include '/path/file.php'
    where "path" IS a directory.

    Edit: Also post the code in your database connection script (the file represented by $connect in your code)
    Edit: And another thing i just noticed, you are missing session_start() at the very top of your file, i.e.:

    <?PHP
    session_start();
    include("$connect");
    Edit: LOL, and....don;t use an upper case 'php'...don;t know if that's allowable...i.e.:

    <?php
    session_start();
    include("$connect");
    Last edited by chump2877; 11-28-2006 at 02:44 AM.
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!

  • #7
    THM
    THM is offline
    New Coder
    Join Date
    Jun 2006
    Location
    Philladelphia
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    PHP Code:
    include("sql/connect2.php"); 

    Thats what i have. As i said, It is correct there.. I use that code for all of them.
    Its not that which is causing these.. "errors". I'm not sure what it is, its JUST this table that does this. Maybe I should redo the table?

  • #8
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,746
    Thanks
    18
    Thanked 155 Times in 146 Posts
    See my "Edits" in my previous post...
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!

  • #9
    THM
    THM is offline
    New Coder
    Join Date
    Jun 2006
    Location
    Philladelphia
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    All my PHPs are capitalized in my scripts, which work.
    The connect thing, i've never used.

    But, I did try it. Still, no luck. It just keeps loading and loading forever and ever. lol.

    Any more ideas? Thanks for your help so far.

  • #10
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    2,958
    Thanks
    2
    Thanked 304 Times in 296 Posts
    The while loop is a "forever" loop. The following line will just keep executing the query. As long as the query does not return a false, the while loop will keep looping... forever... (or until the web server/php script reaches its maximum time limit) -
    PHP Code:
    while ($r mysql_query($sql)) 
    After you form the query string, you need to execute the query once, with error checking and reporting, then fetch results in your while loop -
    PHP Code:
    $result mysql_query($sql) or die('Query failed: ' mysql_error());
    while (
    $r mysql_fetch_assoc($result))
    {
    ...

    Getting PHP to tell you all the errors when debugging will help. Put the following line in after your first opening PHP tag -
    PHP Code:
    error_reporting(E_ALL); 
    Last edited by CFMaBiSmAd; 11-28-2006 at 05:03 AM.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #11
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    2,958
    Thanks
    2
    Thanked 304 Times in 296 Posts
    i just don't want to post it on here because.. well, i've heard you should give as little as you can, by replacing with variables and such.
    By all means, xxxxxx out any sensitive information such as passwords/usernames... and your domain if you don't want that to be made public, but don't edit anything that would modify the intent and function of the actual code when you post it. Doing so just creates wild goose chases by people trying to solve apparent problems that are not really present.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #12
    THM
    THM is offline
    New Coder
    Join Date
    Jun 2006
    Location
    Philladelphia
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you guys SOOO much. Its working now. You're help was greatly appreciated.

    Well, thanks to you my PM system will be up and running shortly. THANK YOU AGAIN!



    Heres, my last question in this topic :

    PHP Code:
    <?php
    include('XXXXX");

    $sql = "SELECT * FROM `XXXXX_pm` WHERE touser = '
    Johnn' ORDER BY 'date' ASC LIMIT 0 , 30";

    $result = mysql_query($sql) or die('
    Query failed' . mysql_error());
    while ($r = mysql_fetch_assoc($result)) 

    {
    $id = $r['
    id'];
    $from = $r['
    fromuser'];
    $subject = $r['
    subject'];
    $date = $r['
    date'];
    $msg = $r['
    message'];

    }

    $rowC = ($rowC=='
    row1' ? 'row2' : 'row1');
    echo("<table width='
    470' cellpadding='0' cellspacing='0' class='PM'>");
    echo("<tr class='
    header'><td>FROM</td><td>SUBJECT</td><td>DATE</td></tr> ");
    echo("<tr class='
    $rowC>");
    echo("
    <td>$from</td>");
    echo("
    <td>$subject</td>");
    echo("
    <td>$date</td>");
    echo("
    </tr>");
    echo("
    </table>");
    echo("
    <br />");
    ?>
    How would I make it repeat the table foreach of the tables?
    Last edited by THM; 11-29-2006 at 03:14 AM. Reason: question

  • #13
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,746
    Thanks
    18
    Thanked 155 Times in 146 Posts
    I think you just want to include your HTML table code inside the while loop:

    PHP Code:
    <?php
    include('XXXXX");

    $sql = "SELECT * FROM `XXXXX_pm` WHERE touser = '
    Johnn' ORDER BY 'date' ASC LIMIT 0 , 30";

    $result = mysql_query($sql) or die('
    Query failed' . mysql_error());
    while ($r = mysql_fetch_assoc($result)) 

    {
    $id = $r['
    id'];
    $from = $r['
    fromuser'];
    $subject = $r['
    subject'];
    $date = $r['
    date'];
    $msg = $r['
    message'];

    $rowC = ($rowC=='
    row1' ? 'row2' : 'row1');
    echo("<table width='
    470' cellpadding='0' cellspacing='0' class='PM'>");
    echo("<tr class='
    header'><td>FROM</td><td>SUBJECT</td><td>DATE</td></tr> ");
    echo("<tr class='
    $rowC>");
    echo("
    <td>$from</td>");
    echo("
    <td>$subject</td>");
    echo("
    <td>$date</td>");
    echo("
    </tr>");
    echo("
    </table>");
    echo("
    <br />");
    }
    ?>
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!

  • #14
    THM
    THM is offline
    New Coder
    Join Date
    Jun 2006
    Location
    Philladelphia
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yupperrs!

    Sure did work. THANKS!


  •  

    Posting Permissions

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