Click here to Skip to main content
14,919,896 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
		$sql="SELECT*FROM user_d WHERE email = '".$
		$result= $conn->query($sql);
		if($result->num_rows > 0){
			$error[] = "Email already exist!";
			$sql="INSERT INTO
			$success[]= "Account created successfully";
		} else{
			$errors[] = "Error:".$sql."<br>".$conn->error;

What I have tried:

$success[]= "Account created successfully";
$success()= "Account created successfully";
Updated 9-May-21 17:29pm

1 solution

$sql="SELECT*FROM user_d WHERE email = '".$
// Previous line is truncated

        $sql="INSERT INTO
// double quote is missing here  ^

Not a solution to your question, but another problem you have.
Never build an SQL query by concatenating strings. Sooner or later, you will do it with user inputs, and this opens door to a vulnerability named "SQL injection", it is dangerous for your database and error prone.
A single quote in a name and your program crash. If a user input a name like "Brian O'Conner" can crash your app, it is an SQL injection vulnerability, and the crash is the least of the problems, a malicious user input and it is promoted to SQL commands with all credentials.
SQL injection - Wikipedia[^]
SQL Injection[^]
SQL Injection Attacks by Example[^]
PHP: SQL Injection - Manual[^]
How can I explain SQL injection without technical jargon? - Information Security Stack Exchange[^]

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

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