SitePoint Sponsor |
|
User Tag List
Results 1 to 6 of 6
Thread: help my codes
-
Jul 30, 2002, 07:51 #1
- Join Date
- Apr 2002
- Posts
- 523
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
help my codes
Hi how are you doing?
My coding is something wrong. Before it was ok and running. But it is not working now. After entring datas, "Thank you for filling out my form" should come. However, it doesn't show up.
My phpeditor says "You don't have permission to access "
Please help me
Here is my code. My php is 4.2
<html>
<body>
<?php
$con = mysql_connect("localhost","itohideo","1234");
if(!$con)
{
print("Fail DB Connection<br>\n");
exit;
}
if(!mysql_select_db("itohideo"))
{
print("Fail DB Selection<br>\n");
exit;
}
if (isset($_POST["submit"]))
{
$number = $_POST["number"];
$name = $_POST["name"];
$country = $_POST["country"];
$query_insert = "insert into takao (number, name, country) values ('$number', '$name', '$country')";
$query_result_insert = mysql_query($query_insert, $con) or die (mysql_error($con));
echo "Thank you for filling out my form";
mysql_close($con);
}
?>
<form method="post" action="<?php print $HTTP_SERVER_VARS["PHP_SELF"]; ?>">
<P>please fill out this form and it goes to my database</P>
Number<input name="number" type="text"><br>
Name<input name="name" type="text"><br>
You country<input name="country" type="text"><br>
<input type="submit" name="submit">
<input type="reset" name="reset">
</form>
</body>
</html>
-
Jul 30, 2002, 07:57 #2
- Join Date
- Jun 2001
- Location
- Before These Crowded Streets
- Posts
- 9,446
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I don't see anything wrong so make sure your connection variables are right. itohedeo is both username and database name??
Also, minor issue, change this:
PHP Code:$HTTP_SERVER_VARS["PHP_SELF"];
PHP Code:$_SERVER['PHP_SELF'];
Sketch
-
Jul 30, 2002, 08:18 #3
- Join Date
- May 2001
- Location
- Channel Islands Girth: Footlong
- Posts
- 5,882
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Re: help my codes
Originally posted by itohideo
Hi how are you doing?
PHP Code:$query_result_insert = mysql_query($query_insert, $con) or die (mysql_error($con));
BTW you do realise you do your connections in a really weird order.. basically you connect to the database AND then check to see if your form has been submitted. Though it will probably make little difference I would always check to see if the form had been submitted and then if necessary open a connection to the database.
FINALLY PLEASE USE SYNTAX HIGHLIGHTING!I swear to drunk I'm not God.
» Matt's debating is not a crime «
Hint: Don't buy a stupid dwarf ö Clicky
-
Jul 30, 2002, 08:39 #4
- Join Date
- Apr 2002
- Posts
- 523
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
still not working yet
I tried both way but it is not working
What should I do?
-
Jul 30, 2002, 08:42 #5
- Join Date
- Apr 2002
- Posts
- 523
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
My phpeditor says?
They say"You don't have permission to access "
That's it
-
Jul 30, 2002, 09:22 #6
- Join Date
- Apr 2002
- Posts
- 523
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Now it works
Thank you guys
Now it works
I saved as php4 so that it didn't work
Then I save as php
it works
What is the diffrent?
Please explain to me
Thank you
Bookmarks