Im quite a newbie in making php, but I managed to run the test you
suggested,
but nothin happened. This time it was propably the code I did:
first I added the "or die("Invalid query: $sql");" part and ran the form,
but everything happened just like when refreshing a page.

Then I did this:
  $result = mysql_query($sql)
or die("Invalid query: $sql");

  echo $sql;

but the database was silent....it just refreshed the page and cleared out
the form.

-Olli



"Brad Bonkoski" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> The best way IMHO, to debug problems like this is to echo out your
> insert query to the screen and not actually run the query, or run it and
> make sure you use:
> $sql = "INSERT INTO employees (first,last,address,position) VALUES
> ('$first','$last','$address','$position')";
> $result = mysql_query($sql)
> or die("Invalid query: $sql");
>
> (This is always good practice anyways, especially if the page depends
> upon that query's execution)
>
> Anyhow, echo out the query: $sql to the screen and then run it against
> your actual MySQL database and see how it responds?  Chances are there
> is some error there, and you'll get more meaningful feedback from the
> database backend.
>
> HTH
> -Brad
>
> Olli Sinerma wrote:
> > Hi,
> > Im having a weird problem with getting my forms work within
> > php. I have a running MySQL server, php installed on a apache server
> > and I can make SQL queries through php, but Im unable to insert
> > any data into it through forms.
> >
> > This is an example file that Im using
> > (its from
> >
http://hotwired.lycos.com/webmonkey/99/21/index3a_page4.html?tw=programming
> > )
> >
> > ______________________________
> >
> > <html>
> >
> > <body>
> >
> >
> >
> > <?php
> >
> >
> >
> > if ($submit) {
> >
> >   // process form
> >
> >   $db = mysql_connect("localhost", "root", "mypassword");
> >
> >   mysql_select_db("mydb",$db);
> >
> >   $sql = "INSERT INTO employees (first,last,address,position) VALUES
> > ('$first','$last','$address','$position')";
> >
> >   $result = mysql_query($sql);
> >
> >   echo "Thank you! Information entered.\n";
> >
> > } else{
> >
> >
> >
> >   // display form
> >
> >
> >
> >   ?>
> >
> >
> >
> >   <form method="post" action="<?php echo $PHP_SELF?>">
> >
> >   First name:<input type="Text" name="first"><br>
> >
> >   Last name:<input type="Text" name="last"><br>
> >
> >   Address:<input type="Text" name="address"><br>
> >
> >   Position:<input type="Text" name="position"><br>
> >
> >   <input type="Submit" name="submit" value="Enter information">
> >
> >   </form>
> >
> >
> >
> >   <?php
> >
> >
> >
> > } // end if
> >
> >
> >
> > ?>
> >
> >
> >
> > </body>
> > </html>
> > ____________________________________
> >
> > I have set the database in working order according to the manual, but
after
> > I enter some writing into the
> > text fields and press submit: It refreshes the page and doesn't add any
> > information into the db.
> >
> > I recon that the problem might be within the $php_self command, for I
got
> > all the previous php/mySQL tutorials
> > working, but when this command appeared...problems started...or more
> > accurate word would be: nothing
> > happened.
> >
> > I have phpMyAdmin 2.3.0 running on my apache server and it can
send/receive
> > data from the db normally, so the problem shouldn't
> > be in the db server or in the php, so its in me or in the code :) I
have
> > read through all the FAQ:s and manuals that I have found and I still
> > cant understand what is the problem in this one!
> >
> > -Olli
> >
> >
> >
> >
> >
>
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to