Re: How do I insert PHP script into existing script? Php script within script?

From: Date: Wed, 09 Apr 2003 20:57:51 +0000
Subject: Re: How do I insert PHP script into existing script? Php script within script?
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-143204@lists.php.net to get a copy of this message
So let me see if I get you right. This is my html page on the server is named whatever.html page contains: <?php $db = mysql_connect("host", "username", "password"); if( !$db ) { die("Error connecting to the Server"); exit; } $result = mysql_select_db("www", $db); if( !$result ) { die("Error selecting Database"); exit; } ?> <?php $query = "SELECT * FROM html WHERE html.id='1'"; $result = mysql_query($query,$db); if( !$result ) { die("No record"); } { $code = mysql_result($result,$row,"code"); echo "$code"; } mysql_free_result($result); mysql_close(); ?> Then when you go into database it will pull up record is 1 that will containt <html> <head> <meta NAME="ROBOTS" CONTENT="All"> </head> <body bgcolor="#ffffff" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0"> WHATEVER HTML CONTENT GOES INTO HERE Now with the next php script I want to pull in php script that pulls up my banner ad eval(<?php if (@include('/large/home/www/carmelme/admanager/phpadsnew.inc.php')) { if (!isset($phpAds_context)) $phpAds_context = array(); $phpAds_raw = view_raw ('', 4, '', '', '0', $phpAds_context); echo $phpAds_raw['html']; } ?>) </body> </html> Is that how I do it??? Quoting "CPT John W. Holmes" <holmes072000@charter.net>: > use eval(), but there has to be a better method for whatever you're doing. > > FYI: You don't "get nothing" for the PHP code. It's in an HTML file, so the > browser interprets that as some kind of HTML tag that it doesn't recognize, > so nothing is rendered. You'll see your PHP code in the source if you look > at it, though. > > ---John Holmes... > > ----- Original Message ----- > From: "Apollo (Carmel Entertainment)" <lists@carmelme.com> > To: <php-general@lists.php.net> > Sent: Wednesday, April 09, 2003 4:09 PM > Subject: Re: [PHP] How do I insert PHP script into existing script? Php > script within script? > > > > Duh! Already did. Is that how you treat all novices here? > > > > Again here is my problem. > > Lets say I enter <?php echo $_SERVER["HTTP_USER_AGENT"]; ?> in that HTML > that is > > residing in that database record, once I pull up that page I get nothing > in the > > area of that "user agent" PHP script. Is there anything I can do so that > script > > within a script would work or not. If yes, could tell me how, if now, than > just > > say "no, you novice, you can't do that". > > > > Quoting Chris Hayes <chayes@antenna.nl>: > > > > > Read a manual and the first chapter will explain it to you in a much > better > > > and complete way than i could type here for you. > > > Find manuals on www.php.net, or just like anywhere, ask Google for a php > > > tutorial. > > > > > > > > > At 21:46 9-4-2003, you wrote: > > > >I use following script for pages to pull up their html. NOTE: yes I am > > > still > > > >stuck in HTML, since I have no time to delve into PHP. > > > >Basicly if you go to page whatever.html and id of that page in the > script is > > > 1 > > > >it pulls up HTML from the database record. I did it this way so I can > just > > > >edit > > > >HTML in the database and not need to upload or download files. But now > I > > > >want to > > > >add extra features to some pages like PHP forms. What do I have to > enter in > > > my > > > >HTML so I could insert PHP script in there and not need to redo > anything > > > with > > > >the following script here? > > > > > > > ><?php > > > > $db = mysql_connect("host", "username", > > > > "password"); > > > > if( !$db ) > > > > { > > > > die("Error connecting to the Server"); > > > > exit; > > > > } > > > > $result = mysql_select_db("www", $db); > > > > if( !$result ) > > > > { > > > > die("Error selecting Database"); > > > > exit; > > > > } > > > > > > > >?> > > > ><?php > > > > $query = "SELECT > > > > * > > > >FROM > > > > html > > > >WHERE > > > >html.id='1'"; > > > > $result = mysql_query($query,$db); > > > > if( !$result ) > > > > { > > > > die("No record"); > > > > } > > > > { > > > > $code = mysql_result($result,$row,"code"); > > > > echo "$code"; > > > > } > > > > mysql_free_result($result); > > > > mysql_close(); > > > >?> > > > > > > > > > > > >-- > > > >PHP General Mailing List (http://www.php.net/) > > > >To unsubscribe, visit: > > > >http://www.php.net/unsub.php > > > > > > > > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > >

« previous php.general (#143204) next »