English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

$complete = mysql_query("INSERT listed SELECT * FROM info WHERE id = '$idno'");

if($complete){
@mysql_query("DELETE FROM info WHERE id = '$idno'")
;
}

exit;

echo("

Entry successfully Posted!

");

2006-09-29 22:35:33 · 3 answers · asked by detroitkid17 2 in Computers & Internet Programming & Design

I'm trying to make it to where the data is inserted into one database, and once this is accomplished, I want data from a different database to delete. Basically, I want to copy one row of data (depending on the $idno variable) from one database to another, then delete it from the first database once it's copied.

2006-09-29 23:09:33 · update #1

3 answers

There could be many reasons...

1. The obvious (your server rejected the connection, you forgot to select a database, or your PHP installation does not have INSERT rights on table `listed`).

2. A record with id='$idno' already exists in table `listed`. You need to specify an ON DUPLICATE KEY clause or the IGNORE mode.

3. Your INSERT query is not valid, because tables `listed` and `info` do not have the same structure. You need to add a list of columns before SELECT. I would also recommend spelling out the list of colunms in the SELECT subquery.

In the end (combining suggestions 2 and 3), you should have a query that looks like one of the following:

INSERT INTO listed (id, col_01, col_02, col_03)
SELECT
id AS info_id,
col_01 AS info_01,
col_02 AS info_02,
col_03 AS info_03
FROM info WHERE id = '$idno'
ON DUPLICATE KEY
UPDATE col_01=info_01, col_02=info_02, col_03=info_03

INSERT IGNORE INTO listed (id, col_01, col_02, col_03)
SELECT
id AS info_id,
col_01 AS info_01,
col_02 AS info_02,
col_03 AS info_03
FROM info WHERE id = '$idno'

2006-10-02 08:09:01 · answer #1 · answered by NC 7 · 0 0

What errors and line is it breaking at? one component that would desire to be a situation is that this: I dont understand in case you may upload different vars right into a string like this. $sql1="INSERT INTO $table_name('$field_name') attempt some thing like this: $sql1="INSERT INTO" . $table_name . "(" .$field_name. ")"; exchange the different sq. vars to this comparable scheme and notice if it does something.

2016-10-18 06:01:31 · answer #2 · answered by titman 4 · 0 0

If you can explain what you are trying to do i might be able to help.. Really dont no what u are trying

2006-09-29 22:41:18 · answer #3 · answered by Pyp 3 · 0 0

fedest.com, questions and answers