I wanted to see if any of you could see what I was doing wrong. I have been looking over this code for a while now and am completly stuck. Thanks <? //connecting to the database we setup define('DB_HOST', 'localhost'); define('DB_NAME', 'dbname'); define('DB_USERNAME', 'user'); define('DB_PASSWORD', 'password'); // Connect to the mysql database. $conn = mysql_connect(DB_HOST, DB_USERNAME, DB_PASSWORD) or die(mysql_error()); mysql_select_db(DB_NAME, $conn) or die(mysql_error()); // Server variables $ip = $_SERVER['REMOTE_ADDR']; $referer = $_SERVER['HTTP_REFERER']; $useragent = $_SERVER['HTTP_USER_AGENT']; // capturing data we passed in the url //ie. http://domain.com/page.php?k=my+keyword&s=yahoo // I've added the engine the click is coming from as // I'm starting to branch out to other engines now $keyword = trim($_GET['k']); $source = trim($_GET['s']); $sql = "INSERT INTO 'clicks' ('keyword','source','ip','referer','useragent','time','site') VALUES ('$keyword','$source','$ip','$referer','$useragent',NOW(),'$site')"; mysql_query($sql); $id = mysql_insert_id(); ?> PHP:
First off, replace <? with <?php. Then set these lines on top to see all errors that may occurred: error_reporting(E_ALL); ini_set('display_errors', '1'); PHP: Then let MySQL tell you if there were any problems: mysql_query($sql) OR die(mysql_error()); PHP: And last, use mysql_real_escape_string() on all variables that you put in your query string.
Hey Thanks for the help This is the error iam getting from the output You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''clicks' ('keyword','source','ip','referer','useragent','time','site') VALUES ('' at line 1 PHP:
The field and table names should not be enclosed in single quotes. Use either backticks, or nothing at all. (Note, values you're trying to insert SHOULD go enclosed in single quotes)
Check the link in my sig. I think the pr has dropped on a lot of the sites but it can get any site indexed in g very quickly. So if you have any new sites you want crawled its a great server. Whenever you want PM me an article or two to post.