Jump to content

[SOLVED] PHP MYSQL PROBLEM <-Please Help


paulman888888

Recommended Posts

<?php require('connect.php'); ?><?php

 

$ipaddress=$_SERVER['REMOTE_ADDR'];

$thedate=date("m:d:y");

$thetime=date("H:i:s")

mysql_query("INSERT INTO intowar1 (ipaddress, thedate, name, thename) VALUES($ipaddress, $thedate,'" . mysql_real_escape_string($_GET['name']) . "', $thetime)") or die('Theres an error. Please try again.#'); 

 

 

 

?>

I know its something to do with the quotes, i dont understand them.

 

thankyou

Link to comment
https://forums.phpfreaks.com/topic/111359-solved-php-mysql-problem-lt-please-help/
Share on other sites

Try this:

 

<?php require('connect.php'); ?><?php

 

$ipaddress=$_SERVER['REMOTE_ADDR'];

$thedate=date("m:d:y");

$thetime=date("H:i:s");

mysql_query("INSERT INTO `intowar1` (ipaddress, thedate, name, thename) VALUES ('$ipaddress', '$thedate','" . mysql_real_escape_string($_GET['name']) . "', '$thetime')") or die("Theres an error. Please try again.");

 

 

 

?>

You need to surround all of those inputs with single quotes... they're all strings. The only time you can leave off the single quotes is if the value is strictly an integer or a float.

 

Also, always use " or die (mysql_error()). That will be much more descriptive.

 

mysql_query("INSERT INTO intowar1 (ipaddress, thedate, name, thename) VALUES('$ipaddress', '$thedate','" . mysql_real_escape_string($_GET['name']) . "', '$thetime')") or die('Theres an error. Please try again.#'); 

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.