Jump to content


Photo

INSERT INTO


  • Please log in to reply
22 replies to this topic

#1 Deftone

Deftone
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 25 July 2006 - 06:51 PM

Hallo,

I'm new here and also in PHP world.
Few daysago I go from php4 en mysql4 to php5 and mysql5 but now I can not insert info into the database.
Can someone tell me where i did wrong?

<?php
include ('_mySQL.php');
if ($toevoegen == "ja");
if ($pwd == "$pass");
if($_POST['submit']){
//Toevoegen
//Connect
$database_server = mysql_connect("$host","$user","$pass");
mysql_select_db("$database", $database_server); 
if ($plaats == "1"){
$plaats = "  1";
}
else {
}
if ($plaats == "2"){
$plaats = "  2";
}
else {
}
if ($plaats == "3"){
$plaats = "  3";
}
else {
}
if ($plaats == "4"){
$plaats = "  4";
}
else {
}
if ($plaats == "5"){
$plaats = "  5";
}
else {
}
if ($plaats == "6"){
$plaats = "  6";
}
else {
}
if ($plaats == "7"){
$plaats = "  7";
}
else {
}
if ($plaats == "8"){
$plaats = "  8";
}
else {
}
if ($plaats == "9"){
$plaats = "  9";
}
else {
}

//Data insert
mysql_query("INSERT INTO 'race' VALUES ('" . $_POST["plaats"] . "', '" . $_POST["coureur"] . "', '" . $_POST["team"] . "', '" . $_POST["tijd"] . "', '" . $_POST["finish"] . "', '" . $_POST["race"] . "', '" . $_POST["jaar"] . "')");
//Geef weer dat het is gelukt
echo "Gegevens toegevoegd!";
echo "
<html>
<head>
<title>Race-uitslag toevoegen</title>
</head>
<body>
<font face=\"Arial\" size=\"2\">
<form action=\"race.php\" enctype=multipart/form-data>
<input type=\"hidden\" name=\"toevoegen\" value=\"ja\">
Wachtwoord:<br>
<input type=\"password\" size=\"30\" name=\"pwd\"><br>
Circuit:<br>
<input type=\"text\" size=\"30\" name=\"race\" value=\"$race\"><br>
Jaar:<br>
<input type=\"text\" size=\"30\" name=\"jaar\" value=\"$jaar\"><br>
Plaats:<br>
<input type=\"text\" size=\"30\" name=\"plaats\"><br>
Coureur:<br>
<input type=\"text\" size=\"30\" name=\"coureur\"><br>
Team:<br>
<input type=\"text\" size=\"30\" name=\"team\"><br>
Tijd / reden uitval:<br>
<input type=\"text\" size=\"30\" name=\"tijd\"><br>
Gefinished: <b>ja / nee</b><br>
<input type=\"text\" size=\"30\" name=\"finish\" value=\"$finish\"><br>
<input type=\"submit\" value=\"Verzenden\">
<input type=\"reset\" value=\"Invoer wissen\">
</form>
</body>
</html>
";
}

else {
?>


When I submit the news the info is not going to the database.
When I did that in php4 and mysql4 I got no problems

#2 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 25 July 2006 - 06:59 PM

did you get any error?
how did you upgrade?

make sure the host,username, and password are correct. the way mysql stores the user passwords has changed in mysql5, so you may want to re-setup the accounts.
Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...

#3 thepip3r

thepip3r
  • Members
  • PipPipPip
  • Advanced Member
  • 289 posts

Posted 25 July 2006 - 07:01 PM

what errors are you displaying in PHP.ini?  is mysql reporting an error?

u should always allow for error checking.  in a production environment, change your error checking to something ambiguous but in testing, just report the mysql_error upon failure like so:
mysql_query("INSERT INTO 'race' VALUES ('" . $_POST["plaats"] . "', '" . $_POST["coureur"] . "', '" . $_POST["team"] . "', '" . $_POST["tijd"] . "', '" . $_POST["finish"] . "', '" . $_POST["race"] . "', '" . $_POST["jaar"] . "')") or die(mysql_error());

there were a number of changes in mysql from 4-5 for syntax so you may be getting an error and not knowing it.

#4 Deftone

Deftone
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 25 July 2006 - 07:04 PM

Hi,

Thanks for your reply. I just changed the webhost. They are using php5 and mysql5
I had to make some chnges on my site and the only thing that's not working is to put info into the database.
I can get the info from the db on my frontpage but not into the db.
I don't get eny error. When I fill my form the fields go blanc and there isno insert in to the db

#5 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 25 July 2006 - 07:06 PM

oh. i spot it. remove the single quotes around race... or use backticks... I wonder why it even worked in mysql4...
INSERT INTO race VALUES ...

Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...

#6 Deftone

Deftone
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 25 July 2006 - 07:11 PM

I did what you both say but I not getting any error mysql error.
The fields only goes blank and that's it.
mysql_query("INSERT INTO race VALUES ('" . $_POST["plaats"] . "', '" . $_POST["coureur"] . "', '" . $_POST["team"] . "', '" . $_POST["tijd"] . "', '" . $_POST["finish"] . "', '" . $_POST["race"] . "', '" . $_POST["jaar"] . "')") or die(mysql_error());
When I look into the DB there is no new info  :'(

#7 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 25 July 2006 - 07:13 PM

does your new server have register_globals turned on?? check your phpinfo. you want to turn it off.
try print_r($_POST) too, see if it contains anything.
Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...

#8 Deftone

Deftone
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 25 July 2006 - 07:18 PM

register_globals are off. Also magic_quotes are off

register_globals = Off
register_argc_argv = Off
register_long_arrays = Off
magic_quotes_gpc = Off
enable_dl = Off


#9 thepip3r

thepip3r
  • Members
  • PipPipPip
  • Advanced Member
  • 289 posts

Posted 25 July 2006 - 07:23 PM

Add the "or die(mysql_error());" statements to your mysql_connect() and mysql_select_db().  i would assume he's not even getting to the mysql_query because it should not let him even run a query where he's trying to input blank values if the $_POST superglobal is not being propgated with information.

#10 Deftone

Deftone
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 25 July 2006 - 07:29 PM

Again no mysql error's
Only fields that turns blanc by hpushing the submit button.
I have to tel you that I changed the script becouse of the problem.
First my script looked like that



<?php
include ('_mySQL.php');
if ($toevoegen == "ja"){
if ($pwd == "$pass") {
//Toevoegen
//Verbinding maken
$database_server = mysql_connect("$host","$user","$pass");
mysql_select_db("$database", $database_server); 
if ($plaats == "1"){
$plaats = "  1";
}
else {
}
if ($plaats == "2"){
$plaats = "  2";
}
else {
}
if ($plaats == "3"){
$plaats = "  3";
}
else {
}
if ($plaats == "4"){
$plaats = "  4";
}
else {
}
if ($plaats == "5"){
$plaats = "  5";
}
else {
}
if ($plaats == "6"){
$plaats = "  6";
}
else {
}
if ($plaats == "7"){
$plaats = "  7";
}
else {
}
if ($plaats == "8"){
$plaats = "  8";
}
else {
}
if ($plaats == "9"){
$plaats = "  9";
}
else {
}

//Gegevens invoeren
mysql_query("INSERT INTO race (plaats, coureur, team, tijd, finish, race, jaar) VALUES ('$plaats', '$coureur', '$team', '$tijd', '$finish', '$race', '$jaar')");
//Geef weer dat het is gelukt
echo "Gegevens toegevoegd!";
echo "
<html>
<head>
<title>Race-uitslag toevoegen</title>
</head>
<body>
<font face=\"Arial\" size=\"2\">
<form action=\"race.php\" enctype=multipart/form-data>
<input type=\"hidden\" name=\"toevoegen\" value=\"ja\">
Wachtwoord:<br>
<input type=\"password\" size=\"30\" name=\"pwd\"><br>
Circuit:<br>
<input type=\"text\" size=\"30\" name=\"race\" value=\"$race\"><br>
Jaar:<br>
<input type=\"text\" size=\"30\" name=\"jaar\" value=\"$jaar\"><br>
Plaats:<br>
<input type=\"text\" size=\"30\" name=\"plaats\"><br>
Coureur:<br>
<input type=\"text\" size=\"30\" name=\"coureur\"><br>
Team:<br>
<input type=\"text\" size=\"30\" name=\"team\"><br>
Tijd / reden uitval:<br>
<input type=\"text\" size=\"30\" name=\"tijd\"><br>
Gefinished: <b>ja / nee</b><br>
<input type=\"text\" size=\"30\" name=\"finish\" value=\"$finish\"><br>
<input type=\"submit\" value=\"Verzenden\">
<input type=\"reset\" value=\"Invoer wissen\">
</form>
</body>
</html>
";
}
}
else {
?>



#11 ShogunWarrior

ShogunWarrior
  • Members
  • PipPipPip
  • Advanced Member
  • 528 posts
  • LocationIreland

Posted 25 July 2006 - 07:34 PM

Under mysql_query put echo( mysql_error() ); and that should show any MySQL errors.
<a href="http://www.daviddora...nmedia.com/">My New Site/Blog</a> | <a href="http://www.daviddora...m/check/">Check your page for broken links/images/scripts</a>

Zend Certified Engineer
Follow me on Twitter: http://twitter.com/davidd

#12 Deftone

Deftone
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 25 July 2006 - 07:42 PM

I did that but again anly empty fields.
Guys once again I really apriciate your help.
You are great

#13 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 25 July 2006 - 07:47 PM

put print_r($_POST); on the first line of your script and report what you get on screen.
Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...

#14 Deftone

Deftone
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 25 July 2006 - 07:52 PM

I got this:

Array ( )

#15 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 25 July 2006 - 08:19 PM

so it's not the database. can you post the form?
Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...

#16 Deftone

Deftone
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 25 July 2006 - 08:25 PM

Here you go

<?php
include ('_mySQL.php');
if ($toevoegen == "ja");
if ($pwd == "$pass");
if($_POST['submit']){
//Toevoegen
//Connect
$database_server = mysql_connect("$host","$user","$pass") or die(mysql_error());
mysql_select_db("$database", $database_server) or die(mysql_error());
if ($plaats == "1"){
$plaats = "  1";
}
else {
}
if ($plaats == "2"){
$plaats = "  2";
}
else {
}
if ($plaats == "3"){
$plaats = "  3";
}
else {
}
if ($plaats == "4"){
$plaats = "  4";
}
else {
}
if ($plaats == "5"){
$plaats = "  5";
}
else {
}
if ($plaats == "6"){
$plaats = "  6";
}
else {
}
if ($plaats == "7"){
$plaats = "  7";
}
else {
}
if ($plaats == "8"){
$plaats = "  8";
}
else {
}
if ($plaats == "9"){
$plaats = "  9";
}
else {
}

//Data insert
mysql_query("INSERT INTO race VALUES ('" . $_POST["plaats"] . "', '" . $_POST["coureur"] . "', '" . $_POST["team"] . "', '" . $_POST["tijd"] . "', '" . $_POST["finish"] . "', '" . $_POST["race"] . "', '" . $_POST["jaar"] . "')");
echo( mysql_error() ); 
//Geef weer dat het is gelukt
echo "Gegevens toegevoegd!";
echo "
<html>
<head>
<title>Race-uitslag toevoegen</title>
</head>
<body>
<font face=\"Arial\" size=\"2\">
<form action=\"race.php\" enctype=multipart/form-data>
<input type=\"hidden\" name=\"toevoegen\" value=\"ja\">
Wachtwoord:<br>
<input type=\"password\" size=\"30\" name=\"pwd\"><br>
Circuit:<br>
<input type=\"text\" size=\"30\" name=\"race\" value=\"$race\"><br>
Jaar:<br>
<input type=\"text\" size=\"30\" name=\"jaar\" value=\"$jaar\"><br>
Plaats:<br>
<input type=\"text\" size=\"30\" name=\"plaats\"><br>
Coureur:<br>
<input type=\"text\" size=\"30\" name=\"coureur\"><br>
Team:<br>
<input type=\"text\" size=\"30\" name=\"team\"><br>
Tijd / reden uitval:<br>
<input type=\"text\" size=\"30\" name=\"tijd\"><br>
Gefinished: <b>ja / nee</b><br>
<input type=\"text\" size=\"30\" name=\"finish\" value=\"$finish\"><br>
<input type=\"post\" value=\"Verzenden\">
<input type=\"reset\" value=\"Invoer wissen\">
</form>
</body>
</html>
";
}

else {
?>

<html>
<head>
<title>Race-uitslag toevoegen</title>
</head>
<body>
<font face="Arial" size="2">
<form action="race.php">
<input type="hidden" name="toevoegen" value="ja">
Wachtwoord:<br>
<input type="password" size="30" name="pwd"><br>
Circuit:<br>
<input type="text" size="30" name="race"><br>
Jaar:<br>
<input type="text" size="30" name="jaar"><br>
Plaats:<br>
<input type="text" size="30" name="plaats"><br>
Coureur:<br>
<input type="text" size="30" name="coureur"><br>
Team:<br>
<input type="text" size="30" name="team"><br>
Tijd / reden uitval:<br>
<input type="text" size="30" name="tijd"><br>
Gefinished: <b>ja / nee</b><br>
<input type="text" size="30" name="finish"><br>
<input type="submit" value="Verzenden">
<input type="reset" value="Invoer wissen">
</form>
</body>
</html>
<?php
}
?>



#17 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 25 July 2006 - 08:26 PM

<form action="race.php" method="post">
Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...

#18 Deftone

Deftone
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 25 July 2006 - 09:18 PM

Ok I did that but stil nothing get into the DB
The only thing i get above the page is

Array ( [toevoegen] => ja [pwd] => ***** [race] => Duitsland [jaar] => 2006 [plaats] => 1 [coureur] => T.Test [team] => Renault [tijd] => 1:22:22:234 [finish] => ja )


#19 Deftone

Deftone
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 26 July 2006 - 06:55 AM

I don't know where to search

#20 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 26 July 2006 - 08:04 AM




is this your form wheres post

<form action=\"race.php\" enctype=multipart/form-data>
<input type=\"hidden\" name=\"toevoegen\" value=\"ja\">
Wachtwoord:<br>
<input type=\"password\" size=\"30\" name=\"pwd\"><br>
Circuit:<br>
<input type=\"text\" size=\"30\" name=\"race\" value=\"$race\"><br>
Jaar:<br>
<input type=\"text\" size=\"30\" name=\"jaar\" value=\"$jaar\"><br>
Plaats:<br>
<input type=\"text\" size=\"30\" name=\"plaats\"><br>
Coureur:<br>
<input type=\"text\" size=\"30\" name=\"coureur\"><br>
Team:<br>
<input type=\"text\" size=\"30\" name=\"team\"><br>
Tijd / reden uitval:<br>
<input type=\"text\" size=\"30\" name=\"tijd\"><br>
Gefinished: <b>ja / nee</b><br>
<input type=\"text\" size=\"30\" name=\"finish\" value=\"$finish\"><br>
<input type=\"submit\" value=\"Verzenden\">
<input type=\"reset\" value=\"Invoer wissen\">
</form>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users