gpt4 book ai didi

php - 函数查询不会执行

转载 作者:行者123 更新时间:2023-12-01 00:27:11 25 4
gpt4 key购买 nike

为什么这个查询不起作用?!?

错误

解析错误:语法错误,第 5 行 E:\xampp\htdocs\pf\shop\buy.php 中意外的 T_STRING

变量信息示例

$character->islots = 20

$chatacter->name = [RE] Tizzle

$e2 = 10

函数

function increaseSlots($e2) {
$slots = ($character->islots)+($e2);
mysql_query('UPDATE `phaos_characters` SET `inventory_slots`="'.$slots.'" WHERE `name`="'.$character->name.'"'); // <-- Line 5
if (mysql_affected_rows() != 0) {
echo 'Inventory Size Incresed By '.$e2.' Slots';
}else{
echo mysql_error();
}
}

最佳答案

查看文档:http://php.net/manual/en/function.mysql-num-rows.php

Retrieves the number of rows from a result set. This command is only valid for statements like SELECT or SHOW that return an actual result set. To retrieve the number of rows affected by a INSERT, UPDATE, REPLACE or DELETE query, use mysql_affected_rows().

您需要使用 mysql_affected_rows() 或更好的 PDO 或 mysqli。

关于php - 函数查询不会执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12484336/

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