By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,408 Members | 1,576 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,408 IT Pros & Developers. It's quick & easy.

query

P: n/a
$query = "update reactie,form set 'reactie.persemail' = 'form.email' where
'reactie.persid' = 'form.id' AND reactie.persemail='' ";

How can i get this query to work?

Irlan
Jul 17 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a

Irlan agous wrote:
$query = "update reactie,form set 'reactie.persemail' = 'form.email' where 'reactie.persid' = 'form.id' AND reactie.persemail='' ";

How can i get this query to work?


Can you give us a hint as to your problems? Context of this line?
Errors you're getting?

Can't say much about one line out of context.

Ken

Jul 17 '05 #2

P: n/a
Irlan agous (ir******@msn.com) decided we needed to hear...
$query = "update reactie,form set 'reactie.persemail' = 'form.email' where
'reactie.persid' = 'form.id' AND reactie.persemail='' ";

How can i get this query to work?

Irlan

Assuming this is a MySQL query...
Don't quote the column names, they are being treated as literals.
Multi-table updates only work with version 4.0.4 onwards so make sure
you're using that or a later version.
--
Dave <da**@REMOVEbundook.com>
(Remove REMOVE for email address)
Jul 17 '05 #3

P: n/a
Thanks, its an mysql quesy yes,

and i also tried it without the quotes:

mysql_select_db("idm") or die("Unable to select database");
$query = "update reactie,form set reactie.persemail = form.email where
reactie.persid = form.id ";
$query_result= mysql_query($query) or die ("can not change the data");

echo "<b>The data is succesfully changed</b><br>";

but it said to the cant change the data, whats wrong here?
"Dave" <da**@REMOVEbundook.com> schreef in bericht
news:g2************@fawlty.homelinux.net...
Irlan agous (ir******@msn.com) decided we needed to hear...
$query = "update reactie,form set 'reactie.persemail' = 'form.email'
where
'reactie.persid' = 'form.id' AND reactie.persemail='' ";

How can i get this query to work?

Irlan

Assuming this is a MySQL query...
Don't quote the column names, they are being treated as literals.
Multi-table updates only work with version 4.0.4 onwards so make sure
you're using that or a later version.
--
Dave <da**@REMOVEbundook.com>
(Remove REMOVE for email address)

Jul 17 '05 #4

P: n/a
Irlan agous (ir******@msn.com) decided we needed to hear...
Thanks, its an mysql quesy yes,

and i also tried it without the quotes:

mysql_select_db("idm") or die("Unable to select database");
$query = "update reactie,form set reactie.persemail = form.email where
reactie.persid = form.id ";
$query_result= mysql_query($query) or die ("can not change the data");

echo "<b>The data is succesfully changed</b><br>";

but it said to the cant change the data, whats wrong here?
"Dave" <da**@REMOVEbundook.com> schreef in bericht
news:g2************@fawlty.homelinux.net...
Irlan agous (ir******@msn.com) decided we needed to hear...
$query = "update reactie,form set 'reactie.persemail' = 'form.email'
where
'reactie.persid' = 'form.id' AND reactie.persemail='' ";

How can i get this query to work?

Irlan

Assuming this is a MySQL query...
Don't quote the column names, they are being treated as literals.
Multi-table updates only work with version 4.0.4 onwards so make sure
you're using that or a later version.
--
Dave <da**@REMOVEbundook.com>
(Remove REMOVE for email address)

I just created a couple test tables and ran your query and it works
fine for me, so...
Do you have a unique index (or primary key) on the persemail column in
the reactie table? Maybe your update is trying to set a duplicate
value?
You should display the text returned by the mysql_error() function
following your call to mysql_query(). That will tell you what is going
wrong.

--
Dave <da**@REMOVEbundook.com>
(Remove REMOVE for email address)
Jul 17 '05 #5

P: n/a
*** Irlan agous wrote/escribió (Mon, 9 May 2005 15:56:30 +0200):
and i also tried it without the quotes:
mysql_select_db("idm") or die("Unable to select database");
$query = "update reactie,form set reactie.persemail = form.email where
reactie.persid = form.id ";


Learn what quotes mean, as in any other language it's necessary to know the
basic syntax:

http://dev.mysql.com/doc/mysql/en/la...structure.html

(See first the "Strings" chapter, then read the rest).

--
-- Álvaro G. Vicario - Burgos, Spain
-- http://bits.demogracia.com - Mi sitio sobre programación web
-- Don't e-mail me your questions, post them to the group
--
Jul 17 '05 #6

P: n/a

allright, well the form.id is a primary key and the reactie.persid and
reactie.persid has more duplicate values, isnt it possible to still change
these values?

and i also tried it without the quotes:
mysql_select_db("idm") or die("Unable to select database");
$query = "update reactie,form set reactie.persemail = form.email where
reactie.persid = form.id ";


Learn what quotes mean, as in any other language it's necessary to know
the
basic syntax:

http://dev.mysql.com/doc/mysql/en/la...structure.html

(See first the "Strings" chapter, then read the rest).

--
-- Álvaro G. Vicario - Burgos, Spain
-- http://bits.demogracia.com - Mi sitio sobre programación web
-- Don't e-mail me your questions, post them to the group
--

Jul 17 '05 #7

P: n/a
Irlan agous (ir******@msn.com) decided we needed to hear...

allright, well the form.id is a primary key and the reactie.persid and
reactie.persid has more duplicate values, isnt it possible to still change
these values?

and i also tried it without the quotes:
mysql_select_db("idm") or die("Unable to select database");
$query = "update reactie,form set reactie.persemail = form.email where
reactie.persid = form.id ";


Learn what quotes mean, as in any other language it's necessary to know
the
basic syntax:

http://dev.mysql.com/doc/mysql/en/la...structure.html

(See first the "Strings" chapter, then read the rest).

--
-- Álvaro G. Vicario - Burgos, Spain
-- http://bits.demogracia.com - Mi sitio sobre programación web
-- Don't e-mail me your questions, post them to the group
--




For this particular query it only really matters if reactie.persemail
is a unique index - i.e. if it was, then you might be trying to set it
to a duplicate value.

Try my other suggestion by changing your query line to be..
$query_result = mysql_query($query) or die ("can not change the
data: " . mysql_error());

That will tell you exactly what is going wrong.

--
Dave <da**@REMOVEbundook.com>
(Remove REMOVE for email address)
Jul 17 '05 #8

P: n/a
Thanks, i tried your suggestion. But it doesnt give me really the
information i need. i get this:
can not change the
data: You have an error in your SQL syntax near 'form set reactie.persemail
= form.email where reactie.persid = form.id AND reac' at line 1

But i think i know the problem now. form.id is a primary key so has unique
values and cant make duplicates. Is there a way to change this ?

allright, well the form.id is a primary key and the reactie.persid and
reactie.persid has more duplicate values, isnt it possible to still change
these values?

and i also tried it without the quotes:
mysql_select_db("idm") or die("Unable to select database");
$query = "update reactie,form set reactie.persemail = form.email where
reactie.persid = form.id ";


Learn what quotes mean, as in any other language it's necessary to know
the
basic syntax:

http://dev.mysql.com/doc/mysql/en/la...structure.html

(See first the "Strings" chapter, then read the rest).

--
-- Álvaro G. Vicario - Burgos, Spain
-- http://bits.demogracia.com - Mi sitio sobre programación web
-- Don't e-mail me your questions, post them to the group
--


For this particular query it only really matters if reactie.persemail
is a unique index - i.e. if it was, then you might be trying to set it
to a duplicate value.

Try my other suggestion by changing your query line to be..
$query_result = mysql_query($query) or die ("can not change the
data: " . mysql_error());

That will tell you exactly what is going wrong.

--
Dave <da**@REMOVEbundook.com>
(Remove REMOVE for email address)
Jul 17 '05 #9

P: n/a
Irlan agous wrote:
Thanks, i tried your suggestion. But it doesnt give me really the
information i need. i get this:
can not change the
data: You have an error in your SQL syntax near 'form set reactie.persemail
= form.email where reactie.persid = form.id AND reac' at line 1

But i think i know the problem now. form.id is a primary key so has unique
values and cant make duplicates. Is there a way to change this ?

No, MySQL is telling you exactly what's wrong - there is a syntax error
in your statement. It never gets far enough to update the database, so
you can't have a problem with duplicates (plus, you aren't changing
form.id or inserting a second row with the same id, so that's not the
problem anyway).

So - back to basics. What version of MySQL are you actually using? And
what's your table layout for form and reactie?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jul 17 '05 #10

P: n/a
Jerry Stuckle (js*******@attglobal.net) decided we needed to hear...
Irlan agous wrote:
Thanks, i tried your suggestion. But it doesnt give me really the
information i need. i get this:
can not change the
data: You have an error in your SQL syntax near 'form set reactie.persemail
= form.email where reactie.persid = form.id AND reac' at line 1

But i think i know the problem now. form.id is a primary key so has unique
values and cant make duplicates. Is there a way to change this ?

No, MySQL is telling you exactly what's wrong - there is a syntax error
in your statement. It never gets far enough to update the database, so
you can't have a problem with duplicates (plus, you aren't changing
form.id or inserting a second row with the same id, so that's not the
problem anyway).

So - back to basics. What version of MySQL are you actually using? And
what's your table layout for form and reactie?

Exactly - as I stated in an earlier post...
Multi-table updates only work with version 4.0.4 (of MySQL) onwards
so make sure you're using that or a later version.
i.e. if your version is less than 4.0.4 you cannot do what you are
trying to do in one statement.

--
Dave <da**@REMOVEbundook.com>
(Remove REMOVE for email address)
Jul 17 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.