Каролина, Неа, всё тоже самое У меня там SET NAMES стоит - обычно тоже помогало...
Добавлено @ 00:14
Цитата(Mal Hack @ 9.1.2007, 09:06 ) | Покажи структуру таблиц, дампом из PMA. |
А это как?
Точнее что такое РМА?
Вот весь код:
Код |
<?php
//include require "config.cfg"; //end_include
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////Блок определения функций////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Функция запрета кеширования//////////////////////////////////////////////////// function NoCache() { Header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Äàòà â ïðîøëîì Header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 Header("Pragma: no-cache"); // HTTP/1.0 Header("Last-Modified: ".gmdate("D, d M Y H:i:s")."GMT"); } //////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////// function show_services_button($conn) { $str_request = "SELECT services FROM system"; $res = mysql_query($str_request, $conn); if(!$res = mysql_query($str_request, $conn)) { NoCache(); echo "<div id=\"ErrorMessage\"><div>ERROR</div></div>"; exit(); } else { NoCache(); echo "<div id=\"show_services\">".mysql_result($res,0,0)."</div>"; exit(); } } ///////////////////////////////////////////////////////////////////////////////////
//////////Функция формирующая дерево категорий///////////////////////////// function CreateTreeCategory($conn) { $str_request = "SELECT * FROM catalogue"; if(!$res = mysql_query($str_request, $conn)) { NoCache(); echo "<div id=\"ErrorMessage\"><div>ERROR789</div></div>"; exit(); } //Формируем строку ответа //Формируем непосредственно список $str_respond = "<div id=\"catalogue_list\">"; $counter = 0; while($m_array = mysql_fetch_row($res)) { $id_str = "wares_layer_".$counter; $str_respond = $str_respond."<ul id=\"".$m_array[0]."\" style=\"list-style-image:disk; text-decoration:underline\" ><img src=\"images/plus.png\" style=\"margin-right:10px; hieght:10px; width:10px\">".$m_array[1]."<div id=wares_content_".$m_array[0]."></div></ul>"; $counter++; } $str_respond = $str_respond."</div>"; //Формируем сисок с превью для отображения в центральном окне NoCache(); echo $str_respond; exit(); } ///////////////////////////////////////////////////////////////////////////////////
//////////Формируем дерево///////////////////////////// function CreateTreeWare($conn) { $str_sql = "SELECT id, wares_name FROM wares WHERE id_category=".$_REQUEST['category_id']; if(!$res = mysql_query($str_sql,$conn)) { NoCache(); echo "<div id=\"ErrorMessage\"><div>ERROR789</div></div>"; exit(); } $str_respond = "<div id=content_response>"; while($m_array = mysql_fetch_row($res)) { $str_respond = $str_respond."<li id=".$m_array[0]." style=\"list-style-image:url(images/dot.png)\" >".$m_array[1]."</li>"; } $str_respond = $str_respond."</div>"; $str_respond = $str_respond."<div id=active_category>".$_REQUEST['category_id']."</div>"; NoCache(); echo $str_respond; exit(); } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////Функция формирующая информацию для превью///////////////////////////////////// function CreatePreview($conn) { $str_sql = "SELECT * FROM wares WHERE id_category=".$_REQUEST['id_category']; if(!$res = mysql_query($str_sql, $conn)) { NoCache(); echo "<div id=\"ErrorMessage\"><div>ERROR602</div></div>"; exit(); } $str_template = file_get_contents("ware_priview_element.tpl"); while($m_array = mysql_fetch_row($res)) { $str_template_edit = str_ireplace("[ware_name]", $m_array[1], $str_template); $str_template_edit = str_ireplace("[priview]", $m_array[2], $str_template_edit); $str_template_edit = str_ireplace("[price]", $m_array[4], $str_template_edit); $str_template_edit = str_ireplace("[TTX]", $m_array[5], $str_template_edit); $str_template_edit = str_ireplace("[description]", $m_array[3], $str_template_edit); $str_template_edit = str_ireplace("[id_category]", $m_array[6],$str_template_edit); $str_template_edit = str_ireplace("[id_wares]", $m_array[0], $str_template_edit); $str_respond = $str_respond.$str_template_edit; } NoCache(); echo $str_respond; exit(); } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////Функция создания страницы с подробным описанием/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function WaresDescriptionCreate($conn) { $str_request = "<html><head><META http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1251\"></head><body style=\"background-image:url('images/content_fon.jpg'); font-size:13pt; text-align:center; margin-left:0; margin-right:0; margin-top:0; margin-bottom:1%; padding:0\">"; $str_sql_images = "SELECT image_url FROM wares_images WHERE id_wares=".$_REQUEST['id_wares']; $str_sql_description = "SELECT wares_description FROM wares_details WHERE id_wares=".$_REQUEST['id_wares']; $str_sql_ttx = "SELECT name_value, value FROM parameters_detail WHERE id_wares=".$_REQUEST['id_wares']; $str_sql_price = "SELECT wares_price FROM wares WHERE id=".$_REQUEST['id_wares']; $res_images = mysql_query($str_sql_images, $conn) or die("ERROR images"); $res_description = mysql_query($str_sql_description, $conn) or die("ERROR description"); $res_ttx = mysql_query($str_sql_ttx, $conn) or die("ERROR ttx"); $res_price = mysql_query($str_sql_price, $conn) or die("ERROR prise"); $str_images = "<div style=\"position:relative; width:100%; margin-top:0%; margin-bottom:2%; margin-left:0; margin-right:0\"><table style=\"width:100%; height:100%; margin:1%; padding:0; text-align:center\" cellspacing=\"10%\">"; while($m_array = mysql_fetch_row($res_images)) { $str_images = $str_images."<tr><td style=\"vertical-align:middle; hight:auto\"><img src=\"".$m_array[0]."\"></td></tr>"; } $str_images = $str_images."</table></div>"; if(mysql_result($res_price,0,0)!="") { $str_price = "<div style=\"position:relative; margin-bottom:2%; margin-top:0%; width:300px; background-image:url('images/baze_for_text.png')\"><span style=\"padding:5px;\">".mysql_result($res_price,0,0)."</span></div>"; } $str_ttx = "<div style=\"position:relative; width:50%; margin-top:4%; margin-bottom:2%; margin-left:0; margin-right:0\"><table cellspacing=\"10px\" style=\"width:100%; margin:1%; padding:0%; text-align:center; border-style:solid; border-width:2px; border-color:#000000 \">"; while($m_array = mysql_fetch_row($res_ttx)) { $str_ttx = $str_ttx."<tr><td style=\"vertical-align:middle; hight:auto; width:auto; background-image:url('images/baze_for_text.png')\">".$m_array[0]."</td><td style=\"width:auto; background-image:url('images/baze_for_text.png')\">".$m_array[1]."</td></tr>"; } $str_ttx = $str_ttx."</table></div>"; if(mysql_result($res_description,0,0)!="") { $str_description = "<div style=\"position:relative; width:70%; min-height:15%; padding-top:2%; padding-bottom:2%; padding-left:1%; text-align:left; margin-top:5%; margin-bottom:2%; margin-left:0; margin-right:0; background-image:url('images/baze_for_text.png')\">".mysql_result($res_description,0,0)."</div>"; } $str_request = $str_request.$str_images.$str_price.$str_ttx.$str_description."</body></html>"; NoCache(); Header("Content-Type: text/html; charset=windows-1251"); //echo iconv("UTF-8", "cp1251", $str_request); echo $str_request; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////Конец блока определения функций//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////Основной блок//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Ïîäêëþ÷åíèå ê ÁÄ $conn = mysql_connect($host_db, $login_db, $password_db) or die ("Íåâîçìîæíî óñòàíîâèòü ñîåäèíåíèå ñ ÁÄ"); if(!mysql_select_db($name_db, $conn)) { NoCache(); echo "<div id=\"ErrorMessage\"><div>ERROR</div><div>Do not select database</div></div>"; exit(); }
$str_sql = "SET NAMES cp1251"; if(!mysql_query($str_sql, $conn)) { NoCache(); echo "<div id=\"ErrorMessage\"><div>ERROR144</div></div>"; exit(); }
//Ïðîâåðÿåì ëîãè÷åñêîå ñîîòâåòñòâèå ïåðåìåííûõ if($_REQUEST['operation']=='get_ware') { if(!isset($_REQUEST['category_id'])) { NoCache(); echo "<div id=\"ErrorMessage\"><div>ERROR</div><div>Incorrect request</div></div>"; exit(); } } else if($_REQUEST['operation']=='get_wares') { if(!isset($_REQUEST['id_wares'])) { NoCache(); echo "<div id=\"ErrorMessage\"><div>ERROR</div><div>Incorrect request</div></div>"; exit(); } }
if($_REQUEST["operation"]=='get_show_services_button') { show_services_button($conn); }
else if($_REQUEST["operation"]=='get_category') { CreateTreeCategory($conn); } else if($_REQUEST["operation"]=='get_ware') { CreateTreeWare($conn); } else if($_REQUEST['operation']=='get_priveiw_table') { CreatePreview($conn); } else if($_REQUEST['operation']=='get_wares') { WaresDescriptionCreate($conn); } ?>
|
|