Multiple Update

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Erick020 wrote:Look, you can see in the $q echo, the INSERT is OK... all values are present...:
insert into BESTELLING (Afnemer_ID, Leads_Kind, Aantal, Betaald, Datetime) values ('87', 'HYPOTHEEK', '3', 'NO', '1180203353')
so, this is 100% OK.
but never mind, this is NOT important....
Ok, let me try it another way. What do you think is the purpose of mysql_query() or mysql_db_query()? What does it do? And therefore what happens if it isn't present?
Erick020
Forum Newbie
Posts: 22
Joined: Sat Apr 12, 2003 7:11 am

Post by Erick020 »

volka wrote:
Erick020 wrote:Look, you can see in the $q echo, the INSERT is OK... all values are present...:
insert into BESTELLING (Afnemer_ID, Leads_Kind, Aantal, Betaald, Datetime) values ('87', 'HYPOTHEEK', '3', 'NO', '1180203353')
so, this is 100% OK.
but never mind, this is NOT important....
Ok, let me try it another way. What do you think is the purpose of mysql_query() or mysql_db_query()? What does it do? And therefore what happens if it isn't present?
This is very easy:

First you have a script to select some data, if the database is empty you get "no data", if there are any, you get a list of the data you have selected (script:Show_Leads_H.php).
From there you have to confirm your order and when you click on the "confirm link" you run Command_Leads_H.php and i must update the database, means I must put in all selected arrays (to find in the Show_Leads_H.php script) some informations like (company_ID).
The problem is that selected arrays get lost (on the script Show_Leads_H.php, I can see: <input type=hidden name=Aanvraag_ID[0] value=28>, <input type=hidden name=Aanvraag_ID[1] value=29>), and it suppose to update the arrays 28, 29... but this information get lost and will not update anything...

Do you get the picture?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

That was so not my question.
What does the function mysql_query() do?
Erick020
Forum Newbie
Posts: 22
Joined: Sat Apr 12, 2003 7:11 am

Post by Erick020 »

volka wrote:That was so not my question.
What does the function mysql_query() do?
Look, I am no expert... so if you get the picture, and understand what i am trying to do, please help me with a simple script, because i get really confused.
I must update some specific arrays that are defined on a page and I cannot send the info to the next page (the update script).
Erick020
Forum Newbie
Posts: 22
Joined: Sat Apr 12, 2003 7:11 am

Post by Erick020 »

volka wrote:That was so not my question.
What does the function mysql_query() do?
Here the page:

http://sales.bestefinancieringen.nl/SCR ... k.php?A=87

don't change the settings, (only the first table works) --> choice: 1 0... click on SELECTEREN
then type 3 for exemple and click on TONEN and then on ORDER BEVESTIGEN

You can see I think what happends
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

What does mysql_query do? (mysql_query and mysql_db_query are similar)
see http://de2.php.net/mysql_query
Erick020
Forum Newbie
Posts: 22
Joined: Sat Apr 12, 2003 7:11 am

Post by Erick020 »

volka wrote:What does mysql_query do? (mysql_query and mysql_db_query are similar)
see http://de2.php.net/mysql_query
mysql_query SELECT THE DATA THAT ARE SHOWN ON THE PAGE
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

no. Please read the manual page carefully.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Let me answer this question for you, it executes the query. If you do not execute the query, in your case the insert statement, then nothing will be inserted.
Erick020
Forum Newbie
Posts: 22
Joined: Sat Apr 12, 2003 7:11 am

Post by Erick020 »

Jcart wrote:Let me answer this question for you, it executes the query. If you do not execute the query, in your case the insert statement, then nothing will be inserted.
I do NOT have any trouble with the INSERT.... it works fine...

The update (competely separate from the INSERT) does not work... so please just forget the INSERT... and help me to update several arrays at the same time..

I finally have on a page:

ID[0] = 1
ID[1] = 5
ID[3] = 8

and I need to update some data (lets say company_ID=87) into all these arrays, that's it
Last edited by Erick020 on Sat May 26, 2007 2:03 pm, edited 1 time in total.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

I meant update, not insert.
Erick020
Forum Newbie
Posts: 22
Joined: Sat Apr 12, 2003 7:11 am

Post by Erick020 »

Jcart wrote:I meant update, not insert.
OK.... but before i start to write here I already tried many things and read the manual, but I don't understand... so if you know the right statement for doing that, please just send it as I suppose to use it (I can change the names).
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Sorry, there is no easy fix.
There's a fundemental misunderstandig in
WHERE

'Aanvraag_ID[$i]' = 'Aanvraag_ID[$i]
and the flop trying to explain the lesser errors or strange things in the script I very much doubt I can explain this to you. Good luck anyway.
Erick020
Forum Newbie
Posts: 22
Joined: Sat Apr 12, 2003 7:11 am

Post by Erick020 »

volka wrote:Sorry, there is no easy fix.
There's a fundemental misunderstandig in
WHERE

'Aanvraag_ID[$i]' = 'Aanvraag_ID[$i]
and the flop trying to explain the lesser errors or strange things in the script I very much doubt I can explain this to you. Good luck anyway.
Look this is what I mean... this is wrong, I know that....
If you understand what I want to do, don't try to fix what i did, just send what you think it should be.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Ok, take this line of code:

Code: Select all

$q = "UPDATE users SET last_login = NOW() WHERE id = '" . mysql_real_escape_string($userId) . "' LIMIT 1";
It does absolutely nothing other than create a string which we do nothing with.

Now take this:

Code: Select all

$q = "UPDATE users SET last_login = NOW() WHERE id = '" . mysql_real_escape_string($userId) . "' LIMIT 1";
mysql_query($q);
It runs that string as a MySQL query. You're missing the call to mysql_query() in your code.

I'll also take a wild stab in the dark that this bit of code:

Code: Select all

WHERE 

'Aanvraag_ID[$i]' = 'Aanvraag_ID[$i]
Should be:

Code: Select all

WHERE 

Aanvraag_ID = 'Aanvraag_ID[$i]
Post Reply