Hello experts, please help me solve this kind of problem. I've already checked the error on line 11 but i seem to not found what's wrong. I've also tried solutions suggested by the page but it's still not working. Please help me.

error: ( ! ) Parse error: syntax error, unexpected '$_POST' (T_VARIABLE), expecting ',' or ')' in C:\wamp64\www\project\server.php on line 11

Here's the part of error in my code:

//<?php
$username = "";
$home = "";
$errors = array();

//connect to the database
$db = mysqli_connect('localhost', 'root', '', 'registration');

// if the register button is clicked
if (isset($_POST['register'])) {
	$username = mysqli_real_escape_string(mysqli $_POST['username']);
	$houseno = mysqli_real_escape_string(mysqli $_POST['houseno']);
	$phonetel = mysqli_real_escape_string(mysqli $_POST['phonetel']);
	$password1 = mysqli_real_escape_string(mysqli $_POST['password1']);
	$password2 = mysqli_real_escape_string(mysqli $_POST['password2']);

	if (empty($username)) {
		array_push($errors, "Username is required");
//
Your help is much appreciated!

    <?php
    $username = "";
    $home = "";
    $errors = array();

    //connect to the database
    $db = mysqli_connect('localhost', 'root', '', 'registration');
    
    // if the register button is clicked
    if (isset($_POST['register'])) {
    	$username = mysqli_real_escape_string(mysqli $_POST['username']);
    	$houseno = mysqli_real_escape_string(mysqli $_POST['houseno']);
    	$phonetel = mysqli_real_escape_string(mysqli $_POST['phonetel']);
    	$password1 = mysqli_real_escape_string(mysqli $_POST['password1']);
    	$password2 = mysqli_real_escape_string(mysqli $_POST['password2']);
    
    	if (empty($username)) {
    		array_push($errors, "Username is required");

    This is the code from the first line. the 11th line is at $username = mysqli_real_escape_string(mysqli $_POST['username']);
    just to ease you to read my error code. pleaseeee help me.

      It looks like you accidentally wrote then copied and pasted "mysqli" as part of the function argument instead of just the prefix to the function name. Remove that extra word from all those function calls and it should be fixed.

      That said, instead of using mysqli_real_escape_string, have you considered parameter binding for prepared statements?

      Almost: since @syahira is using the procedural style, the first argument to mysqli_real_escape_string should be the database connection (the $db defined earlier), then the string being escaped.

      The alternative is to call real_escape_string directly on the connection object and then it does only need one argument.

      Weedpacket it worked perfectly with no errors now i am beyond happy thank you so much!!!

        Write a Reply...