User Profile

Collapse

Profile Sidebar

Collapse
mjb24v
mjb24v
Last Activity: Aug 26 '10, 01:49 PM
Joined: Jul 21 '10
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • Sorry, things have got a bit out of hand! The data does not seem to be inserted. There's no error returned by mysql_query(), and the syntax of the query appears to be valid.

    The red herring was probably that select I was trying right after inserting the record - this appeared to return the inserted data, but in actual fact, it was not being inserted (mysql_affected _rows = -1).

    I've even tried re-writing thwe query suing...
    See more | Go to post

    Leave a comment:


  • Indeed - the select was a test to see what was going on. It's no longer in the code....
    See more | Go to post

    Leave a comment:


  • And the complete display code:

    Code:
    $query = mysql_query("INSERT INTO `my_db`.`user_collection` (`id`, `user_id`, `title`, `date_created`, `public`, `active`) VALUES (NULL, '".$_SESSION['username']."', '".$new_collection."', $now, '0', '1')");
    if (!$query) doError("There was an error creating the collection [86]. ".mysql_error()); 
    $new_collection_id = mysql_insert_id();
    echo
    ...
    See more | Go to post

    Leave a comment:


  • Select query to check:
    Code:
    mysql_query("select * from record_collection where record_id='".$id."' and collection_id = $new_collection_id");
    $check = mysql_fetch_array($check);				print_r($check);
    Output:

    Array ( [0] => A1232710697 [record_id] => A1232710697 [1] => 47 [collection_id] => 47 [2] => 0 [sortorder] => 0 [3] => 1 [active] => 1 )

    So,...
    See more | Go to post

    Leave a comment:


  • The connection is as follows, but it works for dozens of other queries:

    $conn = mysql_connect(" localhost", "user", "pass");
    mysql_select_db ("my_db");...
    See more | Go to post

    Leave a comment:


  • Thanks!

    It didn't fix the problem, as you predicted, but no harm in including the connection....
    See more | Go to post

    Leave a comment:


  • Thanks code green.

    The record is not pulled back on the PHP page where it should be displayed, which leads me to believe the record is not actually inserted.

    If I paste in the generated query manually to create the record, it is listed on my page, but if I leave it to the above mysql_query() call, it doesn't appear on the page. I'm also checking the cardinality of the table in question, so I can see quickly if anything is...
    See more | Go to post

    Leave a comment:


  • Why does MySQL insert appear to work but not insert anything?

    Hi there,

    This is driving me crazy! I have a mysql_query call to insert a simple record:

    Code:
    $update = mysql_query("INSERT INTO `my_db`.`record_collection` (`record_id`, `collection_id`, `sortorder`, `active`) VALUES ('$id', $new_collection_id, 0, 1)");
    When echoed out, this generates a nice little query such as:

    Code:
    INSERT INTO `my_db`.`record_collection` (`record_id`, `collection_id`,
    ...
    See more | Go to post
No activity results to display
Show More
Working...