php array to string not working online server -


i have problem. have array of values database, when try pass string commas, works fine on localhost, when upload online server, string doesn't show values. example: select table in (,,) shows commas , in xampp server works excellent. ideas can be? here's code:

<?php  $sql = "select id users gid = 1"; $result = mysql_query( $sql); $cat_titles=array(); while( $row=mysql_fetch_assoc($result) ) { $cat_titles[] = $row['id ']; //  stuff other column //  data if want } mysql_free_result( $result );  echo "<p>\n"; foreach($cat_titles $v) {     $cat_titles[]= $row['id'];  } echo "</p>\n";  $cat_titles = implode(',',$cat_titles); $cat_titles = substr($cat_titles,0,-2); echo $cat_titles; echo "select * users in (".$cat_titles.")";    ?> 

a number of potential issues here:

you not handling error conditions around database access, if having issue queries never know.

your second select query doesn't specify field in clause, never work

this section of code absolutely nothing , in fact problem lies.

foreach($cat_titles $v) {     $cat_titles[]= $row['id'];  } 

here $row['id'] won't have value, looping throguh existing array , appending empty value new indexes.

in likelihood single query, might if explain trying do.

you should not using mysql_* functions. deprecated. use mysqli or pdo instead.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -