|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
php: submit & query ????
i'm a newbie...trying to make my own basic blog (as all of them are so ugly and difficult to customize)...
can i do this? <? mysql_connect("localhost","vvvvv","vvvvv"); mysql_select_db("vvvvvv"); $query = mysql_query("SELECT * FROM content,response where response.a=content.blog and blog='$blog' " ) or die ("Unexpected error for MySQL database [1b]"); $row = mysql_fetch_array($query); if ($submit){ mysql_query("insert into response (name,email,website,date,comments) values ('$name','$email','$website','$date','$comments')") or die ("ciao"); ?> it worked just find until i added the "submit" part...further down the page is a simple form to insert into the "response" table...but why might it not be working now? any ideas or advice? thanks...jv |
|
#2
|
|||
|
|||
|
RE: php: submit & query ????
At a glance ... you didn't terminate your if statement. What is the error msg?
|
|
#3
|
|||
|
|||
|
RE: php: submit & query ????
I used to have problems with this when i first started, because i let DW make my forms, and then when i did if($submit) it wouldnt work.. as it needed to be Submit (capital S) not sure if thats your problem, sometimes its the simple things that are hardest to find....
|
|
#4
|
|||
|
|||
|
RE: php: submit & query ????
i got it to work...now...i only have one problem to solve...
HOW do i get a loop to know specifically what to search for from a table? meaning...i have created a simple loop...but i want the loop to search a table based upon the record/id of another table... example (if it's not clear)... http://blog.vvvvvv.com/index.php?blog=1 the "1"...i want this number to be inserted directly into the loop query...like this... $query="SELECT * FROM response where a=' 1 ' "; but i can't do this with an include...doesn't work (at least to my knowledge of things - which isn't much)... anybody got a quick solution? thanks...jv |
|
#5
|
|||
|
|||
|
RE: php: submit & query ????
When I click your link the only thing that pops up are like a bajillion domain registrar ads =/
From what I gather from your post, you are wanting the variable $blog to be inserted directly into the mysql query? If so, then you should be able to just put the variable into the query string like so: $query="SELECT * FROM response where a='$blog'"; |
|
#6
|
|||
|
|||
|
RE: php: submit & query ????
yo html...haha...you weren't supposed to really click on that...sorry...
thanks...but i did somehow figure that one out...it was pretty easy...with the help of this forum and a couple others...i've been able to achieve EVERYTHING i set out t do with my blog...i'm not a complete newbie...i'm a designer who has done websites before, but never got this deep with php (i've done really basic stuff in the past)... one last piece of business though to solve...the below script is how i am inserting things into my tables...it's working just great...but...how can i make this code forward me directly back to the referring page? this is the code: <? $username="vvvvvv"; $password="vvvvv"; $database="vvvvvvvvvvvvvvv"; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query = "INSERT INTO response VALUES ('','$name','$email','$website','$date','$comments ','$a')"; mysql_query($query); mysql_close(); ?> |
|
#7
|
|||
|
|||
|
RE: php: submit & query ????
It's great to see you are branching out into php. Once you get comfortable in it, you'll wonder how you ever got along without it hehehe.
What you are wanting to do can be done with the following command: Code:
header("Location: http://www.vvvvvv.com");
Just keep in mind that when you use the header command, it has to be before any output is sent to the page, ie, you print out something or have html. If the code snipet you have above is the first/only thing on the page, then this should not be a problem. |
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > php: submit & query ???? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|