Here is my difficulty that's aged me by fifty years. I am trying to write a script to insert table values into a table I have on my Windows MYSQL and then print out a confirmation page.
Here is my current effort :
<head>
<title> Aliens abducted me </title>
</head>
<body>
<h2> Aliens Abducted Me- Report an Abduction</h2>
<?php
$when_it_happened=$_POST['whenithappened'];
$how_long=$_POST['howlong'];
$alien_description=$_POST['aliendescription'];
$fang_spotted=$_POST['fangspotted'];
$email=$_POST['email'];
$dbc = mysqli_connect('localhost','root',' ','aliendatbase')
or die('Error connecting to MYSQL server');
$query = "INSERT INTO aliens_abduction (first_name, last_name, when_it_happened, how_long, " .
"how_many, alien_description, what_they_did, fang_spotted, other, email " .
"VALUES ('$first_name', '$last_name', 'when_it_happened', '$how_long, '$how_many', " .
"'$alien_description', '$what_they_did', '$fang_spotted', '$other', '$email')";
$result=mysqli_query($dbc,$query)
or die('error querying database.');
mysqli_close($dbc);
echo 'Thank you for submitting the form to the Dalek High Command.Prepare to be exterminated.<br />';
echo 'You where abducted ' . $when_it_happened;
echo 'and were gone for ' . $how_long.'<br />';
echo 'Describe them: ' . $alien_description .'<br />';
echo 'Was Fang there ? ' . $fang_spotted .'<br />';
echo 'Your e-mail address is ' . $email;
?>
</body>
</html
what's not happening is the successful connection to my localhost MYSQL server.I keep getting the message :
Quote
"Warning: mysqli_connect() [function.mysqli-connect]: (28000/1045): Access denied for user 'root'@'localhost' (using password: YES) in C:\xampp\xampplite\htdocs\report1.php on line 24".
What I thought was happening was the user was incorrect, but after reading the server documentation it became clear to me that the user was "root" ,so I used root in the user parameter.Than I thought that maybe there was some confusion caused by including an empty password parameter, So I dropped the password parameter. But the error message is still insisting I am using a password.
I need is some kind soul, like you reading this post, to point out errors n my code and /or understanding of how MYSQL servers operate!:o
cheers and thanks,
April
Edited by Roger, 21 March 2011 - 04:03 PM.
added code block


Sign In
Create Account

Back to top









