Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to do Multiple MySQL Query in mysql_query() function?
    primarykey
    data
    text
    <p>I have a problem updating record on a table. Below is the detail:</p> <p>I have a table named tbl_option, it has 2 field : <code>option_name</code>, <code>option_value</code>. The current table record is follow:</p> <pre><code>option_name | option_value site_name | MySite site_desc | About anything </code></pre> <p>I want to update both site_name and site_desc option_value, here is my php script to update the <code>site_name</code> and <code>site_desc</code> option_value:</p> <pre><code>require "include/config.php"; $name = "MyNewSitess"; $desc = "About Computer"; $query = mysql_query("UPDATE tbl_option SET option_value='$name' WHEREoption_name='site_name';# UPDATE tbl_option SET option_value='$desc' WHERE option_name='site_desc'"); if ($query) { echo "Saved"; } else echo "Not saved : ".mysql_errno()." | ".mysql_error(); </code></pre> <p>after executed I get the following error:</p> <blockquote> <p>Not saved : 1064 | You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UPDATE tbl_option SET option_value='About Computer' WHERE option_name='site_desc' at line 1</p> </blockquote> <p>The record not updatd. But when I add (#) before the second UPDATE query :</p> <pre><code>&lt;?php ... $query = mysql_query("UPDATE tbl_option SET option_value='$name' WHERE option_name='site_name'; #UPDATE tbl_option SET option_value='$desc' WHERE option_name='site_desc'"); ... ?&gt; </code></pre> <p>It not showing any error. I get the following :</p> <blockquote> <p>Saved</p> </blockquote> <p>and the record is updated</p> <p>What is the problem ?</p> <p>Yes, I imitate the wordpress table concept but I don't know how to do the UPDATE query to the table.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload