doushang2023 2011-11-21 00:42
浏览 49
已采纳

在php +错误中调用存储的mySql过程

I am wondering if anyone can tell me where I am going wrong. I am new to mySql and have little experience with php but am trying to call a stored procedure call AddStudy from a mysql database through php. Here is the code I have

//set up our connection to the database
$con = mysql_connect("umemlists.org","umemlist_umbc1",'U[$X7VHO7XT3');
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

$stmt = "call SaveStudy('james', 1234, 'm', 12, 0, 0, 'umbc', 0, 1, 0, 0, 0, 0, "", 0, -1)";
$result = mysqli_query($con, $stmt);

I am getting an error that says

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING

I am wondering if anyone could tell me if I am using the right syntax/method for calling the stored procedure in my database and if so any suggestions as to how I may be able to troubleshoot the problem

  • 写回答

1条回答 默认 最新

  • douluogu8713 2011-11-21 00:44
    关注

    Remove the double quotes inside your query:

    $stmt = "call SaveStudy('james', 1234, 'm', 12, 0, 0, 'umbc', 0, 1, 0, 0, 0, 0, "", 0, -1)";
    

    should be

    $stmt = "call SaveStudy('james', 1234, 'm', 12, 0, 0, 'umbc', 0, 1, 0, 0, 0, 0, '', 0, -1)";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?