Note that there are some explanatory texts on larger screens.

plurals
  1. POOnly One Update Function Working PHP
    primarykey
    data
    text
    <p>So I want to have a button that updates a value and changes it to "HIGH" and another to update the same value and change it to "LOW". Both functions work individually, but when in the same file only the one whose input comes first works. This may sound confusing. If you look at the code below, you can see there are two inputs. If the on function is called by the second input, it works. If it is called by the second input function it does not.</p> <pre><code>&lt;?php function off(){ mysql_connect("localhost", "root", ""); mysql_select_db("arduino"); mysql_query("UPDATE `leds` SET `state` = 'LOW' WHERE `id` = 13"); } function on(){ mysql_connect("localhost", "root", ""); mysql_select_db("arduino"); mysql_query("UPDATE `leds` SET `state` = 'HIGH' WHERE `id` = 13"); } ?&gt; &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt; &lt;html&gt; &lt;head&gt; &lt;link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css" /&gt; &lt;script src="http://code.jquery.com/jquery-1.9.1.min.js"&gt;&lt;/script&gt; &lt;script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"&gt; &lt;/script&gt; &lt;title&gt;&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;input type = "button" value = "Turn On" onclick = "&lt;?php on(); ?&gt;"&gt; &lt;br /&gt; &lt;br /&gt; &lt;input type = "button" value = "Turn Off" onclick = "&lt;?php off(); ?&gt;"&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>I am very confused by this. Anyone know what is going on. If I have not been clear enough please say so and I would be glad to provide more detail.</p>
    singulars
    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