Jump to content

Unknown column 'example' in 'field list' error on mysql? Strange


cs.punk

Recommended Posts

<?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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.