For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > December 2004 > Re: [PHP-DB] query is not executing data is not entering









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [PHP-DB] query is not executing data is not entering
John Holmes

2004-12-27, 3:55 pm

amol patil wrote:
> hallo,
>
> see below code. query is not executing and data is not shown in table of database.after submit button hit.
>
> how to evaluate $submit true. have Tried these statements before if statement
>
> echo "--$submit--";
>
> echo "--$_POST["submit"]--";
>
> echo"Submit = $submit ";
>
> but still query is not executing.


The reason people told you to put the above code is for troubleshooting.
It's not going to fix your query. What do you actually see resulting
from the above code before and after you hit your submit button? My
crystal ball says you see this:

----
----
Submit =

Am I right?

> <?php
>
> if($submit)
> {
>
> $dbh=mysql_connect ("localhost", "root") or die ('I cannot connect to
> the database because: ' . mysql_error());
> mysql_select_db ("dollar1_allinfo");
>
> mysql_query("INSERT INTO totalinfo (Username,Password) VALUES
> ('$loginusername','$loginpassword')")or die (mysql_error());


So if you see what I guessed above, then $submit is not set, so whatever
code you have here not going to execute. Do you know how an IF
conditional works? Do you know that if it evaluates to FALSE, then
nothing within the conditional block is executed? Your query is probably
fine, but the code is just never getting to it.

I could tell you to use $_GET['submit'] or $_REQUEST['submit'], but
would you know why or where to use it?

--

---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com