Připojení
[code]
$dbhost = 'localhost';
$dbname = 'download_manager';
$dbuser = 'root';
$dbpass = 'xxx';
$dates=date('l jS \of F Y h:i:s A');
$ip= $_SERVER['REMOTE_ADDR'];
$url= $_GET['url'];
$con = mysql_connect($dbhost, $dbuser, $dbpass);
if($con == FALSE)
{
echo 'Cannot connect to database' . mysql_error();
}
else
{
echo 'Connected to database';
}
mysql_select_db($dbname, $con);
$sql="INSERT INTO 'log_access' (ID,`URL`,`DATE`,`IP`)
VALUES (1,'$url','$dates','$ip')";
if (!mysql_query($sql, $con))
{
die('Error: ' . mysql_error());
}
mysql_close($con) [/code]
Eror:
Error: 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 ''log_access' (ID,`URL`,`DATE`,`IP`) VALUES (1,'http://i.iinfo.cz/images/141/bez' at line 1
Struktura SQL:
-- phpMyAdmin SQL Dump
-- version 3.4.10.1deb1
-- http://www.phpmyadmin.net
--
-- Počítač: localhost
-- Vygenerováno: Stř 10. dub 2013, 13:52
-- Verze MySQL: 5.5.29
-- Verze PHP: 5.3.10-1ubuntu3.6
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Databáze: `download_manager`
--
-- --------------------------------------------------------
--
-- Struktura tabulky `log_access`
--
CREATE TABLE IF NOT EXISTS `log_access` (
`ID` int(255) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`URL` varchar(100) COLLATE utf8_czech_ci NOT NULL,
`DATE` date NOT NULL,
`IP` varchar(1000) COLLATE utf8_czech_ci NOT NULL,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci COMMENT='Download Manager' AUTO_INCREMENT=1 ;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;