doubutao6216 2018-10-10 01:24
浏览 49

仅向会话数组添加整数

So I have problem where I am using AJAX + PHP to insert product id to $SESSION['korpica'] = array(); Everything is working for id where i have only numbers(222,223,440,900,911) but when it comes to (A320M BAZOOKA, A320M GAMING PRO, A320M PRO-VH PLUS) it is not working. I searched but nothing helped me. Here is my code .

Declaring array in index.php

session_start();
$korpa = array();
$_SESSION['korpica'] = $korpa;

button

<button type="button" class="addToCart btn-button" title="Dodaj u korpu" onclick="dodaj('<?php echo $sifra; ?>');">  <i class="fa fa-shopping-basket"></i>
<span>Add to Cart</span>   
</button>

dodaj.js

function dodaj(sifra) {
    $.ajax({
        url: 'dodajUKorpu.php',
        type: "GET",
        data: {'korpas':sifra}


    });
}

dodajUKorpu.php

<?php session_start(); ?>
<?php
if(isset($_GET['korpas']) && $_GET['korpas']!=0){
    array_push($_SESSION['korpica'], $_GET['korpas']);
}

?>

Working for id -> 222, 223, 444, 900, 121, 911

Not working for id -> A320M BAZOOKA, A320M GAMING PRO, A320M PRO-VH PLUS, A68HM-P33 V1, AD5150JAHMBOX

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 BP神经网络控制倒立摆
    • ¥20 要这个数学建模编程的代码 并且能完整允许出来结果 完整的过程和数据的结果
    • ¥15 html5+css和javascript有人可以帮吗?图片要怎么插入代码里面啊
    • ¥30 Unity接入微信SDK 无法开启摄像头
    • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
    • ¥20 cad图纸,chx-3六轴码垛机器人
    • ¥15 移动摄像头专网需要解vlan
    • ¥20 access多表提取相同字段数据并合并
    • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
    • ¥20 Java-Oj-桌布的计算