#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Quispamsis, NB, Canada
    Posts
    49
    Rep Power
    15
    I have made a script to add people to a DB who will be linking to my site, but it doesn't add to the DB or assign an ID number. below is the MySQL part of the form and the table dump for MySQL. Can someone please skim through this and try to find my problem. Thanks in advance!:
    PHP:
    mysql_query("INSERT INTO refcount (refwebname,
    refuser, refpass, refemail, refweburl) VALUES ('$refwebname','$refuser','$refpass','$refemail','','$refweburl')");
    $query = "select * from refcount where refweburl = '$refweburl'";
    $mysql_result = mysql_query($query);
    while ($row = mysql_fetch_row($mysql_result))
    {
    $id = $row[0];
    $refwebname = $row[1];
    $refuser = $row[2];
    $refpass = $row[3];
    $refemail = $row[4];
    $refcount = $row[5];
    $refweburl = $row[6];
    }

    MySQL:
    CREATE TABLE refcount (
    id int(9) NOT NULL auto_increment,
    refwebname varchar(255),
    refuser varchar(15) NOT NULL,
    refpass varchar(15),
    refemail varchar(255),
    refcount int(7),
    refweburl varchar(255),
    PRIMARY KEY (id),
    UNIQUE id (id, refuser)
    );

    Thanks,
    Scott Lee
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2000
    Posts
    669
    Rep Power
    15
    I am assuming your second query is to get the values that you just inserted, so you probably don't need it, if you are trying to test to see if the record was added, then use this

    $result = mysql_query("INSERT INTO refcount (refwebname,
    refuser, refpass, refemail, refweburl) VALUES ('$refwebname','$refuser','$refpass','$refemail','','$refweburl')");
    if (mysql_affected_rows($result) > 0) {
    print "Record added";
    }
    else {
    print "Error adding record";
    }
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Quispamsis, NB, Canada
    Posts
    49
    Rep Power
    15
    Now i get an error:
    Warning: 0 is not a MySQL link index in /home/mp3findit/mp3findit.com/public_html/addlink.php3 on line 11
    Error adding record

    The line with the error is:
    if (mysql_affected_rows($result) > 0) {

    If anyone can help me I would really apprechiate help as fast as possable, I can be contacted through ICQ at 17259319.

    Thanks,
    Scott Lee
  6. #4
  7. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,648
    Rep Power
    4493
    A good thing to try whenever MySQL doesn't seem to work is mysql_error();

    After the line where you INSERT, put

    echo mysql_error();

    That should give you a better idea of what the problem is.

    ---John Holmes...
  8. #5
  9. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,648
    Rep Power
    4493
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by mp3findit:
    PHP:
    mysql_query("INSERT INTO refcount (refwebname,
    refuser, refpass, refemail, refweburl) VALUES ('$refwebname','$refuser','$refpass','$refemail','','$refweburl')");
    $query = "select * from refcount where
    [/quote]

    Oh, I see your problem. You don't specify refcount in your insert list, put then you try to insert a blank value for it. The count doesn't match up. Try this:

    mysql_query("INSERT INTO refcount (refwebname,refuser,refpass,refemail,refweburl) VALUES ('$refwebname','$refuser','$refpass','$refemail','$refweburl')");

    Hope that helps...

    ---John Holmes...
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Quispamsis, NB, Canada
    Posts
    49
    Rep Power
    15
    Yeah that was my problem, thanks man! i apprechiate all the help from everyone =)

Similar Threads

  1. How to add fonts
    By L1nux in forum MySQL Help
    Replies: 0
    Last Post: February 14th, 2004, 01:42 AM
  2. Getting database info based on db info
    By Zamees in forum PHP Development
    Replies: 3
    Last Post: February 2nd, 2004, 09:55 PM
  3. add text to column
    By xyfix in forum Visual Basic Programming
    Replies: 0
    Last Post: January 27th, 2004, 06:52 PM
  4. Replies: 2
    Last Post: January 14th, 2004, 06:07 PM
  5. Replies: 4
    Last Post: January 14th, 2004, 06:22 AM

IMN logo majestic logo threadwatch logo seochat tools logo