作者qazsd (nice play!)
看板PHP
标题[请益] 这两段原始码的差别
时间Sun Nov 4 20:48:51 2007
以下这段 (简称A)
<?php require_once('../Connections/TravelSite.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "",
$theNotDefinedValue = "")
{
$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_TravelSite, $TravelSite);
$query_ch14_filedownload = "SELECT * FROM ch14_uploadtoserver ORDER BY
Fs_Date DESC";
$ch14_filedownload = mysql_query($query_ch14_filedownload, $TravelSite) or
die(mysql_error());
$row_ch14_filedownload = mysql_fetch_assoc($ch14_filedownload);
$totalRows_ch14_filedownload = mysql_num_rows($ch14_filedownload);
?>
跟以下这段 (简称B)
<?php require_once('../Connections/TravelSite.php'); ?>
<?php
mysql_select_db($database_TravelSite, $TravelSite);
$query_ch14_filedownload = "SELECT * FROM ch14_uploadtoserver ORDER BY
Fs_Date DESC";
$ch14_filedownload = mysql_query($query_ch14_filedownload, $TravelSite) or
die(mysql_error());
$row_ch14_filedownload = mysql_fetch_assoc($ch14_filedownload);
$totalRows_ch14_filedownload = mysql_num_rows($ch14_filedownload);
?>
感觉好像就是A段比B段
多了
if (!function_exists("GetSQLValueString")) {....(以下略)绿色那段(简称C)
而有没有那C段,似乎都可以从资料库里捞到资料
那想请问那C段有什麽作用呢
PS:那段是用DW8建立资料集就会自动产生的。
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 59.127.20.190
※ 编辑: qazsd 来自: 59.127.20.190 (11/04 20:52)
1F:推 JeffMcBride:简单来说 要防止SQL injection 有错请指正:p 11/04 23:03
2F:→ JeffMcBride:和确保变数型态是SQL语法用的 11/04 23:04