#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    San Antonio, Texas, USA
    Posts
    23
    Rep Power
    0
    I'm creating a site that lists lots of artists, I'm not quite sure how to pull stuff off the database, i wrote this script but it's not working, if anyone knows of a good tutorial on this subject please let me know. I could also use any help u got.

    index.php3?artist=1
    ======================================
    <?php


    $db = mysql_connect("localhost", "toxic");

    mysql_select_db("toxic",$db);


    $result = mysql_query($sql);

    if ($artist) {

    $sql = "UPDATE ARTIST SET ARTIST_NAME='$artistname',BIOGRAPHY='$biography',WEBSITE='$website' WHERE ARTIST_ID=$artist";

    } else {

    $sql = "INSERT INTO ARTIST (ARTIST_NAME,BIOGRAPHY,WEBSITE) VALUES ('artistname','$biography','$website')";

    }
    {
    echo "$artistname<br></font>n";
    echo "<font face=veredana size=1>$biography</font><br><br>n";

    } else {

    echo "Artist $artist not foundn";

    }

    ?>

  2. #2
  3. Senior Member
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jun 2000
    Location
    Enschede, The Netherlands
    Posts
    1,527
    Rep Power
    16
    I looked at your script for a sec and 3 things got my attention:

    1) You don't provide a password like in the following code:

    [CODE[
    $db = mysql_connect(localhost, toxic, password);
    [/CODE]

    2) You use the variable $sql before you 'described' it. I don't think that's allowed.

    3) Err.. you're not 'processing' the result:

    Take a look at Database Basics!!

    Well, success with it...

    Mirax
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    San Antonio, Texas, USA
    Posts
    23
    Rep Power
    0
    i diden't want to put up my password for the wourld to see. I really dont know much about this scripting stuff, I'm just starting. Thanks for the help, so if I fix that stuff the script will work?
  6. #4
  7. Senior Member
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jun 2000
    Location
    Enschede, The Netherlands
    Posts
    1,527
    Rep Power
    16
    Just take a look at the tutorial I mentioned. There are some examples about retrieving information from a database. If you modify some of those scripts it will work (unless you forget some of the code )
  8. #5
  9. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15
    Toxic,

    can you explain what you want to do?..

    Just i am writing an example showing how you can get the details from the database...

    -----
    use form action="post" method to pass values to the php script.. that would make your job very easy..

    <form action="somescript.php3" method="post">
    Artist :<input type="text" name="artist">
    <input type="submit" name="submit" value="submit">
    </form>
    ------

    in your php page try the following..

    <?php

    if(isset($submit)){
    // if user clicks on submit...

    $db = mysql_connect("localhost", "username","password");
    //Connection string..

    mysql_select_db("databasename",$db);
    //select your database

    $sql="select * from ARTIST where ARTIST_ID='$artist'"
    //your sql statement..


    $result = mysql_query($sql,$db);
    //issue your query..

    if (mysql_num_rows($result)>0) {
    // artist is present in the table..

    $sql = "UPDATE ARTIST SET ARTIST_NAME='$artistname',BIOGRAPHY='$biography',WEBSITE='$website' WHERE ARTIST_ID='$artist'";
    //now update it..
    echo "$artistname<br></font>n";
    echo "<font face=veredana size=1> biography</font><br><br>n";

    echo "Database updatedn";

    } else {

    echo "Artist $artist not found..so data inserted to the database..n";

    $sql = "INSERT INTO ARTIST (ARTIST_NAME,BIOGRAPHY,WEBSITE) VALUES ('artistname','$biography','$website')";
    // use insert command..
    }
    }
    else{
    echo "Error !!! you can't do thatn";
    exit;
    // user has not clicked on submit button..
    }
    ?>

    i hope this will help you to solve your problem..


    Good Luck!!



    ------------------
    SR -
    webshiju.com

    "The fear of the LORD is the beginning of knowledge..."

Similar Threads

  1. Pulling individual checkbox requests into database
    By techwreck in forum ASP Programming
    Replies: 1
    Last Post: February 17th, 2004, 12:06 PM
  2. mail() ... pulling my freakin hair out !!!
    By grfxguru in forum PHP Development
    Replies: 13
    Last Post: January 29th, 2004, 03:54 AM
  3. Replies: 5
    Last Post: May 20th, 2002, 05:51 PM
  4. Replies: 0
    Last Post: August 9th, 2001, 07:18 AM
  5. error pulling dates from table
    By mstembri in forum PHP Development
    Replies: 2
    Last Post: June 25th, 2001, 02:23 PM

IMN logo majestic logo threadwatch logo seochat tools logo