Login | Register | FAQ
Anonymous

How do I fetch variables from URL and put them in my Databas

+ Post a reply

1 post Page 1 of 1


How do I fetch variables from URL and put them in my Databas

by lilpanda » Mon Jun 26, 2017 11:20 pm

So I want to fetch variables from a website link that ends with pb.php?id=1&affsub=string&lp1=domain&lp2=domain.com/2&lp3=domain.com/3 and I have tried this code below and it returns errors,
Warning: mysqli_stmt::bind_param(): Number of elements in type definition string doesn't match number of bind variables in /home/recondes/public_html/postback.php on line 25


and it does make a new row but it is all blank, I dont know whats wrong.
Code: Select all
<?php

define("MYSQL_HOST", "localhost");
define("MYSQL_PORT", "3306");
define("MYSQL_DB", "db");
define("MYSQL_TABLE", "tbl");
define("MYSQL_USER", "user");
define("MYSQL_PASS", "pass");
$mysqli = new mysqli(MYSQL_HOST, MYSQL_USER, MYSQL_PASS, MYSQL_DB);
if ($mysqli->connect_errno)
{
  echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
$id = $_GET['id'];
$affsub =            $_GET['affsub'];
$lp1 =           $_GET['lp1'];
$lp2 =           $_GET['lp2'];
$lp3 =           $_GET['lp3'];


if (!($stmt = $mysqli->prepare("INSERT INTO ".MYSQL_DB." VALUES (id, affsub, lp1, lp2, lp3);")))
{
  echo "Prepare failed: (" . $mysqli->errno . ") " . $mysqli->error;
}
$stmt->bind_param('dds', $id, $affsub, $lp1, $lp2, $lp3 );
if (!$stmt->execute())
{
  echo "Execute failed: (" . $stmt->errno . ") " . $stmt->error;
}
else
{
  printf("%d Row updated, added ".$id." to locker ".$affsub." .\n", mysqli_stmt_affected_rows($stmt));
}
?>
User avatar

lilpanda

  • Posts: 1
  • Joined: Mon Jun 26, 2017 9:55 pm


+ Post a reply

Page 1 of 1