Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/90.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
mysql_fetch_数组未检索php邮件的结果_Php_Html_Mysql - Fatal编程技术网

mysql_fetch_数组未检索php邮件的结果

mysql_fetch_数组未检索php邮件的结果,php,html,mysql,Php,Html,Mysql,我正试图将乘客位置发送给司机电子邮件。由于某种原因,$loc变量没有获取位置。当用户提交表单时,它会获取乘客姓名,然后$search\u loc['location']会从数据库中获取选项标签中所选姓名的位置。谢谢你的帮助 <?php $host="localhost"; // Host name $username="hidden"; // Mysql username $password="hidden"; // Mysql password $db_name="hidden";

我正试图将乘客位置发送给司机电子邮件。由于某种原因,
$loc
变量没有获取位置。当用户提交表单时,它会获取乘客姓名,然后
$search\u loc['location']
会从数据库中获取选项标签中所选姓名的位置。谢谢你的帮助

<?php
$host="localhost"; // Host name 
$username="hidden"; // Mysql username 
$password="hidden"; // Mysql password 
$db_name="hidden"; // Database name 
$tbl_name="pickuprequests"; // Table name 

// Connect to server and select database.
$link = mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name", $link)or die("cannot select DB");

//names of the passengers in option tags
$name = $_POST['name'];

//this query gets all the records from pickuprequests of the passenger selected
$query="SELECT * FROM $tbl_name WHERE name = '$name'";
$result=mysql_query($result, $link);

// get the location of the passenger from $result
$search_loc = mysql_fetch_array($query, $link);
$loc = $search_loc['location'];


//find how many rows are returned with the passenger name
$search_row = mysql_query($query, $link);
$count = mysql_num_rows($search_row, $link);

//deletes a record assoc with passenger name
$delete_query = "DELETE FROM pickuprequests WHERE name = '$name'";

/* THIS IS CODE THAT HAS BEEN COMMENTED OUT
$altloc = $_POST['altloc'];
$time = $_POST['time'];
*/

//message for the passenger
$msg_passenger = "Your driver is on the way! You will receive one last email when the driver arrives.";
$subject_passenger = "Driver on the way";
$mailheaders = "From: TripoZipo <tripozipo.com> \r\n";

//passengers email
$search_email = mysql_fetch_array($result, $link);
$email = $search_email['email']; // this wont get the passengers email as well

//message for the driver
$msg_driver = "".$name." is located at".$loc.""; // the problem is that this wont display loc in email
$subject_driver = "Passenger Location";

//drivers email is the session name for driver.php
$driver = $_SESSION['driver'];

//on submit and if a passenger is selected run code
if(isset($_POST['submit']) && isset($_POST['name'])) {

    //$count returns all the rows assoc with passenger name
    if($count) {
    mail($email, $subject_passenger, $msg_passenger, $mailheaders); // email passenger your ride is on the way
    mail($driver, $subject_driver, $msg_driver, $mailheaders); // email driver the location
    //mysql_query($delete_query, $link); // finally delete the request as its not pending anymore
    echo "<script type='text/javascript'> document.location = 'http://mobile.tripozipo.com/confirmation2.php'; </script>";
    }
    else {  //else if no rows are returned
    mail($email, $subject_passenger, $msg_passenger, $mailheaders); // email passenger your ride is on the way
    mail($driver, $subject_driver, $msg_driver, $mailheaders); // email driver the location
    //mysql_query($delete_query, $link); // delete pickup request so its no longer available
    echo "<script type='text/javascript'> document.location = 'http://mobile.tripozipo.com/confirmation2.php'; </script>";

    }
}
?>

Change
$search\u loc=mysql\u fetch\u数组($query,$link)
$search\u loc=mysql\u fetch\u数组($result,$link)请不要使用
mysql\uuz
数据库扩展。从PHP5.5开始,它们就被弃用,并在PHP7.0中被完全删除。请改用
mysqli
PDO
。谢谢您的评论,我将查看手册。然而,您是对的,它应该是$result,但这仍然不起作用。为什么$search\u loc没有将结果发送到驱动程序电子邮件?添加以下行
错误报告(E\u ALL);ini设置(“显示错误”,1),查看是否产生任何错误。同样将你的
mail()
函数像这样包装在if-else块中,
if(mail(…){echo“success”;}else{echo“failure”;}
这段代码太不安全了
$search\u loc=mysql\u fetch\u数组($result,$link)请不要使用
mysql\uuz
数据库扩展。从PHP5.5开始,它们就被弃用,并在PHP7.0中被完全删除。请改用
mysqli
PDO
。谢谢您的评论,我将查看手册。然而,您是对的,它应该是$result,但这仍然不起作用。为什么$search\u loc没有将结果发送到驱动程序电子邮件?添加以下行
错误报告(E\u ALL);ini设置(“显示错误”,1),查看是否产生任何错误。还可以像这样将
mail()
函数包装在if-else块中,
if(mail(…){echo“success”;}else{echo“failure”;}
这段代码太不安全了。