Donesa Rucci Donesa Rucci - 1 month ago 7
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());
if(mysql_num_rows($ada)>0)
{
$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.

Answer

As I said in the comments the constant

mysqli_assoc

Needs to be all caps

MYSQL_ASSOC

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'
Comments