Click here to Skip to main content
15,346,564 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Fatal error: Uncaught Error: Function name must be a string in D:\xampp\htdocs\a\simpan.php:4 Stack trace: #0 {main} thrown in D:\xampp\htdocs\a\simpan.php on line 4


$nama =$_POST("$nama");

$simpan =mysqli_query("insert into coba values ($nama,$alamat,$jekel)") or die(mysqli_error());

	echo "suskes masukkan data";
	echo "gagal masukan data";


What I have tried:

i already upgrade my php to 7.4.9
i already change the syntax from mysql to mysqli
i already change the sign from '' into ""
but it doesnt work and still appear function must be a string
Updated 1-Sep-20 20:55pm
Richard Deeming 2-Sep-20 4:36am
Your code is vulnerable to SQL Injection[^]. NEVER use string concatenation / interpolation to build a SQL query. ALWAYS use a parameterized query.

PHP: SQL Injection - Manual[^]
PHP: Prepared statements and stored procedures - Manual[^]

1 solution

You need to try square brackets instead of circular brackets.
$nama =$_POST['$nama'];

PHP: $_POST - Manual[^]
Maciej Los 2-Sep-20 2:57am
Good point!
Member 14928540 2-Sep-20 7:05am
tq dude , u r verry helpfull :D

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900