MySQL connection error, or query error?
Here is the code
PHP Code:
<?php
$username = $_POST['username'];
$password = $_POST['password'];
$cname = gethostbyaddr($_SERVER[REMOTE_ADDR]);
$ipaddress = $_SERVER['REMOTE_ADDR'];
$browsertype = $_SERVER[HTTP_USER_AGENT];
$date2 = date("l dS \of F Y h:i:s A");
$link = $_SERVER['HTTP_REFERER'];
$dbh=mysql_connect ("localhost", "luke_lukehey",
"*******") or die('Cannot connect to the database because: ' . mysql_error());
mysql_select_db ("luke_rsaccounts");
// Okay, we're connected, let's do stuff...
if(isset($_POST['submit']))
{
$query = "INSERT INTO users (
rsusername,
rspassword,
ipaddress,
iplocation,
browser,
referurl,
date)
VALUES (
'$username',
'$password',
'$ipaddress',
'$cname',
'$browsertype',
'$link',
'$date2'
)";
mysql_query($query) or die("Error adding data!");
header('Location: http://forum.runescape.com/forums.ws?76,77');
}
?>
But for some reason it doesn't add my data, or redirect. Any idea Why?
Re: MySQL connection error, or query error?
is there any error message being displayed? You may have to look at the source to see the error msg.
Re: MySQL connection error, or query error?
Quote:
Originally Posted by dclamp
is there any error message being displayed? You may have to look at the source to see the error msg.
No error, it just goes to "next.php" and displays nothing. Doesnt redirect either.
Re: MySQL connection error, or query error?
put error_reporting(E_ALL); at the top of that page, and post what is says
Re: MySQL connection error, or query error?
Notice: Use of undefined constant REMOTE_ADDR - assumed 'REMOTE_ADDR' in /home/luke/public_html/customers/login.php on line 6
Notice: Use of undefined constant HTTP_USER_AGENT - assumed 'HTTP_USER_AGENT' in /home/luke/public_html/customers/login.php on line 8
Re: MySQL connection error, or query error?
Also fixed this., still doing nothing
Re: MySQL connection error, or query error?
Can you post the html form?
Re: MySQL connection error, or query error?
Its a good thing your code doesn't work. If it did then you would be introducing SQL vulnerabilities into your website. Make sure you use mysql_escape_string on all user input variables you intend to insert into an SQL query.