1

Why doesn't my MySQL code work from PHP. However if I return the SQL and paste it into the SQL console the rows update accordingly.

SQL

UPDATE propertypriority 
   SET prioritylevel = '8' 
 WHERE roomtypecode = '1184'; 

UPDATE property 
   SET prioritylevel = '8' 
 WHERE roomtypecode = '1184'; 

PHP

$sql = "UPDATE propertypriority 
           SET prioritylevel = '".$demotionvalue."' 
         WHERE roomtypecode = '".$row['roomtypecode']."'; "
       ."UPDATE property
            SET prioritylevel = '".$demotionvalue."' 
          WHERE roomtypecode = '".$row['roomtypecode']."'; ";
2
  • Why do two tables contain identical information?! Commented Apr 2, 2011 at 3:03
  • im a noob and im trying to work out how to cascade on update? Commented Apr 2, 2011 at 3:10

3 Answers 3

3

from: http://www.tutorialspoint.com/mysql/mysql-sql-injection.htm

'Fortunately, if you use MySQL, the mysql_query() function does not permit query stacking, or executing multiple queries in a single function call. If you try to stack queries, the call fails.'

so maybe try breaking it into two queries

Sign up to request clarification or add additional context in comments.

Comments

1

I think you might want to look into wrapping your SQL statements into a transaction.

This page from the manual has a example for you.

Comments

0

Are you using mysqli? If so, depending on how you execute the query, it's not going to allow you to execute two statements with one command.

1 Comment

I definitely think that including ";" in a SQL command is the problem. Most definitely.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.