Question

I need a little help,I'm new in php mysql, and i dont know why does my script not insert the row in database. I start apache and mysql in xammp and I create the database(users) and the table(users). Maybe I'm not seeing something, could use a little help.

Config.inc.php

$dbUser = "root";
$dbPass = "";
$dbDatabase = "test";
$dbHost = "localhost";

$dbConn = mysql_connect($dbHost, $dbUser, $dbPass);

if($dbConn){
  mysql_select_db($dbDatabase);  
  print ("Succsess");
}
else {
    die("<strong>ERROR</strong>Could Not connect to Database");
}


?>

Index.php

<?php
include("config.inc.php");

print ("<br>Inserting rows ...");
$password = "test";
mysql_query("ISERT INTO `users`(`email`, `password`, `name`) VALUES ('myemail@gmail.com','" . sha1($password)  .  "' , 'Flamur')");
echo "<br>Done";
?>

I also use sha1 to encrypt my password :P . Thnx for helping :)

Was it helpful?

Solution

You have got mistake in:

mysql_query("ISERT INTO `users`(`email`, `password`, `name`) VALUES ('myemail@gmail.com','" . sha1($password)  .  "' , 'Flamur')");

You must use INSERT no ISERT so try to replace your line with this:

mysql_query("INSERT INTO `users`(`email`, `password`, `name`) VALUES ('myemail@gmail.com','" . sha1($password)  .  "' , 'Flamur')");

OTHER TIPS

It is INSERT not ISERT on your query.

mysql_query("ISERT INTO `users`(`email`, `password`, `name`) VALUES ('myem
            ^^^^^

Also, This(mysql_*) extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQL extension should be used. Switching to PreparedStatements is even more better to ward off SQL Injection attacks !

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top