PHP integration

Hello everyone,

I have created a php file to run a mysql command to pull information regarding a promotion that I am running. I am looking for the php to establish a product_id association for the day that I run my promotion. The promotion is a deal of the day promotion, which you can see the specifics here:


I established {include file=‘DOD.php’} in my main.tpl file.

Here is the code for DOD.php file





$hostname_DOD = “xxxxxxxx”;

$database_DOD = “xxxxxxxxxxxxxxxxxxxx”;

$username_DOD = “xxxxxxxxxxxxxxxxxxx”;

$password_DOD = “xxxxxxxxxxxxxxxxx”;

$DOD = mysql_pconnect($hostname_DOD, $username_DOD, $password_DOD) or trigger_error(mysql_error(),E_USER_ERROR);

if (!function_exists(“GetSQLValueString”)) {

function GetSQLValueString($theValue, $theType, $theDefinedValue = “”, $theNotDefinedValue = “”)


if (PHP_VERSION < 6) {

$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;


$theValue = function_exists(“mysql_real_escape_string”) ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {

case “text”:

$theValue = ($theValue != “”) ? “'” . $theValue . “'” : “NULL”;


case “long”:

case “int”:

$theValue = ($theValue != “”) ? intval($theValue) : “NULL”;


case “double”:

$theValue = ($theValue != “”) ? doubleval($theValue) : “NULL”;


case “date”:

$theValue = ($theValue != “”) ? “'” . $theValue . “'” : “NULL”;


case “defined”:

$theValue = ($theValue != “”) ? $theDefinedValue : $theNotDefinedValue;



return $theValue;



mysql_select_db($database_DOD, $DOD);

$query_Recordset1 = “SELECT product_id FROM cscart_product_features_values WHERE value_int = CURDATE()”;

$Recordset1 = mysql_query($query_Recordset1, $DOD) or die(mysql_error());

$row_Recordset1 = mysql_fetch_assoc($Recordset1);

$totalRows_Recordset1 = mysql_num_rows($Recordset1);

[COLOR=“Red”]$product = $row_Recordset1[‘product_id’];[/COLOR]


{literal} mysql_free_result($Recordset1);
?>{/literal} [/QUOTE]

I am trying to pass the variable $product to javascript so that I can establish a link association with my promotion on my home page.

Can anyone see what I am doing wrong here. I am not familiar with smarty syntax, so I’m guessing that is where I am going wrong.

Thanks in advance,


Only JavaScript is surrounded by the {literal} tags, all php code that is within templates need to be surrounded by the php tags {php}your php code{/php}


I FINALLY got it!!

You have to use the absolute path when including the file and you need to use include_php vs. include:

{include_php file=“/absolute/path/to/test.php”}

Then, the file test.php does not need any {php} tags within it. You just use the regular php.

echo "This works!!"

so if you fix the code you use to include the file and then clean up the code to remove the {php} and {literal} tags, it should work.


It worked perfectly!!!

I am going to finalize the deal of the day promotion today. I will post the link under the original thread. I can give insight as to how I set everything up!!!

Thanks again,