Page 1 of 1

page work local but not in server

Posted: Thu Dec 08, 2011 1:07 pm
by motiksir
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

this my code:

Code: Select all

<!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>

Re: page work local but not in server

Posted: Thu Dec 08, 2011 2:07 pm
by maxx99
Is this still valid on your remote server?

Code: Select all

$db = new mysqli("localhost","root","","a");

Re: page work local but not in server

Posted: Thu Dec 08, 2011 2:58 pm
by motiksir
in the server all the same without this line
$db = new mysqli("localhost","winpc_auto","autoauto","winpc_auto");

Re: page work local but not in server

Posted: Thu Dec 08, 2011 3:20 pm
by social_experiment
Are you receiving any error messages; if it is a problem with the mysqli you should be receiving mysqli related error messages

Re: page work local but not in server

Posted: Fri Dec 09, 2011 2:11 am
by motiksir
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();

Re: page work local but not in server

Posted: Fri Dec 09, 2011 2:16 am
by maxx99
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?

Re: page work local but not in server

Posted: Fri Dec 09, 2011 2:18 am
by social_experiment
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.

Re: page work local but not in server

Posted: Fri Dec 09, 2011 1:53 pm
by motiksir
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?
i try to do it but not print nothing..
about the $id its not empty.. print it. you can see it in this page..
http://www.kasirgraf.co.il/autoronen/showCar.php?id=5

about the db there a record because in another page i use it in input you can see it here
http://www.kasirgraf.co.il/autoronen/up ... e.php?id=5


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

Re: page work local but not in server

Posted: Sat Dec 10, 2011 2:11 am
by social_experiment
The code that you pasted; is it from showCar.php?

Re: page work local but not in server

Posted: Sat Dec 10, 2011 4:25 am
by motiksir
Yes

Re: page work local but not in server

Posted: Sun Dec 11, 2011 1:56 am
by social_experiment
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

Code: Select all

<?php $row = $db->fetch_array(); ?>

Re: page work local but not in server

Posted: Sun Dec 11, 2011 4:32 am
by motiksir
social_experiment wrote:
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

Code: Select all

<?php $row = $db->fetch_array(); ?>
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