I have never used array_combine before and I am getting a “Boolean instead of resource” error in the query. If I change the query to read … WHERE cal_id = ” . $quidx . “; the Boolean error goes away but I get unexpected T_STRING errors later in the script for reasons I can’t figure, and the outcome of the query is nothing.
Main question: Is this the proper usage for array_combine? If so, what am I missing in the rest of this script that causes no information after the query? $quid1 is an array of id numbers and $tm is an array of Unix timestamps. Both arrays check out to have the same number of rows consistently. After array_combine, $cls1 returns a valid array of both previous arrays but they don’t seem to work in the query.
Thanks for helping. I’m still learning.
I have edited the script to include the new query statement. Problems now are with the foreach statements where the error reads invalid argument.
$cls1 = array_combine($quid1, $tm);
$quidx = array_values($quid1);
$quclx = array_values($tm);
//// note to self.. start final query for email write with new id data, likely redundant.
$qumail = "SELECT cal_id, cal_name, cal_time, cal_description FROM webcal_entry WHERE cal_id in (" . implode (',' , $quidx) . ")";
$wemail = mysql_query($qumail);
while ($row = mysql_fetch_array($wemail, MYSQL_NUM)) {
$quname2 = $row[1];
$qtime = $row[2]
$qudesc2 = $row[3];
Here’s the complete script section where this is applicable. I’m still pecking through it so it’s not all fixed yet:
$cls1 = array_combine($quid1, $tm);
$quidx = array_values($quid1);
$quclx = array_values($tm);
//// note to self.. start final query for email write with new id data, likely redundant.
$qumail = "SELECT cal_id, cal_name, cal_time, cal_description FROM webcal_entry WHERE cal_id in (" . implode (',' , $quidx) . ")";
$wemail = mysql_query($qumail);
while ($row = mysql_fetch_array($wemail, MYSQL_NUM)) {
$quname2 = $row[1];
$qtime = $row[2]
$qudesc2 = $row[3];
}
foreach ($qtime as $key=>$btUx) {
if (strlen($btUx) < 6){
$btUx = '0' . $btUx;
date_default_timezone_set('UTC');
$unixEpoch = strtotime($btUx);
date_default_timezone_set('America/Denver');
$formtime = date("H:i", $unixEpoch);
}
}
foreach ($tm as $key=>$tf) {
$idnotime = 0;
$idnow = (strlen($tf) > 2);
switch($tf) {
case $idnow:
$repmlnow = sprintf("Event: %s \nTime: %s \nDesc: %s \n\n", $row[1], $formtime, $row[3]);
break;
case $idnotime:
$repmlnotm = sprintf("Event: %s \nDesc: %s \n\n", $row[1], $row[3]);
break;
}
}
/////===================== send mail...
This is my last edit unless there are other comments. I have changed the original script to the following and everything seems to work properly in this case thanks to the contributor below…
$cls1 = array_combine($quid1, $tm);
$quidx = array_values($quid1);
$quclx = array_values($tm);
$qumail = "SELECT cal_id, cal_name, cal_time, cal_description FROM webcal_entry WHERE cal_id in (" . implode (',' , $quidx) . ")";
$wemail = mysql_query($qumail);
while ($row = mysql_fetch_array($wemail, MYSQL_NUM)) {
$quname2 = $row[1];
$qtime = $row[2];
$qudesc2 = $row[3];
}
if(strlen($qtime) < 6){
$btUx = '0' . $qtime;
date_default_timezone_set('UTC');
$unixEpoch = strtotime($btUx);
date_default_timezone_set('America/Denver');
$formtime = date("H:i", $unixEpoch);
}elseif(strlen($qtime) > 5){
date_default_timezone_set('UTC');
$unixEpoch = strtotime($value);
date_default_timezone_set('America/Denver');
$formtime = date("H:i", $unixEpoch);
}
foreach ($quclx as $key=>$tf) {
$idnotime = 0;
$idnow = (strlen($tf) > 2);
switch($tf) {
case $idnow:
$repmlnow = sprintf("Event: %s \nTime: %s \nDesc: %s \n\n", $quname2, $formtime, $qudesc2);
break;
case $idnotime:
$repmlnotm = sprintf("Event: %s \nDesc: %s \n\n", $quname2, $qudesc2);
break;
}
}
/////===================== send mail...
$quidx is an array with numerical index as key and $quid1 array values as it value. try change query become: