Jump to content

Data doesnt enter table MYSQL


eciym

Recommended Posts

Hi I have this very simple form, and want it to insert some data in to some field. Very simple you might think however after following the step by step functions a gazillion times it still doesn't work. I get no error message, it prints the variables before the insert query and prints the text "Records added to the database" after it is supposed to be inserted.

 

But the table remain empty... it's beaten me and now I implore the help of somebody who knows what they are doing.

 

<?php mysql_connect("localhost", "usr", "pwd") or die(mysql_error());

mysql_select_db("dbname") or die(mysql_error());

?>

 

...

<?php

print $erbjmarke;

print $erbjartikel ;

print $erbjxpris ;

print $erbjordpris ;

 

  $query = "INSERT INTO erbjudan (erbjmarke, erbjartikel, erbjxpris, erbjordpris) VALUES ('$erbjmarke','$erbjartikel','$erbjxpris','$erbjordpris')";

 

  print "Records added to the database";

?>

 

 

Thank you in anticipation

 

Link to comment
Share on other sites

missing execution line

 

try this

<?php mysql_connect("localhost", "usr", "pwd") or die(mysql_error());
mysql_select_db("dbname") or die(mysql_error());
?>

...
<?php
print $erbjmarke;
print $erbjartikel ;
print $erbjxpris ;
print $erbjordpris ;

  $query = "INSERT INTO erbjudan (erbjmarke, erbjartikel, erbjxpris, erbjordpris) VALUES ('$erbjmarke','$erbjartikel','$erbjxpris','$erbjordpris')";

//this line was missing
mysql_query($query) or die ('Error in query: $query. ' . mysql_error());
  
  print "Records added to the database";
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.