I’m trying to run one SQL command to update multiple databases. If I copy ‘n paste sql code below directly into PHPMYADMIN it executes just fine, but when I run the sql through php it doesn’t update?
If I run the updates for each database separately via my php script they both update fine, so I’m confused?
What am I doing wrong?
SQL Code:
UPDATE rst.users a, rst.user_type b
SET a.first_name='Timsd',a.last_name='Lebaronsd',a.password='timsd',
a.email='tim@dog.comsd', a.user_type_id='5',a.language_code='en_US',
a.timezone='Pacific/Midway', create_ts = '2010-07-16 12:33:31'
WHERE a.user_type_id = b.user_type_id AND b.account_id = 1 AND a.users_id = 90;
use externalusers;
UPDATE externalusers.user
SET fullname="'Timsd' 'Lebaronsd'", emailaddress="'tim@dog.comsd'"
WHERE rst_id = 90 AND rst_account_id = 1;
mysql_query() and similar functions can’t execute multiple statements for security reasons.
Use mysqli_multi_query() if you really want to execute multiple statements with single call.
P.S. It’s not a PHP feature, but a feature of mysql C API.