我有以下PHP脚本,单击按钮时会运行该脚本。它在Firefox,Chrome,Safari和IE 8+中工作得非常好/但是当我尝试在IE7中运行脚本时代码被挂起了
while( $row = sqlsrv_fetch_array( $result, SQLSRV_FETCH_ASSOC) )
我尝试将SQLSRV_FETCH_ASSOC
更改为SQLSRV_FETCH_NUM
和SQLSRV_FETCH_BOTH
但结果相同。
我尝试在while循环中回显并且它不回显任何东西,所以这意味着它不喜欢
while( $row = sqlsrv_fetch_array( $result, SQLSRV_FETCH_ASSOC) )
出于某种原因。
任何人都知道这是什么问题?或者如何解决它?
更新PHP
<?php
$page = $_POST['page'];
function getMenu($title){
$serverName = "xxxxx.com";
$username = "xxxxxxxx";
$password = "xxxxxxxxx";
$database = "xxxxxxx";
#DO NOT EDIT BELOW THIS LINE
$connectionInfo = array( "UID"=>$username, "PWD"=>$password, "Database"=>$database);
$conn = sqlsrv_connect( $serverName, $connectionInfo);
$result = sqlsrv_query($conn,"SELECT * FROM Menu2013 WHERE viewable = '1' AND section LIKE '".$title."'") or die (sqlsrv_errors());
setlocale(LC_ALL, ''); // Locale will be different on each system.
$locale = localeconv();
$i=0;
while( $row = sqlsrv_fetch_array( $result, SQLSRV_FETCH_ASSOC) ) {
$menu[$i] = $row['title'];
$price[$i] = number_format($row['price'], 2, $locale['decimal_point'], $locale['thousands_sep']);
$description[$i] = $row['description'];
$i++;
}
sqlsrv_close($conn);
return array($menu, $price, $description);
}
$code = '<div id="productTitle">'.$page.'</div>';
$newMenu = getMenu($page);
foreach($newMenu[0] as $key => $value){
$code.= '<div class="item"><lable>'.$value.'</lable><span class="price">$'.$newMenu[1][$key].'</span><input type="number" min="0" placeholder = "0" size = "1" class="items" value="" name="'.$value.'"/><br/><div class="description">'.$newMenu[2][$key].'</div></div><hr/>';
}
echo $code;
?>
jQuery AJAX Call
$.ajax({
type: 'POST',
url: 'functions.php',
data:{'page': menuItem},
success: function(data){
$('#orderForm').html(data);
$('.items').each(function(){
if($.cookie($(this).attr('name')))
{
$(this).val($.cookie($(this).attr('name'))[0]);
}
});
}
});
答案 0 :(得分:0)
$conn
添加
$viewable = '1';
$params = array(&$viewable, &$title);
$tsql = "SELECT * FROM Menu2013 WHERE viewable = ( ? ) AND section LIKE ( ? )";
$result = sqlsrv_stmt($conn, $tsql, $params);
如果仍然没有回复,请使用sqlsrv_errors()
获取更多信息