Jump to content

Warning: in_array() [function.in-array]: Wrong datatype for second argument


alapimba

Recommended Posts

Hello

 

I'm using tcpdf to convert some stuff to pdf.

On my local computer running wamp my script works perfect and the pdf is generated without problems

When i put my files in a webserver i got this error:

Warning: in_array() [function.in-array]: Wrong datatype for second argument in /home/vieira/public_html/topdf/dbcon.class.php on line 68

 

Line 68 is:

if(in_array($key,$arr_switches)){  //check switches

 

My complete code is:

 

    // Get fields of enum on/off switches type
    $result2 = mysql_query("SHOW FIELDS FROM $db_name.$table");
    $counter=0;    
    while($row = @mysql_fetch_array($result2)){
        //echo $row['Field'] . ' ' . $row['Type']."<br/>";
        if($row['Type'] === "enum('on','off')"){
            $arr_switches[$counter] = $row['Field'];
            $counter++;
        }        
    }
    //print"<pre>"; print_r($arr_switches); print"</pre>";exit;
    
    $counter = 0;
    while($row = @mysql_fetch_array($result)){
        foreach( $row as $key => $val ){
            if(!is_numeric($key))
            {
                $row_rs_certidao[$key] = $val;
                if(in_array($key,$arr_switches)){   //check switches
                    $record_key[$counter] = htmlentities('<?php if (!(strcmp($row_rs_certidao['."'".$key."'".'],"on"))) {echo "x";} ?>');
                    if($val==='on') $record_val[$counter] = "x";    //turn on switches
                    else $record_val[$counter] = '';                //turn off
                }else{
                    $record_key[$counter] = htmlentities('<?php echo $row_rs_certidao['."'".$key."'".']; ?>');
                    $record_val[$counter] = htmlentities($val);
                }
                $counter++;                
            }            
        }        
    }

 

Anyone can help?

don't do this:

 

@mysql_fetch_array($result2)

 

remove the @ and erase it from your memory. don't use it anywhere.

 

Also, it is really super-helpful to know if your query fails. update your code to this:

 

$result2 = mysql_query("SHOW FIELDS FROM $db_name.$table") or die(mysql_error());

 

i suspect that $arr_switches is not an array, and that's why you get that error. i would initialize the array before performing the first mysql_query.

 

$arr_switches = array();

perfect

 

it's working, i did the 3 things you said.

 

Thanks

 

don't do this:

 

@mysql_fetch_array($result2)

 

remove the @ and erase it from your memory. don't use it anywhere.

 

Also, it is really super-helpful to know if your query fails. update your code to this:

 

$result2 = mysql_query("SHOW FIELDS FROM $db_name.$table") or die(mysql_error());

 

i suspect that $arr_switches is not an array, and that's why you get that error. i would initialize the array before performing the first mysql_query.

 

$arr_switches = array();

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.