What am I doing wrong

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Tsongkie
Forum Newbie
Posts: 13
Joined: Sun Feb 01, 2009 6:51 pm

What am I doing wrong

Post 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.
mattpointblank
Forum Contributor
Posts: 304
Joined: Tue Dec 23, 2008 6:29 am

Re: What am I doing wrong

Post 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.
Tsongkie
Forum Newbie
Posts: 13
Joined: Sun Feb 01, 2009 6:51 pm

Re: What am I doing wrong

Post 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
Ravisankar
Forum Newbie
Posts: 9
Joined: Tue Mar 04, 2008 5:12 am

Re: What am I doing wrong

Post 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]}";
    Tsongkie
    Forum Newbie
    Posts: 13
    Joined: Sun Feb 01, 2009 6:51 pm

    Re: What am I doing wrong

    Post by Tsongkie »

    done that and still getting a blank page. pfft
    User avatar
    papa
    Forum Regular
    Posts: 958
    Joined: Wed Aug 27, 2008 3:36 am
    Location: Sweden/Sthlm

    Re: What am I doing wrong

    Post by papa »

    mysql_close($dbh>;


    See something wrong here ?

    The echo statement is also filled with parse errors.
    Last edited by papa on Tue Feb 03, 2009 7:49 am, edited 1 time in total.
    mickeyunderscore
    Forum Contributor
    Posts: 129
    Joined: Sat Jan 31, 2009 9:00 am
    Location: UK

    Re: What am I doing wrong

    Post 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);
    Tsongkie
    Forum Newbie
    Posts: 13
    Joined: Sun Feb 01, 2009 6:51 pm

    Re: What am I doing wrong

    Post by Tsongkie »

    my hero :)

    Sorry I dont have a debugger yet
    Tsongkie
    Forum Newbie
    Posts: 13
    Joined: Sun Feb 01, 2009 6:51 pm

    Re: What am I doing wrong

    Post 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);
     
    ?>
    joel24
    Forum Newbie
    Posts: 10
    Joined: Tue Feb 03, 2009 6:18 am

    Re: What am I doing wrong

    Post 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?
    Tsongkie
    Forum Newbie
    Posts: 13
    Joined: Sun Feb 01, 2009 6:51 pm

    Re: What am I doing wrong

    Post by Tsongkie »

    I want to actually delete the row. So once i reload the page, the next row shows up :)
    Post Reply