我目前有一个运行中的购物车系统,当单击“ addToCart”时,产品代码存储在$ _SESSION ['cart']数组中,然后在下拉菜单中打印出来,如果未存储任何值,则打印“ No购物车中的项目”。这完全可以正常工作,但是当我尝试使用产品代码从数据库中提取其余项目数据时,我得到500个内部服务器错误,但是这种与数据库的连接方法工作得很好,任何建议都将不胜感激。 / p>
constructor(props){
this.state = {
shapes : [],
isDrawing : false,
isDrawingMode : true,
image : null,
}
}
// I tried adding many things here but nothing worked as I wanted
moveRects(e) {
var shapesList = this.state.shapes;
shapesList[e.target.index].x = e.target._lastPos.x;
shapesList[e.target.index].y = e.target._lastPos.y;
console.log(shapesList[e.target._id]);
}
render() {
return (
<div>
<input type = "checkbox" checked = {this.state.isDrawingMode} onChange = {this.handleCheckboxChange} />
<label>Drawing Mode</label>
<Stage
ref = 'stage'
width = {window.innerWidth}
height = {window.innerHeight}
onContentClick = {this.handleClick}
onContentMouseMove = {this.handleMouseMove}
>
<Layer ref = 'layer'>
<Image image = {this.state.image} />
{this.state.shapes.map((shape) => {
return (
<Group>
<Rect
x = {shape.x}
y = {shape.y}
width = {shape.width}
height = {shape.height}
isDrawingMode = {this.state.isDrawingMode}
stroke = {2}
draggable = "true"
onDragEnd = {(e) => this.moveRects(e)}
/>
</Group >
);
})}
</Layer>
</Stage>
</div>
);
}
答案 0 :(得分:0)
那么,您应该检查Web服务器错误日志中的确切错误。错误日志通常位于/ var / log / apache2文件夹中。以下内容可能会有所帮助:
您需要使用session_start()初始化Php会话。应该在第一个if语句之前调用session_start。
如果您的产品代码是字符串,则应将其括在引号中,因此您的sql查询应为:“ SELECT Student from Comforts WHERE Product_Code ='$ productCode'”;
您可以组合if和first else语句。例如:
if ($_SESSION['cart'] === null || !isset($_SESSION['cart']))