mysqli_query insert help!!

rastael

Registered Member
Joined
Aug 10, 2015
Messages
74
Reaction score
8
Hey guys,

I am working with this pixel tracker, i am trying to pass email variables into the url, everything gets recorded, but the email variables arent being passed or written whats wrong?

should work like this http://domain.com/[email protected]

if (isset($_GET['e'])) {
$e = $_GET['e'];}
echo $e;

//$url = parse_url ($_SERVER['HTTP_REFERER']);
$query = "INSERT INTO hitlog(hostname, ip, os, browser, city, referer, email, date) VALUES ('".
$hostname . "', '".
$_SERVER['REMOTE_ADDR'] . "', '".
$os . "', '".
$browser. "', '".
whois_info( ) . "', '".
$_SERVER['HTTP_REFERER']. "', ".
//$_GET['email']. "', ".
$e . "', '".
" now() )";

$result = mysqli_query($name1,$query);
include 'closedb.php';
// End DB code


How can i properly insert the e or email variable into it?
 
Looks like you have 2 issues:

1. date in query it is "system" word and should be quoted by "`"
2. you have extra quotes in the query
 
PDO works better for this then mySQLi, but that's my suggestion. Hope this helps.
 
You have an error SQL syntax. Try this and let me know if it works.

PHP:
<?php
    $servername = "localhost";
    $username = "<Username Name here>";
    $password = "<Password here>";
    $dbname = "<Database Name here>";

    // Create connection
    $conn = new mysqli($servername, $username, $password, $dbname);

    // Check connection
    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    }
    
    if(isset($_GET['e'])){
        $value = mysqli_real_escape_string($conn, $_GET['e']);
    }
    //echo $value;
    //$url = parse_url ($_SERVER['HTTP_REFERER']);
        
    $sql = "INSERT INTO hitlog(hostname, ip, os, browser, city, referer, email, date) VALUES ('".$hostname."', '".$_SERVER['REMOTE_ADDR']."', '".$os."', '".$browser."', '".whois_info()."', '".$_SERVER['HTTP_REFERER']."', ".$_GET['email']."', ".$value."', NOW())";

    if (mysqli_query($conn, $sql)) {
        echo "Done!";
    } else {
        echo "Error: " . $sql . "" . mysqli_error($conn);
    }
    $conn->close();
?>
 
Ur get variable is e, but at the insert u put email, change dat, I guess dat is d error.
 
Back
Top