cs.punk Posted April 16, 2010 Share Posted April 16, 2010 <?php include "mysqli_con.php"; $con = mysqli_connect($sql_host, $sql_user, $sql_pass, $sql_name); function hits ($page, $con) { $page = addslashes($page); $sql = "SELECT COUNT(*) FROM hits WHERE page='$page'"; $query = mysqli_query($con, $sql); $row = mysqli_fetch_row ($query); $hits = $row['0']; $hit = "Page Hits: $hits"; echo "<h1>$hit</h1>"; $time = time(); $sql = "INSERT INTO hits VALUES ($page, $time)"; $query = mysqli_query($con, $sql) or die ("Error".mysqli_error($con)); } hits ("example", $con); ?> Where am I going wrong? It seems its giving it a specific column to insert into but how? Link to comment https://forums.phpfreaks.com/topic/198757-unknown-column-example-in-field-list-error-on-mysql-strange/ Share on other sites More sharing options...
Ken2k7 Posted April 16, 2010 Share Posted April 16, 2010 example is a string, which means you need to put quotes around it. $sql = "INSERT INTO hits VALUES ('$page', $time)"; Link to comment https://forums.phpfreaks.com/topic/198757-unknown-column-example-in-field-list-error-on-mysql-strange/#findComment-1043135 Share on other sites More sharing options...
cs.punk Posted April 16, 2010 Author Share Posted April 16, 2010 example is a string, which means you need to put quotes around it. $sql = "INSERT INTO hits VALUES ('$page', $time)"; Thank you! Was a bummer to spot! Link to comment https://forums.phpfreaks.com/topic/198757-unknown-column-example-in-field-list-error-on-mysql-strange/#findComment-1043189 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.