Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mixing php and html within a script

Status
Not open for further replies.

tnsbuff

Technical User
Jan 23, 2002
216
US
Hi,

I know this is a simple question, but I'm new to this so please excuse my ignorance.

Here's my problem. I'm using a shopping cart script that's written in php. Within the admin area of the cart, you can specify the html for a custom header of the shop pages, which I've done.

What I want to do is insert php code in between the <title></title> tags so that the category name will be dynamically displayed, which isn't the way the script is written now. It just displays a static title for all pages.

The problem that I've run into is that this header code that's specified in the admin section is placed into a (string) variable for the script to access, so even though I've placed my code between the php script delimiters (within the title tags) it's displaying the code in the title bar instead of executing it. How do I correct this?

Thanks very much.

 
I meant to look in the database, not to look for the file that sets $header. Most likely, the string is already backslashed in the database. I would guess that it is stored in the row &quot;title&quot;. Just take off the slashes that it added and things should work. Remember, if:
<title>&quot;.$var.&quot;</title>
doesn't work, try:
<title>'.$var.'</title>

Rick -----------------------------------------------------------
 
>>I meant to look in the database, not to look for the file that sets $header. <<

I don't think I have access to the database. As I mentioned, this is a script that's installed by the hosting company and is used server-wide.

>>I would guess that it is stored in the row &quot;title&quot;. Just take off the slashes that it added and things should work. <<

I don't think there's anything called &quot;title&quot; for the custom header. Everything is stored in $header when you specify a custom header.

I think I'm out of luck.

:-\
 
From your code:

$qry_gethead = mysql_query(&quot;SELECT name, title, dividercellcolor, pagetitle, shoplogo, background, fontcolour, fontfamily, &quot;.
&quot;fontsize, linkcolour, visitedlinkcolour, activelinkcolour, header, &quot;.
&quot;displaycartlink, displayhomelink, otherhomelink, displaysearchbox &quot;.
&quot;FROM shop &quot;.
&quot;WHERE id=$shop&quot;);

That is pulling &quot;title&quot; out of the database. I'm pretty sure that that entry contains the &quot;fixed&quot; version of what you typed into that box. Let's test:

<?
mysqlconnect() stuff....

$res=mysql_query(&quot;SELECT title FROM shop WHERE id='your_shop_id_#'&quot;);
print(mysql_result($res,0,title));

?>

That might not give you the backslashed version of your title, but it should at least let you know if that is where your title is stored.

Rick -----------------------------------------------------------
 
I tried to connect to the db and get the value of title, but I'm getting an error:

Warning: Supplied argument is not a valid MySQL result resource in /home/sites/mysite/web/shop/test.php on line 10

I'm almost positive that the value of title would be '' because the text box for &quot;title&quot; was empty when I specified a custom header.

The code that you cite above also pulls &quot;header&quot; and if you look closely at the portion that I highlighted in bold, it says:

if (trim($header) != '' && $titleadd != '| Final Page') {
// if theyve created a custom header...
$ret .= $header . &quot;\n<!-- STOP HEADER -->&quot;;
return $ret;


If $header is empty (If I had not supplied a custom header), then it would take the information supplied by me in individual text boxes (such as title, background color, background, logo path) and use it for a standard header. (As it is, those text boxes are empty.)

I think you're confusing the custom headers and standard headers. Either way I specify a logo and title, etc., whether it's a custom header or a standard header. The difference is that with a standard header, it gives me individual text boxes (not a textarea) to specify title, logo path, etc. and it will create a standard header for me with this information. With a custom header, I can insert all of the html myself (inside one textarea that it provides for the custom header html) and control everything exactly how I want it. In other words, I can control the look of the page more than just a standard header template with fill in the blank fields.

Does that make sense?

 
>>Yes. Now it makes sense ...it just doesn't solve the problem.
<<

Yes, I know. <grrrrrrrrrrr> :)

I'm going to let this go for now and maybe down the road I'll find a way to do it. Thanks SOOOOO much for your help and suggestions!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top