How do I insert with mySQLi?

Get help using Construct 2

Post » Fri Apr 21, 2017 5:28 pm

Hi guys,

I'm trying to insert into a mySQLi DB, but nothing is happening :cry: This is my code:

Code: Select all
<?php
$db = "db";//Your database name
$dbu = "user";//Your database username
$dbp = "pass";//Your database users' password
$host = "host";//MySQL server - usually localhost

$dblink = mysqli_connect($host,$dbu,$dbp,$db);
if (!$dblink) { exit('Verbindung schlug fehl: '.mysqli_connect_error()); }
echo 'Verbindung zum Host steht!';
     
if(isset($_GET['name']) && isset($_GET['score'])&& isset($_GET['last_name'])&& isset($_GET['nickname'])&& isset($_GET['email'])){
     
     $name = strip_tags(mysql_real_escape_string($_GET['name']));
     $score = strip_tags(mysql_real_escape_string($_GET['score']));
     $last_name = strip_tags(mysql_real_escape_string($_GET['last_name']));
     $nickname = strip_tags(mysql_real_escape_string($_GET['nickname']));
     $email = strip_tags(mysql_real_escape_string($_GET['email'])); 
   
     $string = "INSERT INTO sbo_scores (id,name,score,last_name,nickname,email) VALUES ('','$name','$score','$last_name','$nickname','$email');";
     $sql = mysqli_query($dblink, $string);
     
}else{
     echo 'error.';
}

mysqli_close($dblink); //Close off the MySQL connection to save resources.
?>


Any ideas?
B
26
S
8
Posts: 84
Reputation: 1,722

Post » Fri Apr 21, 2017 5:40 pm

Nvm, I fixed it.

I removed all the "mysql_real_escape_string" statements.
B
26
S
8
Posts: 84
Reputation: 1,722


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 5 guests

cron