31 users online (1 members and 30 guests)  


  Results 1 to 3 of 3

Related

  1. perl in debug mod    Forum: CGI Perl Forum
    Replies: 0
  2. insert pages into a table?    Forum: HTML Forum
    Replies: 6
  3. Insert a wav file    Forum: HTML Forum
    Replies: 3
  4. Insert page in a table?    Forum: HTML Forum
    Replies: 5
  5. Replies: 2
  1. #1
    darkdirk1's Avatar
    New User

    Status
    Offline
    Join Date
    Oct 2005
    Posts
    5

    this insert row keeps failing please help debug.

    My opendb() function is succeeding (I have notifiers that let me know it opens the db fine.) It throws the "error adding record" message....It's probably some simple syntax thing but I don't see it.
    Also I know my variables are posting because the addRecord() func is called after a valid check on the POST vars passes..........

    PHP Code:
    function addRecord(){
    $caseNum $_POST['case'];
    $group $_POST['group'];
    $userId $_POST['uid'];
    $notes $_POST['notes'];
    $date date('YmdHis');
    $table "invalids";
    openDB();
    $addRow_q "INSERT INTO $table (caseNum, group, userId, notes, date) VALUES ('$caseNum', '$group', '$userId', '$notes', '$date')"
    $result mysql_query($addRow_q$connection);
    if (
    $result) {echo '<font color=green>success record added!';} else {echo '<font color=red>error adding record!';}

    Thank you for lending me your eyes and brains!!!

  2. #2
    vinyl-junkie's Avatar
    Moderator

    Status
    Offline
    Join Date
    Sep 2005
    Posts
    721

    Re: this insert row keeps failing please help debug.

    Try adding:
    Code:
    die($addRow_q);
    just after you assign a value to it. Does anything look out of place or incorrect? That should show you what you're doing wrong.
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more

  3. #3
    DeadMeatGF's Avatar
    Moderator

    Status
    Offline
    Join Date
    Sep 2005
    Posts
    381

    Re: this insert row keeps failing please help debug.

    Possibly the line
    Code:
    openDB();
    is the problem - I assume it's a user function to open your database?
    If so, try using
    Code:
    $result = mysql_query($addRow_q, $GLOBALS['connection']);
    as it looks like the script has no idea what $connection is ...
    Alternatively, have the resource returned from the function (I've had difficulties doing that, although I think that's down to inexperience) e.g.
    Code:
    $connection = openDb();
    $addRow_q = "INSERT INTO $table (caseNum, group, userId, notes, date) VALUES ('$caseNum', '$group', '$userId', '$notes', '$date')"; 
    $result = mysql_query($addRow_q, $connection);
    ...



Tags for this Thread