problems running php script
I have been tryin to do this for a long time but no luck, so i decided to format the system again and start again.
I am tryin to set up a web server with PHP and MySQL. I installed a fresh install of Red hat8. and after configuring the Network. i tested the server, and it worked fine. http://134.36.16.12 when i tested php, it displayed ok. http://134.36.16.12/phpinfo.php Following this i tried to test PHP, with a basic script ------------------------------ inputform.php <?php $myvar = "Hello World, $firstname"; echo $myvar; ?> ------------------------------ form1.html <HTML> <BODY> <FORM ACTION="inputform.php" METHOD=post> First Name <INPUT TYPE=TEXT NAME="firstname" SIZE=30><BR> <INPUT TYPE=SUBMIT NAME="SUBMIT" VALUE="Submit"> </FORM> </BODY> </HTML> ------------------------- The output i got is simply Hello world. http://134.36.16.12/inputform.php I really require help as i am tryin to work on this project and i am stuck at the setting up. Any Help appreciated. Regards |
Although I never use PHP, I look it up on the web. Here is the syntax for ur inputform.php
This should work for u <?php echo $_POST["firstname"]; ?>. I think your concatenate method below is wrong. Check out the syntax for it. <?php $myvar = "Hello World, $firstname"; echo $myvar; ?> or Assumming ur syntax is correct... try this: <?php $myvar = "Hello World, $_POST["firstname"]"; echo $myvar; ?> |
You can also go into the php.ini file and turn on register globals. That should fix it. But at a cost of security. Read up more on it at php.net
|
SAMS PHP and MySQL Web Development book is an excellent resource. You can pick it up at Amazon.com or Barnes and Noble, or email me and I'll send you a link to the PDF version of it :)
|
Fatal Error: running mysql_connect()
I am getting a fatal error when i try to submit data to my Mysql using php.
http://134.36.16.12/submitform.html is the page the php is as folows: <html> <body> <?php mysql_connect (localhost, user, pass); mysql_select_db (dbname); mysql_query ("INSERT INTO tablename (first_name, last_name) VALUES ('$first_name', '$last_name') "); print ($first_name); print (" "); print ($last_name); print ("<p>"); print ("Thanks for submitting your name."); ?> </body> </html> |
Works fine for me now :)
|
All times are GMT -5. The time now is 08:37 AM. |