Friday, 2 December 2016

Store Value from On/Off Button in MySQL Database Using PHP Ajax code throwing error

I have tried the exact same code on the link :- http://www.freezecoders.com/2013/05/store-value-from-onoff-button-in-mysql-database-using-php-ajax.html


Index.php :


$query=mysql_connect("localhost","root","");
mysql_select_db("freeze",$query);
?>



iPhone Style Radio and Checkbox Switches, found on DevGrow.com







$query3=mysql_query("select * from choice where id=1");
$query4=mysql_fetch_array($query3);
if($query4['choice']=="off")
{
echo "checked";
}
?>>






And this ajax.php:-


$query=mysql_connect("localhost","root","");
mysql_select_db("freeze",$query);
if(isset($_POST['value']))
{
$value=$_POST['value'];
mysql_query("update choice set choice='$value' where id='1'");
echo "

You have Chosen the button status as:" .$value."

";
}
?>

But the fact is it is not working on my wamp server. This code throws a lot of errors such as : Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in C:\wamp\www\btn\index.php on line 2
and :- mysqli_fetch_array() error on the line 109 . What is the problem with the given code ? Is there any one who can help me with this ?

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...