Donesa Rucci Donesa Rucci - 15 days ago 5x
PHP Question

Get Data From Mysql_Fetch_array

I have table, its name is "PBK", in pbk tables theres
1. ID
2. Group ID
3. Name
4. Number
5. NPP

I have value from NPP and check into PBK tables, I want to get "Number" Values from PBK tables and insert that number to "Outbox". i can't to get Number values i used MYSQL_FETCH_ARRAY

this is my code,

$npp2 = $data->val($i,2);
$npp = $upper = strtoupper($npp2);
$sql = "SELECT id FROM pbk WHERE NPP = '$npp'";
$ada=mysql_query($sql) or die(mysql_error());
$row= mysql_fetch_array($ada,mysqli_assoc);
$kirim_pesan = mysql_query("insert into outbox (DestinationNumber,TextDecoded, CreatorID)
values('".$row['Number']."', '$pesan', 'Gammu')");

I hove you can help me, thanks for your help.


As I said in the comments the constant


Needs to be all caps


That and your mixing mysql and mysqli, mysql is deprecated and will be removed in PHP7+ so I would avoid using it.

What you have happening though is this mysqli_assoc will issue a warning, which if you had error reporting on you would know, then PHP will convert it to a string because it does not exist as a constant. Constants are case sensitive. And when they don't exist you'll get something like this

Warning undefined constant mysqli_assoc assuming 'mysqli_assoc'