回各位大虾1。传递参数,我发现传递后我的SQL语句里面多了几个反斜杠 "\",因为我的语句里面有单引号,一传就自动加上了反斜杠但是我用strtr怎么也去不掉他们! strtr(strSQL, '\\', '');2。我按照教程在文件最开头加上了 <?php session_start(); session_register('strSQL'); ?> 可是一执行,得到一大堆错误。 Warning: session_start(): open(/tmp\sess_adb91774d5eae0bcab28d03417625a86, O_RDWR) failed: No such file or directory (2) in C:\Program Files\Apache Group\Apache2\htdocs\JTG\SearchPage.php on line 2Warning: session_start(): Cannot send session cookie - headers already sent by (output started at C:\Program Files\Apache Group\Apache2\htdocs\JTG\SearchPage.php:2) in C:\Program Files\Apache Group\Apache2\htdocs\JTG\SearchPage.php on line 2Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at C:\Program Files\Apache Group\Apache2\htdocs\JTG\SearchPage.php:2) in C:\Program Files\Apache Group\Apache2\htdocs\JTG\SearchPage.php on line 2急死我了!救命!
在C盘根目录建一个tmp的文件夹,或者修改php.ini里的session_save_path去掉这个错误下面的 Warning: session_start(): Cannot send session cookie - headers already sent by (output started at C:\Program Files\Apache Group\Apache2\htdocs\JTG\SearchPage.php:2) in C:\Program Files\Apache Group\Apache2\htdocs\JTG\SearchPage.php on line 2 就不会有了
/* clean the strSQL*/ $sSQL = strtr($sSQL, '\\', ''); if (empty($recid) && empty($staffname) && empty($refno) && empty($route) && empty($delidate) && empty($customername) && empty($contactname) ) { if (empty($sSQL)) return ""; else{ if (empty($pCount)){ return ""; }else{ return $sSQL; } } } //Make each part of SELECT, FROM and WHERE .... return $strSEL.$strFROM.$strWHERE." ORDER BY RECORDTBL.ID_NUMBER DESC "; } ?>
<?php
session_start();
session_register('strSQL');
?>
可是一执行,得到一大堆错误。
Warning: session_start(): open(/tmp\sess_adb91774d5eae0bcab28d03417625a86, O_RDWR) failed: No such file or directory (2) in C:\Program Files\Apache Group\Apache2\htdocs\JTG\SearchPage.php on line 2Warning: session_start(): Cannot send session cookie - headers already sent by (output started at C:\Program Files\Apache Group\Apache2\htdocs\JTG\SearchPage.php:2) in C:\Program Files\Apache Group\Apache2\htdocs\JTG\SearchPage.php on line 2Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at C:\Program Files\Apache Group\Apache2\htdocs\JTG\SearchPage.php:2) in C:\Program Files\Apache Group\Apache2\htdocs\JTG\SearchPage.php on line 2急死我了!救命!
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at C:\Program Files\Apache Group\Apache2\htdocs\JTG\SearchPage.php:2) in C:\Program Files\Apache Group\Apache2\htdocs\JTG\SearchPage.php on line 2
就不会有了
最开头这么写
<?php
session_start();
session_register('strSQL');
?>并且在C潘根目录下面建立了 tmp子目录可是当我点击了<a href = "SearchPage.php?count=<?echo $i+11?>">次10件</a>之后
重新 回到了SearchPage.php里面,但是此时strSQL还是重置为空!谢谢大虾帮忙!
session_start();
session_register('strSQL');
?>
...
<table >
<tr bgcolor="#FF6666">
<td >検索条件を入力してください</td>
</tr>
<tr>
<?
global $PHP_SELF;
?>
<td><form name="form1" method=post action="<? echo $PHP_SELF;?>">
<p> 予約番号:
<input type="text" name="recid">
<p> 担当名前:<input type="text" name="staffname">
顧客姓名:<input type="text" name="customername">
RefNO:<input type="text" name="refno"></p>
<p> 連絡先No:<input type="text" name="contactname">
出発日付:<input type="text" name="delidate">
行程指定:<input type="text" name="route">
<p>
<input type="submit" name="Submit" value="検索する">
<input type="reset" name="Submit2" value="キャンセル">
</p>
</form></td>
</tr>
</table>
<table >
<tr>
<td height="300">
<?
// if ($strSQL==NULL )
if (empty($_POST['recid']) && empty($_POST['staffname'])
&& empty($_POST['refno']) && empty($_POST['route'])
&& empty($_POST['delidate']) && empty($_POST['customername'])
&& empty($_POST['contactname']) && empty($_GET['count']))
{
?>
<p>検索条件を入力して、「検索する」ボタンを押してください。 </p>
<?
}
else
{
//DISPLAY
$db = new DB_Sql;
if (empty($_GET['count'])){
$i=0;
}else{
$i=$_GET['count'];
}
(在这里count能取到值,但是strSQL不行)
$strSQL = MakeSQL($strSQL, $i); 《- 传进去的是空值
$db->query($strSQL);
$totalnumber=$db->num_rows();//総件数
?>
<table >
<tr>
<td>
<table >
<tr>
<td ><b>予約番号</font></b></td>
<td ><b>担当者</font></b></td>
<td ><b>受付日付</b></td>
<td ><b>連絡人</b></td>
<td ><b>連絡先</b></td>
</tr>
<?
//第i条ー第i+10条
$strSQL = MakeSQL($strSQL, $i);
if ($strSQL != "") {
$db->query($strSQL." LIMIT $i, 10");
$nowget=$db->num_rows();
}
?>
<?while($db->next_record()):?>
<tr>
<td width="20%" height="18"><font size="3">
<? $rec_id= $db->f(0)?>
<a href="javascript:view('recview.php?rec_id=<?echo $db->f(0)?>')">
<?echo $db->f(0); ?>
</a></font>
</td>
<td ><? echo $db->f(1) ?></font></td>
<td ><? echo $db->f(2) ?></font></td>
<td ><? echo $db->f(3) ?></font></td>
<td ><? echo $db->f(4) ?></font></td>
</tr>
<? endwhile ?>
</table>
</td>
</tr>
<tr>
<td><b>総計<? echo $totalnumber ?>件、第<? echo $i+1 ?>件から第<? echo $i+$nowget ?>件までが表示されています。
<? if(($totalnumber-$i-10)>0)
{?>
<a href="SearchPage.php?count=<?echo $i+11?>">次10件</a> // 调用
<? } ?>
<? if(($i-10)>=0)
{?>
<a href="SearchPage.php?count=<?echo $i-11?>">前10件</a> // 调用
<? }
?>
</b>
</font>
</td>
</tr>
</table>
<? } ?>
</td>
</tr>
</table>
<p> </p>
<!-- #EndEditable --></td>
</tr>
</table>
</div>
</td>
</tr>
</table><!-- #EndTemplate -->
<?
function MakeSQL($sSQL, $pCount)
{
//When there is no input, just return
$recid = $_POST['recid'];
$staffname = $_POST['staffname'];
$refno = $_POST['refno'];
$route = $_POST['route'];
$delidate = $_POST['delidate'];
$customername = $_POST['customername'];
$contactname = $_POST['contactname'];
/* clean the strSQL*/
$sSQL = strtr($sSQL, '\\', '');
if (empty($recid) && empty($staffname)
&& empty($refno) && empty($route)
&& empty($delidate) && empty($customername)
&& empty($contactname) )
{
if (empty($sSQL))
return "";
else{
if (empty($pCount)){
return "";
}else{
return $sSQL;
}
}
}
//Make each part of SELECT, FROM and WHERE
....
return $strSEL.$strFROM.$strWHERE." ORDER BY RECORDTBL.ID_NUMBER DESC ";
}
?>