简体   繁体   中英

mysqli_real_escape_string for int

Help, I've been searching for all solutions on how I can retrieve my data from a table in a database using the primary key.

intval($referenceNumber) = mysqli_real_escape_string($link, $_POST['referenceNumber']);

Then my sql query goes like this..

$sql = "INSERT INTO cleared 
        (referenceNumber, visitorName, visitorID, 
        numberOfCompanions, collegeVisit, reasonVisit, timeIn)
        SELECT *
        FROM visitor
        WHERE referenceNumber = PRIMARY KEY";`

I always get the error: Fatal error: Can't use function return value in write context in C:\\wamp64\\www\\test\\transfer.php on line 13

How can I remove this error? Thanks in advance for the help.

Well you need to first assign the value to the variables and then cast it to an integer. You line 13 should be:

$referenceNumber = mysqli_real_escape_string($link, $_POST['referenceNumber']);

$referenceNumber = intval($referenceNumber);

See the documentation for intval

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM