gpt4 book ai didi

Php Mysql 插入存储过程

转载 作者:行者123 更新时间:2023-11-30 23:06:50 25 4
gpt4 key购买 nike

我的存储过程:

DROP PROCEDURE IF EXISTS alphaindia.insertcoursedetails;
CREATE DEFINER=`root`@`localhost` PROCEDURE `insertcoursedetails`( IN `StartDate` DATE,IN `ChurchName` VARCHAR(50), IN `CourseTypeId` BIGINT, IN `Participants` BIGINT, IN `MxId` VARCHAR( 50 ) , IN `DateCreated` DATE, IN `LocationName` VARCHAR( 100 ) , IN `LocationLatitude` VARCHAR( 50 ) , IN `LocationLongitude` VARCHAR( 50 ) , IN `LocationAddress` VARCHAR( 300 ) )
NO SQL
INSERT INTO coursedetails( StartDate, ChurchName, CourseTypeId, Participants, MxId, DateCreated, LocationName, LocationLatitude, LocationLongitude, LocationAddress )
ALUES (
StartDate, ChurchName, CourseTypeId, Participants, MxId, DateCreated, LocationName, LocationLatitude, LocationLongitude, LocationAddress
)

PHP 代码:

$date = date('d/m/Y');
echo $date;
mysql_connect("localhost", "root", "") or
die("Could not connect: " . mysql_error());
mysql_select_db("alphaindia");
$result = mysql_query("Call insertcoursedetails('2/3/2014','$_SESSION['ChurchLead']','$_SESSION['courseid']','$_SESSION['NumbPart']','vini.katyal','2/3/2014','$_SESSION['shortname']','$_SESSION['lat'],'$_SESSION['long'],'$_SESSION['address']'");
if($result)
{
echo("<br>Data Input OK");
}
else
{
echo("<br>Data Input Failed");
}

我无法通过 php 中的存储过程插入数据。请帮忙

最佳答案

在双引号字符串中,PHP 可以评估变量名 Like

echo "My name is $name";

但是使用数组,您必须使用大括号才能成功评估您的语句。以下声明有效

echo "My name is {$_SESSION['name']}";

你会得到

PHP Parse error:  syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING 

如果你这样做

echo "My name is $_SESSION['name']";

这就是您的查询中发生的情况。

关于Php Mysql 插入存储过程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21520848/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com