每次运行这个php时,我都会得到相同的3个错误.我不知道我做错了什么,有人可以帮忙吗?
以下是错误:
[05-May-2014 19:20:50 America/Chicago] PHP警告:mysqli_query()需要至少2个参数,1在第10行的/home/sagginev/public_html/Nutrifitness/search.php中给出
[05-May-2014 19:20:50 America/Chicago] PHP警告:mysqli_num_rows()期望参数1为mysqli_result,在第11行的/home/sagginev/public_html/Nutrifitness/search.php中给出null
[05-May-2014 19:20:50 America/Chicago] PHP警告:mysqli_num_rows()期望参数1为mysqli_result,在第16行的/home/sagginev/public_html/Nutrifitness/search.php中给出null
这是我的代码
enter code here
<?php
$con=mysqli_connect('localhost','sagginev_rob','122989','sagginev_Nutrifitness');
if (mysqli_connect_errno()) // Check connection
{ echo "Failed to connect to MySQL: " . mysqli_connect_error(); }
if(!isset($_POST['search'])) {
header("Location:home.php");
}
$search_sql="Select * FROM Questions WHERE username LIKE '%".$_POST['search']."%' OR feedback LIKE '%".$_POST['search']."%'";
$search_query=mysqli_query($search_sql);
if(mysqli_num_rows($search_query)!=0) {
$search_rs=mysqli_fetch_assoc($search_query);
}
?>
<H2> Search Results</H2>
<?php if(mysqli_num_rows($search_query)!=0) {
do { ?>
<p><?php echo $search_rs['name']; ?> </p>
<?php } while ($search_rs=mysqli_fetch_assoc($search_query));
} else {
echo …Run Code Online (Sandbox Code Playgroud) 这是我的代码:
$jsonData = file_get_contents('http://example.com/bin/serp.php?engine=google&phrase=$name');
Run Code Online (Sandbox Code Playgroud)
它似乎没有$name正确使用.我将如何将该变量添加到我的字符串中,就像我正在尝试的那样?
以下代码中的第107行是
$sql="INSERT INTO " $table_name " (confirm_code,name,password,email,address,phone,education,date_of_birth) VALUES
('".$confirm_code."','".$name."','".$pwd."','".$email."','".$adres."','".$phno."','".$educon."','".$dob."') "; "
Run Code Online (Sandbox Code Playgroud)
我得到了意想不到的T_VARIABLE;
<?php
if(isset($_POST['Register']))
{
$name= $_POST['uname'];
$pwd= $_POST['pswd'];
$email= $_POST['email'];
$phno= $_POST['phno'];
$adrs= str_replace("'","`",$_POST['adres']);
$adres = $adrs;
$educon= $_POST['educon'];
$dob= $_POST['dob'];
$chkname = "select email from ".USREG." where email='".$email."'";
$res = mysql_query($chkname, $con) or die(mysql_error());
$chkresult=mysql_fetch_array($res);
$uemail= $chkresult['email'];
//print_r($uemail);die();
include ('config.php');
$table_name=temp_members_db;
$confirm_code=md5(uniqid(rand()));
if($uemail==$email)
{
echo ' <p style="color:red">Email <b> '.$email.' </b> Already exists</p>';
}
else
{
$sql="INSERT INTO " $table_name "(confirm_code,name,password,email,address,phone,education,date_of_birth) VALUES
('".$confirm_code."','".$name."','".$pwd."','".$email."','".$adres."','".$phno."','".$educon."','".$dob."') ";
$result = mysql_query($sql, $con) …Run Code Online (Sandbox Code Playgroud) 如果你有这样的功能:
function somefunc ($data, $something) {
//
}
Run Code Online (Sandbox Code Playgroud)
当您调用这样的函数时:
somefunc($data);
Run Code Online (Sandbox Code Playgroud)
它发送错误说它缺少参数2.有没有办法让第二个参数可选?谢谢
我在网站上遇到错误解析错误:语法错误,意外的T_STRING,在第69行的/home/kbccsystem/kbccsystem.php.xdomain.jp/public_html/register.php中期望']'
从第69行到第96行的PHP代码是:
$allowedformat = array("gif" , "jpeg", "jpg" , "png");
$temp = explode(".", $_FILES["img_path"]["name"]);
$extension = end($temp);
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/jpg")
|| ($_FILES["file"]["type"] == "image/pjpeg")
|| ($_FILES["file"]["type"] == "image/x-png")
|| ($_FILES["file"]["type"] == "image/png"))
&& ($_FILES["file]["size"] < 20000 )
&& in_array($extension, $allowedformat)) {
if(is_uploaded_file($_FILES["img_path"]["tmp_name"]))
{
if(move_uploaded_file($_FILES["img_path"]["tmp_name"], "shop_image/" .$_FILES["img_path"]["name"]))
{
chmod("shop_image/" .$_FILES["img_path"]["name"], 0644);
echo "???????????";
}else{
echo "????????????????????";
}
}else{
echo "???????????????";
}
}
}
Run Code Online (Sandbox Code Playgroud)
起始行是69。最后一行是行96。
请帮助:)谢谢。
我需要知道如何找到数组的三个最大数字.目前我只能找到最大数量的数组,但我希望有三个最好的数组:
$avg = array();
$avg[20,10,30,50,80,90,220];
echo max($avg);
Run Code Online (Sandbox Code Playgroud)
也许你可以帮我这个?
我想检查不同的变量但是如果只有一个满足所需的条件,那么我得到一个警报视图.我试过if( && )但它没有按照我想要的方式工作.我认为我要找的东西就像是"或"陈述.
if(_d0 == 0 && _d1 == 0) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Input Error"
message: @"Need to Choose Sections"
delegate: nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
[alert release];
}
Run Code Online (Sandbox Code Playgroud)
所以我希望它检查是否_d0 = 0或_d1 == 0,即使这两个中的一个为0我需要弹出警报视图.问题是如果我做了分离的语句,那么如果用户没有选择任何两个部分,它将弹出两个警报视图,这将是烦人的,因为在某些情况下用户需要选择5个不同的部分.
我添加了一个下拉菜单的搜索框,通过javascript函数解决.因为我用php显示表单和框,我有问题调用javascript函数"searchSel():
echo "<input type=\"text\" id=\"realtxt\" onkeyup="searchSel()"><s";
Run Code Online (Sandbox Code Playgroud)
错误:解析错误:语法错误,意外T_STRING,期待','或';'
onkeyup=". searchSel() ." 不起作用
有任何想法吗?
php ×7
html ×2
syntax-error ×2
arrays ×1
forms ×1
function ×1
if-statement ×1
ios ×1
ipad ×1
iphone ×1
javascript ×1
jquery ×1
max ×1
mysql ×1
parameters ×1
string ×1
variables ×1
xcode ×1