-1

Error in PHP:

Warning: mysqli_error() expects parameter 1 to be mysqli, null given in /users/mikadoru/www/register.php on line 16

Warning: mysqli_query() expects parameter 1 to be mysqli, null given in /users/mikadoru/www/register.php on line 13 PHP:

<?php
$con = mysqli_connect();
mysqli_select_db($con, "mikadoru");
$id = $_GET[id];
$email = $_GET[email];
$name = $_GET[name];
$password = $_GET[password];
$sql = "INSERT INTO user VALUES ($id, $email, $name, $password)";
mysqli_query($con, $sql);
mysqli_close($con);
echo "registriert"
?>

I connected normaly to MySQL the connect function is only here empty.

Community
  • 1
  • 1
Mikdore
  • 699
  • 5
  • 16
  • 1
    Code provided is not relevant to errors. Where is line 16 or 13? – u_mulder Aug 21 '17 at 15:37
  • line 13 is mysqli_query($con, $sql); and 16 is ?> – Mikdore Aug 21 '17 at 15:39
  • 1
    [Little Bobby](http://bobby-tables.com/) says ***[your script is at risk for SQL Injection Attacks.](http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php)*** Learn about [prepared](http://en.wikipedia.org/wiki/Prepared_statement) statements for [MySQLi](http://php.net/manual/en/mysqli.quickstart.prepared-statements.php). Even [escaping the string](http://stackoverflow.com/questions/5741187/sql-injection-that-gets-around-mysql-real-escape-string) is not safe! – Jay Blanchard Aug 21 '17 at 15:40
  • 1
    **Never store plain text passwords!** Please use ***PHP's [built-in functions](http://jayblanchard.net/proper_password_hashing_with_PHP.html)*** to handle password security. If you're using a PHP version less than 5.5 you can use the `password_hash()` [compatibility pack](https://github.com/ircmaxell/password_compat). ***It is not necessary to [escape passwords](http://stackoverflow.com/q/36628418/1011527)*** or use any other cleansing mechanism on them before hashing. Doing so *changes* the password and causes unnecessary additional coding. – Jay Blanchard Aug 21 '17 at 15:40
  • You have not included any connection information for your database here `$con = mysqli_connect();` – Jay Blanchard Aug 21 '17 at 15:41
  • in the original i do – Mikdore Aug 21 '17 at 15:42
  • Note: The object-oriented interface to `mysqli` is significantly less verbose, making code easier to read and audit, and is not easily confused with the obsolete `mysql_query` interface. Before you get too invested in the procedural style it’s worth switching over. Example: `$db = new mysqli(…)` and `$db->prepare("…”)` The procedural interface is an artifact from the PHP 4 era when `mysqli` API was introduced and should not be used in new code. – tadman Aug 21 '17 at 16:03
  • **WARNING**: Writing your own access control layer is not easy and there are many opportunities to get it severely wrong. Please, do not write your own authentication system when any modern [development framework](http://codegeekz.com/best-php-frameworks-for-developers/) like [Laravel](http://laravel.com/) comes with a robust [authentication system](https://laravel.com/docs/5.4/authentication) built-in. At the absolute least follow [recommended security best practices](http://www.phptherightway.com/#security) and **never store passwords as plain-text**. – tadman Aug 21 '17 at 16:03

1 Answers1

0

You are not opening any DB!

From PHP manual:

mysqli_connect($db_host,$db_user,$db_pass,$db_database,$db_port);

Fabio Marzocca
  • 1,573
  • 16
  • 36