SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Zealot JordanTLClive's Avatar
    Join Date
    Feb 2001
    Location
    Las Vegas, NV
    Posts
    118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi
    Im trying to output data from the bio column of a table named bios in MySQL...

    Code:
    <?
    
    // open a connection to the database
    mysql_connect($server, $user, $pass) or die("Invalid server or user");
    mysql_select_db($db);
    
    $getartistbio = mysql_query("SELECT bio FROM bios WHERE artistid='$artist'");
    if (!$getartistbio)
    {
    	echo "There was an error fetching the artist's ('$artist') biography as explained by:<br>";
    	mysql_error();
    	echo "<br><br>Please send an email to <a href=\"mailto:jordan@hotmusicstars.com?subject='$artist'+Biography+Error&body=" .
    	mysql_error() .
    	"\">jordan@hotmusicstars.com</a> with the complete error message above.";
    
    } else {
    
    echo $getartistbio;
    
    }
    ?>
    the variable $artist comes from the query string (bios.php?artist=artistnamehere)
    the output i get for that section is:
    "Resource id #2"
    (without the quotes)

    Could someone please tell me what I'm doing wrong???
    -Jordan

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You need to use something to get the data like mysql_fetch_array(). Read over the manual for that part
    http://www.php.net/mysql

    you should do
    PHP Code:
    <?

    // open a connection to the database
    mysql_connect($server$user$pass) or die("Invalid server or user");
    mysql_select_db($db);

    $getartistbio mysql_query("SELECT bio FROM bios WHERE artistid='$artist'");
    if (!
    $getartistbio)
    {
        echo 
    "There was an error fetching the artist's ('$artist') biography as explained by:<br>";
        
    mysql_error();
        echo 
    "<br><br>Please send an email to <a href="mailto:jordan@hotmusicstars.com?subject='$artist'+Biography+Error&body=" .
        mysql_error() .
        "">jordan@hotmusicstars.com</a> with the complete error message above."
    ;

    } else {
    $row mysql_fetch_array($getartistbio);
    echo 
    $row["bio"];

    }
    ?>
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    SitePoint Zealot JordanTLClive's Avatar
    Join Date
    Feb 2001
    Location
    Las Vegas, NV
    Posts
    118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK
    now I have an error at the end of the file
    Parse error: parse error in /home/hotmusic/public_html/php/bios.php on line 147

    Could someone please look at the code ( http://www.hotmusicstars.com/php/bios.txt ) I am clueless as to what to do!
    Last edited by JordanTLClive; Feb 22, 2001 at 01:50.
    -Jordan

  4. #4
    SitePoint Addict
    Join Date
    Nov 2000
    Location
    London, UK
    Posts
    223
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    simple .. I think ..
    Try it like this instead
    PHP Code:
    <?

    // open a connection to the database
    mysql_connect($server$user$pass) or die("Invalid server or user");
    mysql_select_db($db);

    $getartistbio mysql_query("SELECT bio FROM bios WHERE artistid='$artist'");
    // not too sure about that one ... probably that though ..

    if (!$getartistbio)
    {
        echo 
    "There was an error fetching the artist's ('$artist') biography as explained by:<br>";
        
    mysql_error();
        echo 
    "<br><br>Please send an email to <a href='mailto:jordan@hotmusicstars.com?subject=$artist+Biography+Error&body=" .
        
    mysql_error() .
        
    "'>jordan@hotmusicstars.com</a> with the complete error message above.";

    } else {

    echo 
    $getartistbio;

    }
    ?>

    ... what's the world coming to?

  5. #5
    SitePoint Zealot JordanTLClive's Avatar
    Join Date
    Feb 2001
    Location
    Las Vegas, NV
    Posts
    118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Check out www.hotmusicstars.com/php/bios.php
    I moved all the php stuff to the top of the file, then used <? echo $bio ?> to show the biography below. It at least shows an error now that it isnt fetching the biography from the server. Anyone? (code at www.hotmusicstars.com/php/bios.txt )
    -Jordan

  6. #6
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    First off this line should end with a semicolon

    <? echo $bio; ?>

    That is where the parse error comes.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  7. #7
    SitePoint Zealot JordanTLClive's Avatar
    Join Date
    Feb 2001
    Location
    Las Vegas, NV
    Posts
    118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think because its one line I dont have to use the semicolon (there wasnt a parse error, and there still isnt)
    Still stuck with the problem fetching info from mysql?
    -Jordan

  8. #8
    SitePoint Zealot JordanTLClive's Avatar
    Join Date
    Feb 2001
    Location
    Las Vegas, NV
    Posts
    118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    got it!

    Im not sure exactly what things were wrong because everything LOOKED right to me, but after changing a few things around it now works!

    Thanks for all the help everyone gave me
    -Jordan

  9. #9
    SitePoint Addict
    Join Date
    Nov 2000
    Location
    London, UK
    Posts
    223
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You might want to put a password on the biosupdate.php and biosadmin.php files, put the artists.txt into a non-web directory and put and index.php into that folder you link to.
    You never know, someone might just find it, and a little security never hurts...

    ... what's the world coming to?


Bookmarks

Posting Permissions

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