Jump to content

 

shipweb

Member Since 18 Feb 2010
Offline Last Active Oct 18 2010 01:27 PM
-----

#73653 PHP integration

Posted by shipweb on 08 March 2010 - 08:28 PM

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:

http://forum.cs-cart...?t=15752&page=7

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

Here is the code for DOD.php file

{literal}<?php

# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$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";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
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);
$product = $row_Recordset1['product_id'];
?>{/literal}
<script type="text/javascript">
<!--
var product = '{php} echo $product;{/php}';
// -->
</script>
{literal}<?php
mysql_free_result($Recordset1);
?>{/literal}


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,

Jeff