Page 1 of 2
hmm, not getting errors when this is executed but no results
Posted: Thu May 31, 2007 11:04 am
by aredden
Here is what I have coded.
Code: Select all
<?php
session_start();
$_SESSION['sessid'] = $id;
$con = mysql_connect("********);
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("******", $con);
mysql_query("INSERT INTO main2 (name, email, deptcity, deptdate, arrivalcity, retdate, pass1name, pass1age, pass1nation, pass2name, pass2age, pass2nation, pass3name, pass3age, pass3nation, pass4name, pass4age, pass4nation, comment) SELECT name, email, deptcity, deptdate, arrivalcity, retdate, pass1name, pass1age, pass1nation, pass2name, pass2age, pass2nation, pass3name, pass3age, pass3nation, pass4name, pass4age, pass4nation, comment FROM main1 WHERE main1.id = $id");
mysql_close($con);
//session_destroy();
?>
but no data gets moved. any thoughts?
Posted: Thu May 31, 2007 11:22 am
by superdezign
Well, if you tell us the error that occurred, we can probably point out the error relative quickly.
Code: Select all
mysql_query("....") or die(mysql_error());
Posted: Thu May 31, 2007 11:23 am
by superdezign
Whoa whoa whoa whoa whoa. What are you doing here?
Code: Select all
INSERT INTO
main2
(name, email, deptcity, deptdate, arrivalcity, retdate, pass1name, pass1age, pass1nation, pass2name, pass2age, pass2nation, pass3name, pass3age, pass3nation, pass4name, pass4age, pass4nation, comment)
SELECT
name, email, deptcity, deptdate, arrivalcity, retdate, pass1name, pass1age, pass1nation, pass2name, pass2age, pass2nation, pass3name, pass3age, pass3nation, pass4name, pass4age, pass4nation, comment
FROM
main1
WHERE
main1.id = $id
What is this supposed to do?
Posted: Thu May 31, 2007 11:24 am
by thiscatis
I hope it's because you removed your login details but the connection string doesn't have an ending "
Posted: Thu May 31, 2007 11:29 am
by aredden
ok the error i get now is
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
and I was trying to move data from one table to another. heh. but im new to the php game and i might not have done that properly.
but i was trying to insert into table2 with values from table 1 with a corrisponding table id = $id.
Posted: Thu May 31, 2007 11:36 am
by volka
aredden wrote:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
Your whole sql statement is one single line, therefore the error message doesn't help you much
try
Code: Select all
session_start();
$_SESSION['sessid'] = $id;
$con = mysql_connect("********");
if (!$con) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("******", $con) or die(mysql_error();
$query = "INSERT INTO
main2
(name, email, deptcity, deptdate,
arrivalcity, retdate, pass1name, pass1age,
pass1nation, pass2name, pass2age, pass2nation,
pass3name, pass3age, pass3nation, pass4name,
pass4age, pass4nation, comment)
SELECT
name, email, deptcity, deptdate,
arrivalcity, retdate, pass1name, pass1age,
pass1nation, pass2name, pass2age, pass2nation,
pass3name, pass3age, pass3nation, pass4name,
pass4age, pass4nation, comment
FROM
main1
WHERE
main1.id = $id";
mysql_query($query, $con) or die('<pre>mysql_error().': '.$query.'</pre>');
mysql_close($con);
What is $id and where does it come from?
Posted: Thu May 31, 2007 11:36 am
by superdezign
Interesting... Well, it's totally possible. You should look up some SQL tutorials and read a bit of the manual.
Code: Select all
INSERT INTO `tableName` (columnNames) VALUES(columnValues);
Seeing as you're new to it, I'd suggest selecting the values, saving them in PHP, and then inserting them into the query from there.
Posted: Thu May 31, 2007 11:59 am
by aredden
found the problem I had $_SESSION.... = $id;
works as $id = $_SESSION['sessid'];

thanks guys
Posted: Thu May 31, 2007 12:08 pm
by superdezign
aredden wrote:found the problem I had $_SESSION.... = $id;
works as $id = $_SESSION['sessid'];

thanks guys
^_^ That made me giggle. :-p
Posted: Thu May 31, 2007 12:22 pm
by aredden
superdezign wrote:aredden wrote:found the problem I had $_SESSION.... = $id;
works as $id = $_SESSION['sessid'];

thanks guys
^_^ That made me giggle. :-p
Did I miss something?
Posted: Thu May 31, 2007 12:36 pm
by superdezign
aredden wrote:Did I miss something?
No no
It was one of those errors that was right in front of our face, but none of us noticed. Too simple. :-p
Posted: Thu May 31, 2007 12:51 pm
by volka
volka wrote:What is $id and where does it come from?
I did

Posted: Thu May 31, 2007 1:00 pm
by superdezign
volka wrote:volka wrote:What is $id and where does it come from?
I did

Showoff.

I assumed he meant to set it to the session... Didn't even think that it was undefined.
Posted: Thu May 31, 2007 2:49 pm
by RobertGonzalez
superdezign wrote:volka wrote:volka wrote:What is $id and where does it come from?
I did

Showoff.

I assumed he meant to set it to the session... Didn't even think that it was undefined.
Beware... volka sees things almost like feyd sees things...
Posted: Thu May 31, 2007 2:56 pm
by superdezign
Everah wrote:superdezign wrote:volka wrote:I did

Showoff.

I assumed he meant to set it to the session... Didn't even think that it was undefined.
Beware... volka sees things almost like feyd sees things...
Oh! Almost. Okay then.
There were almost two of them.