PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
i do page in php its work fine in wamp.. but it doesnt work in host..
its display all the images that need but not the table with the info, after the line $row = $res->fetch_array(); its not print nothing
<!DOCTYPE html>
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<link rel="stylesheet" href="menu/menu_style.css" type="text/css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<style type="text/css">
body{
direction: rtl;
font-family: arial;
color:black;
}
#content{
padding-right:10px;
margin-top:70px;
background: #efefef;
height:500px;
}
</style>
</head>
<body>
<div id="content">
<?php
if(isset($_REQUEST["id"]))
{
$id=$_GET["id"];
echo($id);
echo("<br>");
$strAddress = "Uploaded/";
// Takes all of the files in the specified folder
$arrFileNames = scandir($strAddress);
$arrLength = count($arrFileNames);
$nTemp = 0;
$nCounter = 0;
if($arrLength > 0)
{
echo '<center>';
echo '<table cellpadding="0" cellspacing="15">';
}
foreach($arrFileNames as $strName)
{
// Checks if the current element is a name of a picture
if(($strName!=".") && ($strName!="..") && !strpos($strName, ".txt"))
{
if(strpos($strName,"123321"))
{
$arrpic = explode("123321",$strName);
if($arrpic[0]==$id)
{
// Checks if new line is needed
if($nTemp == 0)
{
echo '<tr>';
}
// Creates a new column and puts an image in it
echo '<td>';
echo '<img src="'.$strAddress.$strName.'" height="100" width="100" />';
echo '<br>';
// Takes only the file name, without the suffix (.jpeg)
$arrId = explode(".",$strName);
// Shows the file content to the user
echo('</td>');
$nTemp++;
if($nTemp == 3)
{
$nTemp = 0;
echo '</tr>';
}
}
}
}
}
if($nTemp != 3 || nTemp != 0)
{
echo '</tr>';
}
$db = new mysqli("localhost","root","","a");
$res = $db->query("SELECT * FROM `carDetails` WHERE `carId` = '".$id."'");
$db->query("SET NAMES 'hebrew'");
$row = $res->fetch_array();
$res->close();
$db->close();
$toWrite = "<h1><font color=\"red\"><b>".$row["carName"]."</h1></font><table>
<tr><td>מחיר:</td><td>".$row["carPrice"]."</td></tr>
<tr><td>קילומטרז:</td><td>".$row["carKm"]."</td></tr>
<tr><td>שנה:</td><td>".$row["carYear"]."</td></tr>
<tr><td>יד:</td><td>".$row["carYad"]."</td></tr>
<tr><td>תיבת הילוכים:</td><td>".$row["carBox"]."</td></tr>
<tr><td>הערות:</td><td>".$row["carOther"]."</td></tr>
</table></b>";
echo($toWrite);
echo("<br/>");
echo("<br/>");
echo ("<a href=\"stocks.php\">");
echo ("חזור למלאי רכבים");
echo("</a>");
}
?>
</div>
</body>
</html>
Last edited by Benjamin on Sat Dec 10, 2011 1:01 pm, edited 1 time in total.
Reason:Added [syntax=php||htm||css||javascript||sql||etc] - Please use [syntax] tags when posting code in the forums! Thanks.
in the page not appear nothing error.
but the server do a new file error_log and appear this:
[08-Dec-2011 00:41:07] PHP Warning: Cannot modify header information - headers already sent by (output started at /home/winpc/public_html/autoronen/showCar.php:7) in /home/winpc/public_html/autoronen/showCar.php on line 93
[08-Dec-2011 00:41:07] PHP Fatal error: Call to a member function fetch_array() on a non-object in /home/winpc/public_html/autoronen/showCar.php on line 101
line 93: header('Content-Type: text/html; charset=utf-8');
line 101:$row = $res->fetch_array();
Normally that type of error is indicative of something being called before the header() function;
The Manual wrote:Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include(), or require(), functions, or another file access function, and have spaces or empty lines that are output before header() is called. The same problem exists when using a single PHP/HTML file.
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
maxx99 wrote:just vardump($res) or print_r($res) you'll probably see that its empty.
check if your $id isnt empty? if you have a record in db with this id?
social_experiment wrote:Normally that type of error is indicative of something being called before the header() function;
The Manual wrote:Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include(), or require(), functions, or another file access function, and have spaces or empty lines that are output before header() is called. The same problem exists when using a single PHP/HTML file.
i am sorry my friend i am not so much understand what to do... however i delete the line of header and dont have any change
motiksir wrote:in the page not appear nothing error.
but the server do a new file error_log and appear this:
[08-Dec-2011 00:41:07] PHP Warning: Cannot modify header information - headers already sent by (output started at /home/winpc/public_html/autoronen/showCar.php:7) in /home/winpc/public_html/autoronen/showCar.php on line 93
[08-Dec-2011 00:41:07] PHP Fatal error: Call to a member function fetch_array() on a non-object in /home/winpc/public_html/autoronen/showCar.php on line 101
line 93: header('Content-Type: text/html; charset=utf-8');
line 101:$row = $res->fetch_array();
Output to the browser is already starting at line 7 of this page; possibly the HTML header you have at the top.
motiksir wrote:[08-Dec-2011 00:41:07] PHP Fatal error: Call to a member function fetch_array() on a non-object in /home/winpc/public_html/autoronen/showCar.php on line 101
$row = $res->fetch_array(); where do you define $res as an object prior to this line? You create a new instance using $db so your changes your code like this
motiksir wrote:in the page not appear nothing error.
but the server do a new file error_log and appear this:
[08-Dec-2011 00:41:07] PHP Warning: Cannot modify header information - headers already sent by (output started at /home/winpc/public_html/autoronen/showCar.php:7) in /home/winpc/public_html/autoronen/showCar.php on line 93
[08-Dec-2011 00:41:07] PHP Fatal error: Call to a member function fetch_array() on a non-object in /home/winpc/public_html/autoronen/showCar.php on line 101
line 93: header('Content-Type: text/html; charset=utf-8');
line 101:$row = $res->fetch_array();
Output to the browser is already starting at line 7 of this page; possibly the HTML header you have at the top.
motiksir wrote:[08-Dec-2011 00:41:07] PHP Fatal error: Call to a member function fetch_array() on a non-object in /home/winpc/public_html/autoronen/showCar.php on line 101
$row = $res->fetch_array(); where do you define $res as an object prior to this line? You create a new instance using $db so your changes your code like this
this way not solve the problem, however i change the sql
$res = $db->query("SELECT `carId`, `carName`, `carPrice`, `carKm`, `carYear`, `carYad`, `carBox`, `carOther` FROM `cardetails` WHERE `carId` =".$id);
and now it work.. i dont understand why..
but thanks