各位大神帮忙看一下这个是什么情况!
这是一个创建个人仓库的程序,单独测试没问题
打算在用户个人中心加载的时候直接运行,
程序运行的时候很成功,但是每次刷新界面的时候if语句中的程序又执行了
function _order_given(){
$uid = $this->checked_login();
$sql1="select uid from order_given where uid='$uid'";
$usergiven=$this->App->find($sql1);
//判断当前用户id在个人仓库表中是否存在
$row = mysql_num_rows($usergiven);
if($row==0) //表中不存在用户id创建个人仓库数据
{
$sqlg1="insert into order_given(goods_sn,pifa_price,is_on_sale,is_jifen) select goods_sn,pifa_price,is_on_sale,is_jifen from gz_goods";
$sqlg2="UPDATE order_given SET uid='$uid' WHERE uid='0'";
$this->App->query($sqlg1);
$this->App->query($sqlg2);
}
}
回复讨论(解决方案)
给自己张沙发,坐等大神路过!
既然 单独测试没问题,那么就是联合环境出了问题
你不去到其他地方找原因,只揪住这个函数不放,是什么道理?
你在sql语句后边加上
echo $sql1; exit; //有时候要查看的内容不是字符串,用print_r($xxx);
运行看看,sql对不对,可能是check用户没拿到正确的uid。
测试程序哪里出了问题可以用这个方法,看看打印的内容和预期的有什么差别
这条语句:
int mysql_num_rows ( resource $result )
括号中的参数是资源句柄
$usergiven=$this->App->find($sql1); 这条语句返回的是resource类型吗?
最好把完整的 类,类中的app,还有find 程序发出来。
如果刷新插入多一条记录。
问题应该是在这里
$sql1="select uid from order_given where uid='$uid'";
$usergiven=$this->App->find($sql1);
//判断当前用户id在个人仓库表中是否存在
$row = mysql_num_rows($usergiven);
if($row==0) //表中不存在用户id创建个人仓库数据
把$uid,$sql1,$row打印出来看看。
感谢大家问题解决了

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Alipay PHP...

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

How to debug CLI mode in PHPStorm? When developing with PHPStorm, sometimes we need to debug PHP in command line interface (CLI) mode...

Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.
