문제

My goal is to change the value in the "commission" column from 'open' to 'closed' when I update the table 'status'.I can't seem to get the DB to update. I do not get any errors. What am I doing wrong?

This is the code for my submit button:

if($result["commissions"]=='open'){
    echo '<form method="post" action="admin_main.php">
    <input name="commissionsC" type="submit" value="Close comissions" />
    </form>';
    }

This is the part of my code that is not working:

<?php 
include("includes/connect.php");
if(isset($_POST['comissionsC'])){ 

$res= mysql_query("SELECT * FROM status");
$row= mysql_fetch_array($res);
$sql="UPDATE status".
"SET commissions = 'closed'".
"WHERE id = 1";
}

?>
도움이 되었습니까?

해결책

Change your query to:

$sql = mysql_query("UPDATE status SET commisions = 'closed' WHERE id = 1");

You're not executing your query.


Footnotes:

mysql_* functions deprecation notice:

http://www.php.net/manual/en/intro.mysql.php

This extension is deprecated as of PHP 5.5.0, and is not recommended for writing new code as it will be removed in the future. Instead, either the mysqli or PDO_MySQL extension should be used. See also the MySQL API Overview for further help while choosing a MySQL API.

These functions allow you to access MySQL database servers. More information about MySQL can be found at » http://www.mysql.com/.

Documentation for MySQL can be found at » http://dev.mysql.com/doc/.

다른 팁

is it always id number 1 that you want to update? Maybe you have to get the number id for each data :

$sql = mysql_query(UPDATE status SET commisions = "closed" WHERE id = 1)

Once u get the datas, execute the update query as well

$res= mysql_query("SELECT * FROM status");
$row= mysql_fetch_array($res);

$sql = mysql_query(UPDATE status SET commisions = "closed" WHERE id = 1)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top