1
votes

I am running this php code with sql query but it keeps showing this error and i couldn't find where the mistake is? Can you help please.THANKS IN ADVANCE

Warning: mssql_query(): message: Incorrect syntax near '='. (severity 15)

Warning: mssql_query(): General SQL Server error: Check messages from the SQL Server (severity 15)

Warning: mssql_query(): Query failed

I have this on my user.php

if(isset($_POST['refresh'])){
    $mssql_real = db_connect_real();
    $sql = "UPDATE TOP(1) click_users_phones SET pin_failed = 0, status = 1, pin_blocked_time = NULL WHERE phone_num = $phone_num";
    mssql_query($sql, $mssql_real);
}

I have this on another php file

<form action="user.php" method="post">
    <button class="#" name="refresh">Refresh</button>
</form>
2
This might enlightment you about using mssql_* - Carl Binalla

2 Answers

2
votes

update this statement

$sql = "UPDATE TOP(1) click_users_phones SET pin_failed = 0, status = 1, pin_blocked_time = NULL WHERE phone_num = $phone_num";

to

$sql = "UPDATE TOP(1) click_users_phones SET pin_failed = 0, status = 1, pin_blocked_time = NULL WHERE phone_num =".$phone_num;
0
votes

Your SQL statement should be like

UPDATE TOP(1) A SET pin_failed = 0, status = 1, pin_blocked_time = NULL 
FROM click_users_phones A WHERE phone_num = ''

Note: But you should remember that SQL never guarantee you the order. So If you are updating the TOP 1 ,then you should provide the ORDER BY in the select. So that you will update the correct record.