alapimba Posted November 2, 2010 Share Posted November 2, 2010 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? Link to comment https://forums.phpfreaks.com/topic/217596-warning-in_array-functionin-array-wrong-datatype-for-second-argument/ Share on other sites More sharing options...
BlueSkyIS Posted November 2, 2010 Share Posted November 2, 2010 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(); Link to comment https://forums.phpfreaks.com/topic/217596-warning-in_array-functionin-array-wrong-datatype-for-second-argument/#findComment-1129666 Share on other sites More sharing options...
OldWest Posted November 3, 2010 Share Posted November 3, 2010 You also might want run a file comparison app on your php.ini files (local and server) to determine the version and setting differences... Link to comment https://forums.phpfreaks.com/topic/217596-warning-in_array-functionin-array-wrong-datatype-for-second-argument/#findComment-1129764 Share on other sites More sharing options...
alapimba Posted November 3, 2010 Author Share Posted November 3, 2010 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(); Link to comment https://forums.phpfreaks.com/topic/217596-warning-in_array-functionin-array-wrong-datatype-for-second-argument/#findComment-1129834 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.