Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Closed Thread
mysql multi query with php
Old 12-15-2010, 12:17 PM mysql multi query with php
Experienced Talker

Posts: 43
Trades: 0
Ok this is starting to piss me off.
I have a little project and i know some basic stuff about mysql and php but i cant figure this one out.

I need to copy one row in a table to another table, so i searched for some scripts to do this and i found a sql script (thnx to original poster):

Code:
UPDATE old_data SET move="MARKED";
INSERT INTO somewhere... SELECT where move="MARKED";
DELETE FROM old_data WHERE move="MARKED";
I can run this sql query in phpmyadmin wihout any problems and it does what i need it to do the only thing is when i try to implement this in my php page i cant get this to work.
I know i need to use mysqli_multi_query (at least i think) but after 4 hours searching and trying i cant get it to work.

So if anyone can help me with this or point me in the right direction. it would help me a lot.
Thnx in advance!
TheSir is offline
View Public Profile
 
 
Register now for full access!
Old 12-15-2010, 03:21 PM Re: mysql multi query with php
miki86's Avatar
Extreme Talker

Posts: 185
Location: print_r($serbia);
Trades: 0
Where is your php code?
miki86 is online now
View Public Profile
 
Old 12-15-2010, 04:20 PM Re: mysql multi query with php
Experienced Talker

Posts: 43
Trades: 0
Dont have a php code for it, because i have no idea how to code a multiple query and the examples in documentations echo stuff etc and i dont need all that.

It doesn't have to echo anything or something like that, the query only has to update 1 row in my database and copy it to a other table and delete the row in the old table. Nothing more, so basicly the php code just has to run the multiple query.

It will be implemented in paypal IPN, i can get 1 query to work with:
Code:
$sql="UPDATE data_temp SET check='MARKED' WHERE 'itx' = '$_POST[item_number]'";
But i have no idea how to do multiple query's.
TheSir is offline
View Public Profile
 
Old 12-15-2010, 04:41 PM Re: mysql multi query with php
miki86's Avatar
Extreme Talker

Posts: 185
Location: print_r($serbia);
Trades: 0
By looking at the documentation, this is how you can do what you want to do:

PHP Code:
$query "UPDATE old_data SET move='MARKED'";
$query .= "INSERT INTO somewhere... SELECT where move='MARKED'";
$query .= "DELETE FROM old_data WHERE move='MARKED'";

mysqli_multi_query($query); 
By the way you are open for sql injection here:
Code:
$sql="UPDATE data_temp SET check='MARKED' WHERE 'itx' = '$_POST[item_number]'";
Use mysql_real_escape_string() or in your case mysqli_real_escape_string():
PHP Code:
$item_number mysqli_real_escape_string($_POST[item_number]);
$sql="UPDATE data_temp SET check='MARKED' WHERE 'itx' = '$item_number'"
miki86 is online now
View Public Profile
 
Old 12-15-2010, 05:53 PM Re: mysql multi query with php
Experienced Talker

Posts: 43
Trades: 0
Thnx for the fast response, really appreciate it!
Will try it later today.
TheSir is offline
View Public Profile
 
Old 12-15-2010, 08:07 PM Re: mysql multi query with php
Experienced Talker

Posts: 43
Trades: 0
Your post give me the little push i needed to solve it. Cost me another hour though but i got it working, finally!

So thnx again and this thread can be closed!
TheSir is offline
View Public Profile
 
Closed Thread     « Reply to mysql multi query with php
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.38155 seconds with 12 queries