You are here: Re: Send data form to mysql « PHP SQL « IT news, forums, messages
Re: Send data form to mysql

Posted by Luigi Donatello Asero on 10/09/06 11:22

"Hilarion" <hilarion@SPAM.op.SMIECI.pl> skrev i meddelandet
news:dc3b6d$a8t$1@news.onet.pl...
> Luigi Donatello Asero wrote:
> > The page https://www.scaiecat-spa-gigi.com/sv/form.php shows a form but
> > when I enter data in the form the result is
> > "Error, insert query failed".
> > The question is what I missed this time.
> >
> > <html>
> > <body>
> > <?PHP
> > if(array_key_exists('add', $_POST) && ($_POST['add']=="Skicka")) {
> > $fornamn = $_POST['fornamn'];
> > $efternamn = $_POST['efternamn'];
> > $db = mysql_connect("local host", "user", "password")
> > or die('I could not connect');
> > mysql_select_db("scaiecat_?", $db);
> > $query="INSERT INTO Formulr('frnamn','efternamn')
> > VALUES('$fornamn','$efternamn')";
> > mysql_query($query) or die('Error, insert query failed');
> > echo "Fljande har sparats till databasen:<br>\n
> > Frnamn: $fornamn<br>\n
> > Efternamn: $efternamn<br>\n";
> > } else {
> > ?>
> > <form method="post">
> > <label for="Fornamn">Frnamn</label>
> > <input type="text" name="fornamn" id="Fornamn"><br>
> > <label for="Efternamn">Efternamn</label>
> > <input type="text" name="efternamn" id="efternamn"><br>
> > <input type=submit name="add" VALUE="Skicka">
> > </form>
> > <?PHP
> > }
> > ?>
> > </body>
> > </html>
>
>
> You should try testing your code before asking your question.
>
> Simple changing line:
> > mysql_select_db("scaiecat_?", $db);
> to
> > mysql_select_db("scaiecat_?", $db) or die( 'Error switching DB: ' .
mysql_error($db) );
> would give you info if the switch worked or if not, why it did
> not work.
>
>
> Simple adding "echo $query;" after seting $query variable
> would show you how your query looks like with entered values.
>
> Simple changing line:
> > mysql_query($query) or die('Error, insert query failed' );
> to
> > mysql_query($query) or die('Error, insert query failed: ' .
mysql_error($db) );
> would show you more details why the INSERT failed (if it failed).
>
> Using results of those three changes you would probably solve
> the problem yourself.
>
>
> Hilarion
>
> PS.: Try what I wrote above before posting some comments to this post.

They were good suggestions but the result shows something which I do not
understand
Error, insert query failed: Table 'scaiecat_?.Formular' doesn't exist

When looking into the database I find the table "Formular" and the name of
the database "scaiecat_?"
was used for the table "semesterbostder" as well
which displays data on for example
https://www.scaiecat-spa-gigi.com/sv/boende-i-italien.php
So, why do I get a message that the table does not exist?


--
Luigi Donatello (un italiano che vive in Svezia)
https://www.scaiecat-spa-gigi.com/sv/oversattning.php

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация