Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You may need to look at setting a cookie in PHP correctly. the <code>setcookie()</code> function expects up to 6 parameters as follows:</p> <pre><code>setcookie(name,value,expire,path,domain,secure) </code></pre> <p>Your <code>setcookie()</code> has 7 parameters in the call and are not following the structure correctly:</p> <pre><code>setcookie("info", $uuid, $thisAid, $thisSubID, $thisURL, time()+30*24*60*60, "/") </code></pre> <p>In addition you are checking for an empty cookie named 'uuid' with your code <code>empty($_COOKIE["uuid"])</code> however you are setting a cookie with the name info.</p> <p>You would need to re-arrange this to be:</p> <pre><code>setcookie("uuid", $uuid, time()+30*24*60*60, "/") </code></pre> <p>However I don't know what the <code>$thisAid</code>, <code>$thisSubID</code> or <code>$thisURL</code> variables contain or are for?</p> <p><a href="http://www.w3schools.com/php/func_http_setcookie.asp" rel="nofollow">W3 Schools</a> have a pretty good example of <code>setcookie()</code> and there is always the <a href="http://php.net/manual/en/function.setcookie.php" rel="nofollow">PHP Manual</a> itself</p> <p>If you would want to use the one cookie to store all of your variables and then build your SQL query then you could either set a cookie seperately for each variable as so:</p> <pre><code>setcookie("uuid", $uuid, time()+30*24*60*60, "/") setcookie("thisAid", $thisAid, time()+30*24*60*60, "/") setcookie("thisSubID", $thisSubID, time()+30*24*60*60, "/") setcookie("thisURL", $thisURL, time()+30*24*60*60, "/") setcookie("campaignID", $thisCampaignID, time()+30*24*60*60, "/") </code></pre> <p>or alternatively set one cookie with a ; symbol to seperate each value as so:</p> <pre><code>setcookie("uuid", $thisAid . ";" . $thisSubId . ";" . $thisCampaignID. ";" . $thisURL . ";" . $uuid, time()+30*24*60*60, "/") </code></pre> <p>You could then use the <code>explode()</code> function to split the cookie value apart and then use a foreach loop on this to build your SQL query as below:</p> <pre><code> $values = explode( ";", $_COOKIE['uuid'] ); foreach( $values as $value ) { $sqlValues .= $value . ","; } $sql = "INSERT INTO WebTraffic (aid, subID, campaignID, URL, uuid) VALUES($sqlValues); </code></pre> <p>Alternatively using multiple setcookie() calls above you could do it as so:</p> <pre><code> $sql = "INSERT INTO WebTraffic (aid, subID, campaignID, URL, uuid) VALUES($_COOKIE['thisAid'], $_COOKIE['subID'], $_COOKIE['campaignID'], $_COOKIE['thisURL'], $_COOKIE['uuid'] ); </code></pre> <p>One other thing to note however is you really should be using prepared statements when inserting or retrieving information from a database to avoid SQL injection attacks. Do you know what these are/are you using any prevention techniques to avoid them?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload