Autor | Zpráva | ||
---|---|---|---|
Pepan23 Profil * |
#1 · Zasláno: 6. 8. 2010, 14:23:57
Dobrý den,
potřeboval bych nějak upravit tento kód aby mi vypisoval z DB. Když mám tak le ten to kód tak mi to hazí chybu. Parse error: syntax error, unexpected T_WHILE, expecting ')' in /home/users/manikbla/witpek.cz/web/vn.php on line 16 Zkoušel jsem hodně způsobů, ale vždy stejná chyba. <?php $host="localhost"; // Host name $username="username"; // Mysql username $password="password"; // Mysql password $db_name="db_name"; // Database name $tbl_name="tbl_name"; // Table name mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM $tbl_name"; $result=mysql_query($sql); $aUsers = array( while($rows=mysql_fetch_array($result)){ "$rows[title]", } ); $input = strtolower( $_GET['input'] ); $len = strlen($input); $aResults = array(); if ($len) { for ($i=0;$i<count($aUsers);$i++) { // had to use utf_decode, here // not necessary if the results are coming from mysql // if (strtolower(substr(utf8_decode($aUsers[$i]),0,$len)) == $input) $aResults[] = array( "id"=>($i+1) ,"value"=>htmlspecialchars($aUsers[$i]), "info"=>htmlspecialchars($aInfo[$i]) ); //if (stripos(utf8_decode($aUsers[$i]), $input) !== false) // $aResults[] = array( "id"=>($i+1) ,"value"=>htmlspecialchars($aUsers[$i]), "info"=>htmlspecialchars($aInfo[$i]) ); } } header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header ("Pragma: no-cache"); // HTTP/1.0 if (isset($_REQUEST['json'])) { header("Content-Type: application/json"); echo "{\"results\": ["; $arr = array(); for ($i=0;$i<count($aResults);$i++) { $arr[] = "{\"id\": \"".$aResults[$i]['id']."\", \"value\": \"".$aResults[$i]['value']."\", \"info\": \"\"}"; } echo implode(", ", $arr); echo "]}"; } else { header("Content-Type: text/xml charset=windows-1250"); echo "<?xml version=\"1.0\" encoding=\"windows-1250\" ?><results>"; for ($i=0;$i<count($aResults);$i++) { echo "<rs id=\"".$aResults[$i]['id']."\" info=\"".$aResults[$i]['info']."\">".$aResults[$i]['value']."</rs>"; } echo "</results>"; } ?> |
||
Keeehi Profil |
#2 · Zasláno: 6. 8. 2010, 14:33:38 · Upravil/a: Keeehi
Problém je v této části:
$aUsers = array( while($rows=mysql_fetch_array($result)){ "$rows[title]", } ); Asi by to mělo být takto: $aUsers = array(); while($rows=mysql_fetch_array($result)) $aUsers[]=$rows["title"]; |
||
Pepan23 Profil * |
#3 · Zasláno: 6. 8. 2010, 14:54:30
Díky, už to funguje. Moc jsi mě pomohl. Fakt díky.
|
||
Pepan23 Profil * |
#4 · Zasláno: 6. 8. 2010, 15:38:08
Jěšte malí problém, s kódováním píšemi to čtverečky místo čárek a háčků.
|
||
Kajman_ Profil * |
#5 · Zasláno: 6. 8. 2010, 15:49:22
|
||
Časová prodleva: 14 let
|
0