Page 1 of 1

What am I doing wrong

Posted: Tue Feb 03, 2009 7:15 am
by Tsongkie
pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.


Here's my php code:

Code: Select all

<?php
 
$dbh=mysql_connect ("localhost", "flipsoft_tsongki",
"muncher") or die('Cannot connect to the database because: ' . mysql_error());
 
mysql_select_db ("flipsoft_esubmit");
 
$query  = "SELECT number, gender, givenname,middleinitial, surname, streetaddress FROM fakenames";
 
$result = mysql_query($query);
 
$row = mysql_fetch_row($result);
 
echo "Name $row[0]".
     $row[1]
     $row[2]    
     $row[3]
     $row[4]
     $row[5];
 
mysql_close($dbh>;
 
?>
And nothing is showing up. Sorry, I'm new.


pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.

Re: What am I doing wrong

Posted: Tue Feb 03, 2009 7:17 am
by mattpointblank
Try changing:

$result = mysql_query($query);

to

$result = mysql_query($query) or die(mysql_error());

This will display whatever error the MySQL server encountered. Start there.

Re: What am I doing wrong

Posted: Tue Feb 03, 2009 7:23 am
by Tsongkie
I changed that, and saved the code in index.php

when i go to the site mydomain.com/folder/index.php i only get a blank page

Re: What am I doing wrong

Posted: Tue Feb 03, 2009 7:37 am
by Ravisankar
    use this.
    $result = mysql_query($query,$dbh);

    instead of this.
    $result = mysql_query($query);


    and

    Do this

    echo "Name {$row[0]}";
    echo "Name {$row[1]}";
    echo "Name {$row[2]}";

    Re: What am I doing wrong

    Posted: Tue Feb 03, 2009 7:47 am
    by Tsongkie
    done that and still getting a blank page. pfft

    Re: What am I doing wrong

    Posted: Tue Feb 03, 2009 7:48 am
    by papa
    mysql_close($dbh>;


    See something wrong here ?

    The echo statement is also filled with parse errors.

    Re: What am I doing wrong

    Posted: Tue Feb 03, 2009 7:48 am
    by mickeyunderscore
    If that is your exact code then I think your problem is the syntax errors which would cause your script to die with an internal server error if your server is configured that way. try:

    Code: Select all

    echo "Name " . $row[0] . '<br />' .
         $row[1] . '<br />' .
         $row[2] . '<br />' .
         $row[3] . '<br />' .
         $row[4] . '<br />' .
         $row[5];
     
    mysql_close($dbh);

    Re: What am I doing wrong

    Posted: Tue Feb 03, 2009 7:52 am
    by Tsongkie
    my hero :)

    Sorry I dont have a debugger yet

    Re: What am I doing wrong

    Posted: Tue Feb 03, 2009 7:54 am
    by Tsongkie
    Ok so I have this code that is completely working, now how can i delete that row so that the next time i reload the page i get the next row in the database? :)

    Thanks a lot!!!

    Code: Select all

     
    <?php
     
    $dbh=mysql_connect ("localhost", "flipsoft_tsongki",
    "muncher") or die('Cannot connect to the database because: ' . mysql_error());
     
    mysql_select_db ("flipsoft_esubmit");
     
    $query  = "SELECT number, gender, givenname,middleinitial, surname, streetaddress FROM fakenames";
     
    $result = mysql_query($query,$dbh);
     
    $row = mysql_fetch_row($result);
     
    echo $row[0] . '<br />' .
    $row[1] . '<br />' .
    $row[2] . '<br />' .
    $row[3] . '<br />' .
    $row[4] . '<br />' .
    $row[5];
     
     
     mysql_close($dbh);
     
    ?>

    Re: What am I doing wrong

    Posted: Tue Feb 03, 2009 7:59 am
    by joel24
    Tsongkie wrote:Ok so I have this code that is completely working, now how can i delete that row so that the next time i reload the page i get the next row in the database? :)
    do you want to actually delete the rows?
    or do you want to display one row, then click next, and have the next row in the DB show up?

    Re: What am I doing wrong

    Posted: Tue Feb 03, 2009 8:54 am
    by Tsongkie
    I want to actually delete the row. So once i reload the page, the next row shows up :)