Jump to content

Recommended Posts

Hi guys, i'm new to PHP and i just couldn't get something right..

 

http://carnex.com.sg/preownedcars.php

this is the web that i'm currently having problem with, after pressing the button "learn more".

 

It will link to a page example, http://carnex.com.sg/view_car.php?id=97

 

And it should show more details of the cars, but i aren't getting any my details out..

 

The scripts are here..

 

I'm not sure if this is correct..

 <?php

include "includes/common.php";

$det1 = mysql_query("select * from tab_product where Status='1' and feat='1' limit $offset,$recperpage");

while($det2 = mysql_fetch_array($det1))

{

	$det[] = $det2;

}


        $objSmarty->assign("det",$det);
$objSmarty->assign("IncludeTemplate","view_car.tpl");
$objSmarty->display("pagetemplateautomobile.tpl");	

?>

<tr>
    <td style="padding-top:30px; padding-bottom:20px;"><table width="780" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="540" valign="top"><table width="540" border="0" align="left" cellpadding="0" cellspacing="0">
          <tr>
            <td valign="top" class="body"><form id="form1" name="form1" method="post" action="">
              <table width="93%" border="0" align="center" cellpadding="2" cellspacing="4" class="border">
{literal}

<script src="http://www.google.com/jsapi" type="text/javascript"></script>

	<script type="text/javascript" charset="utf-8">

		google.load("jquery", "1.3");

	</script>






	<link rel="stylesheet" href="css/prettyPhoto.css" type="text/css" media="screen" title="prettyPhoto main stylesheet" charset="utf-8" />

	<script src="js/jquery.prettyPhoto.js" type="text/javascript" charset="utf-8"></script>

<script type="text/javascript">

<script type="text/javascript" src="js/login.js"></script>


<style type="text/css">


.error {

font: normal 12px arial;

text-align:center;

font-weight:bold;

background-color: #ffc;

border: 1px solid #c00;

}



.ok {

font: normal 12px arial;

text-align:center;

font-weight:bold;

background-color:#EFFFDF;

border: 1px solid #339966;

color:#009900;

}



</style>

{/literal}

{section name=a loop=$det}

<tr>

        <td width="580" align="center" valign="top"><table width="580" border="0" cellspacing="0" cellpadding="0">

          <tr>

            <td height="672" align="center" valign="top" background="images/boby_bg_top.jpg" style="background-position:top; background-repeat:repeat-x; background-color:#FFFFFF;"><table width="100%" border="0" cellspacing="0" cellpadding="0">

              <tr>

                <td height="19"> </td>

                <td> </td>

              </tr>

              <tr>

                <td width="580" valign="top"><table width="580" border="0" align="left" cellpadding="0" cellspacing="0">

                  <tr>

                    <td height="620" align="center" valign="top"><table width="98%" border="0" align="center" cellpadding="5" cellspacing="0">

                      

                      <tr>

                                

                                <td width="32%" align="left" valign="middle"><!--<a href="carforsale.php"><img src="images/back.jpg" name="back" width="80" border="0" /></a>--></td>

                                <td width="43%" align="left" valign="middle"> </td>

                       </tr>

                      <tr align="left">

                        <td width="12%" class="tit_1">{$det[a].prod_name}</td>

                        <td width="88%" class="tit_1"> </td>

                      </tr>

                      

                      <tr align="left">

                        <td colspan="2" valign="top" class="tit_1"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="registration_border">

                          <tr>

                            <td height="228" valign="top" bgcolor="#FFFFFF"><table width="95%" border="0" align="center" cellpadding="5" cellspacing="0">

                              	

                              <tr>

                                <td height="15" colspan="3"></td>

                              </tr>



                              

                                

                              <tr>

                               
                                <td align="center" class="content_text" valign="top" colspan="2">
                                {if $det[a].prod_imgsize1 eq '0' and $det[a].prod_imgsize2 eq '0' and $det[a].prod_imgsize3 eq '0' and $det[a].prod_imgsize4 eq '0' and $det[a].prod_imgsize5 eq '0' and $det[a].prod_imgsize6 eq '0' and $det[a].prod_imgsize7 eq '0'}<img src="product_img/no_image.gif" width="100" align="absmiddle"  border="1" style="border-color:#CCCCCC; padding:5px;"/>

                                {else}
<!--{if $det[a].prod_imgsize1 neq '0'}-->

<a href="product_img/{$det[a].prod_imgname1}"rel="prettyPhoto[mixed]"><img src="product_img/{$det[a].prod_imgname1}" width="140" height="100" border="1" style="border-color:#CCCCCC; padding:5px;"/></a>{/if}
{if $det[a].prod_imgsize2 neq '0'}<a href="product_img/{$det[a].prod_imgname2}"  rel="prettyPhoto[mixed]"><img src="product_img/{$det[a].prod_imgname2}" width="140" height="100" border="1" style="border-color:#CCCCCC; padding:5px;"/></a>{/if}
{if $det[a].prod_imgsize3 neq '0'}<a href="product_img/{$det[a].prod_imgname3}"  rel="prettyPhoto[mixed]"><img src="product_img/{$det[a].prod_imgname3}" width="140" height="100" border="1" style="border-color:#CCCCCC; padding:5px;"/></a>{/if}
{if $det[a].prod_imgsize4 neq '0'}<a href="product_img/{$det[a].prod_imgname4}"  rel="prettyPhoto[mixed]"><img src="product_img/{$det[a].prod_imgname4}" width="140" height="100" border="1" style="border-color:#CCCCCC; padding:5px;"/></a>{/if}
{if $det[a].prod_imgsize5 neq '0'}<a href="product_img/{$det[a].prod_imgname5}" rel="prettyPhoto[mixed]"><img src="product_img/{$det[a].prod_imgname5}" width="140" height="100" border="1" style="border-color:#CCCCCC; padding:5px;"/></a>{/if}
{if $det[a].prod_imgsize6 neq '0'}<a href="product_img/{$det[a].prod_imgname6}" rel="prettyPhoto[mixed]"><img src="product_img/{$det[a].prod_imgname6}" width="140" height="100" border="1" style="border-color:#CCCCCC; padding:5px;"/></a>{/if}
{if $det[a].prod_imgsize7 neq '0'}<a href="product_img/{$det[a].prod_imgname7}"  rel="prettyPhoto[mixed]"><img src="product_img/{$det[a].prod_imgname7}" width="140" height="100" border="1" style="border-color:#CCCCCC; padding:5px;"/></a>{/if}
{/if}{if $det[a].feat eq '1'}




                                  <div style="margin-top:-5px;" align="center"><img src="administrator/images/favorites.png" width="36" border="0" /></div>


                                {/if}</td>

                              </tr>

                              <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">Car Name : </strong></td>

                                <td class="content_text">{$det[a].prod_name}</td>
                              </tr>

                              <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">Category : </strong></td>

                                <td class="content_text">{$det[a].category}</td>

                                </tr>
                                
                               <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">Agent Name : </strong></td>

                                <td class="text1">{$fname} {$lname}</td>

                                </tr>

                              

                              <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">Agent Email : </strong></td>

                                <td class="text1">{$det[a].email}</td>

                                </tr>

                              

                              <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">Agent Code : </strong></td>

                                <td class="text1">{$det[a].agent}</td>

                                </tr>

                                 <tr>

                                <td class="car_1_blc" valign="top"><strong class="car_1_blc">Contact No. : </strong></td>

                                <td class="text1">{$phone}<br /><br />{$phone2}</td>

                                </tr>
                                
                              <tr>


                                <td class="car_1_blc"><strong class="car_1_blc">Sale Price : </strong></td>

                                <td class="content_text">${$det[a].saleprice}</td> 

                                </tr>  

                             {if $smarty.session.user_log neq ''}
                              <tr>


                                <td class="car_1_blc"><strong class="car_1_blc">Dealer Price : </strong></td>

                                <td class="content_text">{$det[a].prod_price}</td>

                                </tr>

			{/if}
                              

                           <!--   <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">Car Quantity : </strong></td>

                                <td class="content_text">{$det[a].quant}</td>

                                </tr>-->

                              

                              <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">Road Tax : </strong></td>

                                <td class="content_text">{$det[a].roadtax}</td>

                                </tr>

                              

                              <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">Transmission  : </strong></td>

                                <td class="content_text">{$det[a].trans}</td>

                                </tr>

                              

                              <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">Engine Capacity : </strong></td>

                                <td class="content_text">{$det[a].capacity}</td>

                                </tr>

                              

                              <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">Mileage : </strong></td>

                                <td class="content_text">{$det[a].mile}</td>

                                </tr>

                                                            

                              <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">Register date  : </strong></td>

                                <td class="content_text">{$det[a].regdate}</td>

                                </tr>
                                

                                
                              <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">Features  : </strong></td>

                                <td class="content_text">{$det[a].features}</td>

                                </tr>
                                
                              <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">Accessories  : </strong></td>

                                <td class="content_text">{$det[a].acc}</td>

                                </tr>
                                
                              <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">COE  : </strong></td>

                                <td class="content_text">{$det[a].coe}</td>

                                </tr>
                                
                               <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">OMV  : </strong></td>

                                <td class="content_text">{$det[a].omv}</td>

                                </tr>
                                
                               <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">Depreciation  : </strong></td>

                                <td class="content_text">{$det[a].dep}</td>

                                </tr>
                                
                               <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">No. of owners  : </strong></td>

                                <td class="content_text">{$det[a].owner}</td>

                                </tr>
                                
                                <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">Type of Vehicle   : </strong></td>

                                <td class="content_text">{$det[a].type}</td>

                                </tr>

                              

                              <tr>

                                <td class="car_1_blc" valign="top"><strong class="car_1_blc">Description  : </strong></td>

                                <td colspan="2" class="content_text">{$det[a].desc}</td>

                              </tr>



                              

                              <tr>

                                <td height="10" colspan="3"></td>

                                </tr>



                              <tr>

                                <td width="25%"> </td>

                                <td colspan="2"><a href="sendmail.php?id={$det[a].prod_id}"><img src="images/sendthemail.jpg" border="0" style="padding:10px;" /></a></td>

                              </tr>

                              

                            </table></td>

                          </tr>

                        </table></td>

                      </tr>

                      

                    </table></td>

                  </tr>

                </table></td>



                <!-- Side panel -->

              	<td width="32%" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">

                {include file="side.tpl"}

                 </table></td>

               <!-- Side ends -->



              </tr>

              <tr>

                <td width="68%"> </td>

                <td> </td>

              </tr>

              

            </table></td>

          </tr>

        </table></td>

      </tr>

{/section}


      {literal}



<script type="text/javascript" charset="utf-8">

	$(document).ready(function(){

		$("a[rel^='prettyPhoto']").prettyPhoto();

	});

</script>

   {/literal}
			</table>

</form>
		 </td>
	  </table>
	  </tr>
	  

</td>
	 </tr>
</td>
</tr>

 

 

Link to comment
https://forums.phpfreaks.com/topic/210823-php-doesnt-link-properly/
Share on other sites

You have not posted the query on view_car.php!

 

It should be something like

<?php
$result = mysql_query("SELECT * FROM tab_product WHERE id='".mysql_real_escape_string($_GET['id'])."'");
if(!mysql_num_rows($result)) {
// bad id - redirect user to 404
exit();
}
$thisCar = mysql_fetch_assoc($result);
$objSmarty->assign("car",$thisCar);
$objSmarty->display("view_car.tpl")
?>

You have not posted the query on view_car.php!

 

It should be something like

<?php
$result = mysql_query("SELECT * FROM tab_product WHERE id='".mysql_real_escape_string($_GET['id'])."'");
if(!mysql_num_rows($result)) {
// bad id - redirect user to 404
exit();
}
$thisProduct = mysql_fetch_assoc($result);
$objSmarty->assign("product",$thisProduct);
$objSmarty->display("product.tpl")
?>

 

I've posted it, its the first one which i think everything inside is completely wrong..

This is why i need help completing the view_car.php

Of course it is incorrect. The query within view_car.php should be selecting a single record (the car that the user has clicked on). You are passing the id through the URL which you use in your query. I have already posted the solution.

 

To me you have posted the script from http://carnex.com.sg/preownedcars.php

The view_car.php file should look like what I have posted.

Of course it is incorrect. The query within view_car.php should be selecting a single record (the car that the user has clicked on). You are passing the id through the URL which you use in your query. I have already posted the solution.

 

Okay, i will try the script and let you know. Thanks for your replies.

Of course it is incorrect. The query within view_car.php should be selecting a single record (the car that the user has clicked on). You are passing the id through the URL which you use in your query. I have already posted the solution.

 

To me you have posted the script from http://carnex.com.sg/preownedcars.php

The view_car.php file should look like what I have posted.

 

Hi neil.johnson, i've applied your script and i have some errors can you view and clarify them? thanks!

You have not connected to your database on view_car.php

It is best to have a common file included on all site pages that connects to your database. Then you do not have to connect to the database on each page. i.e

<?php
// common.inc.php
mysql_connect();
mysql_select_db();
?>

<?php
// preownedcars.php
include('common.inc.php');
?>

<?php
// view_car.php
include('common.inc.php');
?>

You have not connected to your database on view_car.php

It is best to have a common file included on all site pages that connects to your database. Then you do not have to connect to the database on each page. i.e

<?php
// common.inc.php
mysql_connect();
mysql_select_db();
?>

<?php
// preownedcars.php
include('common.inc.php');
?>

<?php
// view_car.php
include('common.inc.php');
?>

 

I forgot to include my common file.

After including my common file, i still got 1 last error.

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/carnexco/public_html/view_car.php on line 5.

 

http://carnex.com.sg/view_car.php?id=97

 

Any idea why?

Post the code.

 

This is view_car.php

<?php

include "includes/common.php";
$result = mysql_query("SELECT * FROM tab_product WHERE id='".mysql_real_escape_string($_GET['id'])."'");
if(!mysql_num_rows($result)) {
// bad id - redirect user to 404
exit();
}
$thisProduct = mysql_fetch_assoc($result);
$objSmarty->assign("product",$thisProduct);
$objSmarty->assign("IncludeTemplate","view_car.tpl");
$objSmarty->display("pagetemplateautomobile.tpl")
?>

 

This is view_car.tpl

 <tr>
    <td style="padding-top:30px; padding-bottom:20px;"><table width="780" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="540" valign="top"><table width="540" border="0" align="left" cellpadding="0" cellspacing="0">
          <tr>
            <td valign="top" class="body"><form id="form1" name="form1" method="post" action="">
              <table width="93%" border="0" align="center" cellpadding="2" cellspacing="4" class="border">
{literal}

<script src="http://www.google.com/jsapi" type="text/javascript"></script>

	<script type="text/javascript" charset="utf-8">

		google.load("jquery", "1.3");

	</script>






	<link rel="stylesheet" href="css/prettyPhoto.css" type="text/css" media="screen" title="prettyPhoto main stylesheet" charset="utf-8" />

	<script src="js/jquery.prettyPhoto.js" type="text/javascript" charset="utf-8"></script>

<script type="text/javascript">

<script type="text/javascript" src="js/login.js"></script>


<style type="text/css">


.error {

font: normal 12px arial;

text-align:center;

font-weight:bold;

background-color: #ffc;

border: 1px solid #c00;

}



.ok {

font: normal 12px arial;

text-align:center;

font-weight:bold;

background-color:#EFFFDF;

border: 1px solid #339966;

color:#009900;

}



</style>

{/literal}

{section name=a loop=$det}

<tr>

        <td width="580" align="center" valign="top"><table width="580" border="0" cellspacing="0" cellpadding="0">

          <tr>

            <td height="672" align="center" valign="top" background="images/boby_bg_top.jpg" style="background-position:top; background-repeat:repeat-x; background-color:#FFFFFF;"><table width="100%" border="0" cellspacing="0" cellpadding="0">

              <tr>

                <td height="19"> </td>

                <td> </td>

              </tr>

              <tr>

                <td width="580" valign="top"><table width="580" border="0" align="left" cellpadding="0" cellspacing="0">

                  <tr>

                    <td height="620" align="center" valign="top"><table width="98%" border="0" align="center" cellpadding="5" cellspacing="0">

                      

                      <tr>

                                

                                <td width="32%" align="left" valign="middle"><!--<a href="carforsale.php"><img src="images/back.jpg" name="back" width="80" border="0" /></a>--></td>

                                <td width="43%" align="left" valign="middle"> </td>

                       </tr>

                      <tr align="left">

                        <td width="12%" class="tit_1">{$det[a].prod_name}</td>

                        <td width="88%" class="tit_1"> </td>

                      </tr>

                      

                      <tr align="left">

                        <td colspan="2" valign="top" class="tit_1"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="registration_border">

                          <tr>

                            <td height="228" valign="top" bgcolor="#FFFFFF"><table width="95%" border="0" align="center" cellpadding="5" cellspacing="0">

                              	

                              <tr>

                                <td height="15" colspan="3"></td>

                              </tr>



                              

                                

                              <tr>

                               
                                <td align="center" class="content_text" valign="top" colspan="2">
                                {if $det[a].prod_imgsize1 eq '0' and $det[a].prod_imgsize2 eq '0' and $det[a].prod_imgsize3 eq '0' and $det[a].prod_imgsize4 eq '0' and $det[a].prod_imgsize5 eq '0' and $det[a].prod_imgsize6 eq '0' and $det[a].prod_imgsize7 eq '0'}<img src="product_img/no_image.gif" width="100" align="absmiddle"  border="1" style="border-color:#CCCCCC; padding:5px;"/>

                                {else}
<!--{if $det[a].prod_imgsize1 neq '0'}-->

<a href="product_img/{$det[a].prod_imgname1}"rel="prettyPhoto[mixed]"><img src="product_img/{$det[a].prod_imgname1}" width="140" height="100" border="1" style="border-color:#CCCCCC; padding:5px;"/></a>{/if}
{if $det[a].prod_imgsize2 neq '0'}<a href="product_img/{$det[a].prod_imgname2}"  rel="prettyPhoto[mixed]"><img src="product_img/{$det[a].prod_imgname2}" width="140" height="100" border="1" style="border-color:#CCCCCC; padding:5px;"/></a>{/if}
{if $det[a].prod_imgsize3 neq '0'}<a href="product_img/{$det[a].prod_imgname3}"  rel="prettyPhoto[mixed]"><img src="product_img/{$det[a].prod_imgname3}" width="140" height="100" border="1" style="border-color:#CCCCCC; padding:5px;"/></a>{/if}
{if $det[a].prod_imgsize4 neq '0'}<a href="product_img/{$det[a].prod_imgname4}"  rel="prettyPhoto[mixed]"><img src="product_img/{$det[a].prod_imgname4}" width="140" height="100" border="1" style="border-color:#CCCCCC; padding:5px;"/></a>{/if}
{if $det[a].prod_imgsize5 neq '0'}<a href="product_img/{$det[a].prod_imgname5}" rel="prettyPhoto[mixed]"><img src="product_img/{$det[a].prod_imgname5}" width="140" height="100" border="1" style="border-color:#CCCCCC; padding:5px;"/></a>{/if}
{if $det[a].prod_imgsize6 neq '0'}<a href="product_img/{$det[a].prod_imgname6}" rel="prettyPhoto[mixed]"><img src="product_img/{$det[a].prod_imgname6}" width="140" height="100" border="1" style="border-color:#CCCCCC; padding:5px;"/></a>{/if}
{if $det[a].prod_imgsize7 neq '0'}<a href="product_img/{$det[a].prod_imgname7}"  rel="prettyPhoto[mixed]"><img src="product_img/{$det[a].prod_imgname7}" width="140" height="100" border="1" style="border-color:#CCCCCC; padding:5px;"/></a>{/if}
{/if}{if $det[a].feat eq '1'}




                                  <div style="margin-top:-5px;" align="center"><img src="administrator/images/favorites.png" width="36" border="0" /></div>


                                {/if}</td>

                              </tr>

                              <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">Car Name : </strong></td>

                                <td class="content_text">{$det[a].prod_name}</td>
                              </tr>

                              <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">Category : </strong></td>

                                <td class="content_text">{$det[a].category}</td>

                                </tr>
                                
                               <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">Agent Name : </strong></td>

                                <td class="text1">{$fname} {$lname}</td>

                                </tr>

                              

                              <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">Agent Email : </strong></td>

                                <td class="text1">{$det[a].email}</td>

                                </tr>

                              

                              <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">Agent Code : </strong></td>

                                <td class="text1">{$det[a].agent}</td>

                                </tr>

                                 <tr>

                                <td class="car_1_blc" valign="top"><strong class="car_1_blc">Contact No. : </strong></td>

                                <td class="text1">{$phone}<br /><br />{$phone2}</td>

                                </tr>
                                
                              <tr>


                                <td class="car_1_blc"><strong class="car_1_blc">Sale Price : </strong></td>

                                <td class="content_text">${$det[a].saleprice}</td> 

                                </tr>  

                             {if $smarty.session.user_log neq ''}
                              <tr>


                                <td class="car_1_blc"><strong class="car_1_blc">Dealer Price : </strong></td>

                                <td class="content_text">{$det[a].prod_price}</td>

                                </tr>

			{/if}
                              

                           <!--   <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">Car Quantity : </strong></td>

                                <td class="content_text">{$det[a].quant}</td>

                                </tr>-->

                              

                              <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">Road Tax : </strong></td>

                                <td class="content_text">{$det[a].roadtax}</td>

                                </tr>

                              

                              <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">Transmission  : </strong></td>

                                <td class="content_text">{$det[a].trans}</td>

                                </tr>

                              

                              <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">Engine Capacity : </strong></td>

                                <td class="content_text">{$det[a].capacity}</td>

                                </tr>

                              

                              <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">Mileage : </strong></td>

                                <td class="content_text">{$det[a].mile}</td>

                                </tr>

                                                            

                              <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">Register date  : </strong></td>

                                <td class="content_text">{$det[a].regdate}</td>

                                </tr>
                                

                                
                              <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">Features  : </strong></td>

                                <td class="content_text">{$det[a].features}</td>

                                </tr>
                                
                              <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">Accessories  : </strong></td>

                                <td class="content_text">{$det[a].acc}</td>

                                </tr>
                                
                              <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">COE  : </strong></td>

                                <td class="content_text">{$det[a].coe}</td>

                                </tr>
                                
                               <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">OMV  : </strong></td>

                                <td class="content_text">{$det[a].omv}</td>

                                </tr>
                                
                               <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">Depreciation  : </strong></td>

                                <td class="content_text">{$det[a].dep}</td>

                                </tr>
                                
                               <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">No. of owners  : </strong></td>

                                <td class="content_text">{$det[a].owner}</td>

                                </tr>
                                
                                <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">Type of Vehicle   : </strong></td>

                                <td class="content_text">{$det[a].type}</td>

                                </tr>

                              

                              <tr>

                                <td class="car_1_blc" valign="top"><strong class="car_1_blc">Description  : </strong></td>

                                <td colspan="2" class="content_text">{$det[a].desc}</td>

                              </tr>



                              

                              <tr>

                                <td height="10" colspan="3"></td>

                                </tr>



                              <tr>

                                <td width="25%"> </td>

                                <td colspan="2"><a href="sendmail.php?id={$det[a].prod_id}"><img src="images/sendthemail.jpg" border="0" style="padding:10px;" /></a></td>

                              </tr>

                              

                            </table></td>

                          </tr>

                        </table></td>

                      </tr>

                      

                    </table></td>

                  </tr>

                </table></td>



                <!-- Side panel -->

              	<td width="32%" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">

                {include file="side.tpl"}

                 </table></td>

               <!-- Side ends -->



              </tr>

              <tr>

                <td width="68%"> </td>

                <td> </td>

              </tr>

              

            </table></td>

          </tr>

        </table></td>

      </tr>

{/section}


      {literal}



<script type="text/javascript" charset="utf-8">

	$(document).ready(function(){

		$("a[rel^='prettyPhoto']").prettyPhoto();

	});

</script>

   {/literal}
			</table>

</form>
		 </td>
	  </table>
	  </tr>
	  

</td>
	 </tr>
</td>
</tr>

 

The error, Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/carnexco/public_html/view_car.php on line 5

 

Link, http://carnex.com.sg/view_car.php?id=97

You must have a query error. Use this to display your error and then fix it.

replace

<?php
$result = mysql_query("SELECT * FROM tab_product WHERE id='".mysql_real_escape_string($_GET['id'])."'");
?>

with

<?php
if(!$result = mysql_query("SELECT * FROM tab_product WHERE id='".mysql_real_escape_string($_GET['id'])."'")) {
die(mysql_error());
}
?>

You must have a query error. Use this to display your error and then fix it.

replace

<?php
$result = mysql_query("SELECT * FROM tab_product WHERE id='".mysql_real_escape_string($_GET['id'])."'");
?>

with

<?php
if(!$result = mysql_query("SELECT * FROM tab_product WHERE id='".mysql_real_escape_string($_GET['id'])."'")) {
die(mysql_error());
}
?>

 

The error is, Unknown column 'id' in 'where clause'.

 

I've changed the script and now the webpage displays but still didn't display anything of the view_car.tpl script..

<?php

include "includes/common.php";
$result = mysql_query("SELECT * FROM tab_product WHERE prod_id='".mysql_real_escape_string($_GET['id'])."'");

$thisProduct = mysql_fetch_assoc($result);
$objSmarty->assign("product",$thisProduct);
$objSmarty->assign("IncludeTemplate","view_car.tpl");
$objSmarty->display("pagetemplateautomobile.tpl")
?>

 

In my view_car.tpl i've used scripts like.

 

{$det[a].prod_name} // this is just one example, i have more in the view_car.tpl itself. 

 

And

 

<tr>

                               
                                <td align="center" class="content_text" valign="top" colspan="2">
                                {if $det[a].prod_imgsize1 eq '0' and $det[a].prod_imgsize2 eq '0' and $det[a].prod_imgsize3 eq '0' and $det[a].prod_imgsize4 eq '0' and $det[a].prod_imgsize5 eq '0' and $det[a].prod_imgsize6 eq '0' and $det[a].prod_imgsize7 eq '0'}<img src="product_img/no_image.gif" width="100" align="absmiddle"  border="1" style="border-color:#CCCCCC; padding:5px;"/>

                                {else}
<!--{if $det[a].prod_imgsize1 neq '0'}-->

<a href="product_img/{$det[a].prod_imgname1}"rel="prettyPhoto[mixed]"><img src="product_img/{$det[a].prod_imgname1}" width="140" height="100" border="1" style="border-color:#CCCCCC; padding:5px;"/></a>{/if}
{if $det[a].prod_imgsize2 neq '0'}<a href="product_img/{$det[a].prod_imgname2}"  rel="prettyPhoto[mixed]"><img src="product_img/{$det[a].prod_imgname2}" width="140" height="100" border="1" style="border-color:#CCCCCC; padding:5px;"/></a>{/if}
{if $det[a].prod_imgsize3 neq '0'}<a href="product_img/{$det[a].prod_imgname3}"  rel="prettyPhoto[mixed]"><img src="product_img/{$det[a].prod_imgname3}" width="140" height="100" border="1" style="border-color:#CCCCCC; padding:5px;"/></a>{/if}
{if $det[a].prod_imgsize4 neq '0'}<a href="product_img/{$det[a].prod_imgname4}"  rel="prettyPhoto[mixed]"><img src="product_img/{$det[a].prod_imgname4}" width="140" height="100" border="1" style="border-color:#CCCCCC; padding:5px;"/></a>{/if}
{if $det[a].prod_imgsize5 neq '0'}<a href="product_img/{$det[a].prod_imgname5}" rel="prettyPhoto[mixed]"><img src="product_img/{$det[a].prod_imgname5}" width="140" height="100" border="1" style="border-color:#CCCCCC; padding:5px;"/></a>{/if}
{if $det[a].prod_imgsize6 neq '0'}<a href="product_img/{$det[a].prod_imgname6}" rel="prettyPhoto[mixed]"><img src="product_img/{$det[a].prod_imgname6}" width="140" height="100" border="1" style="border-color:#CCCCCC; padding:5px;"/></a>{/if}
{if $det[a].prod_imgsize7 neq '0'}<a href="product_img/{$det[a].prod_imgname7}"  rel="prettyPhoto[mixed]"><img src="product_img/{$det[a].prod_imgname7}" width="140" height="100" border="1" style="border-color:#CCCCCC; padding:5px;"/></a>{/if}
{/if}{if $det[a].feat eq '1'}




                                  <div style="margin-top:-5px;" align="center"><img src="administrator/images/favorites.png" width="36" border="0" /></div>


                                {/if}</td>

                              </tr>

 

And also starting them off by.

 

{section name=a loop=$det}

 

I believe the codes should look like

 

$det1 = ......
$det2 = ...... 

 

For the php script, but i couldn't get it right.

 

My view_car.tpl can be found in the previous post.

Someone please help me! This is really driving me nuts!

There is not such variable as $det

<a href="product_img/{$det[a].prod_imgname1}"rel="prettyPhoto[mixed]">

 

You have assigned $product to the template that contains the selected car record.

<a href="product_img/{$product.prod_imgname1}"rel="prettyPhoto[mixed]">

 

You really need to learn php basics from a book. I do not think you are grasping what you are doing.

There is not such variable as $det

<a href="product_img/{$det[a].prod_imgname1}"rel="prettyPhoto[mixed]">

 

You have assigned $product to the template that contains the selected car record.

<a href="product_img/{$product.prod_imgname1}"rel="prettyPhoto[mixed]">

 

You really need to learn php basics from a book. I do not think you are grasping what you are doing.

 

I think i've found the problem. Its with the php and tpl.

Because if i change the

$objSmarty->assign("IncludeTemplate","view_car.tpl");

To

$objSmarty->assign("IncludeTemplate","preownedcars.tpl");

 

The webpage actually takes in the preownedcars.tpl but the moment i change it back to view_car.tpl the web doesn't take in the .tpl file anymore..

Could there be a conflict somewhere?

Shouldn't be.

 

Have you tested just displaying it rather than including it?

<?php
$objSmarty->assign("IncludeTemplate","view_car.tpl");
?>

to

<?php
// this is just a test
$objSmarty->display("view_car.tpl");
exit();
?>

 

I dont think the underscore makes a difference but yoiu could try renaming the file to viewcar.tpl and change the value in the assign method.

 

Are you including the template correctly?

{include file=$IncludeTemplate}

 

 

Shouldn't be.

 

Have you tested just displaying it rather than including it?

<?php
$objSmarty->assign("IncludeTemplate","view_car.tpl");
?>

to

<?php
// this is just a test
$objSmarty->display("view_car.tpl");
exit();
?>

 

I dont think the underscore makes a difference but yoiu could try renaming the file to viewcar.tpl and change the value in the assign method.

 

Are you including the template correctly?

{include file=$IncludeTemplate}

 

I've tried every ways, none worked & yup i've included the template correctly.

If there is an error including the template then you would see a smarty error on the screen. If not the template must be included correctly. If I were you I would view the HTML source in the browser and see what the final output is displaying. Just add some simple text to view_car.tpl like 'Hello World'. Is it in the source?

If there is an error including the template then you would see a smarty error on the screen. If not the template must be included correctly. If I were you I would view the HTML source in the browser and see what the final output is displaying. Just add some simple text to view_car.tpl like 'Hello World'. Is it in the source?

 

Prob is no errors were shown, and i'm very sure everything is included correctly. I've view the page source and from what i see, only,

 <tr>
    <td style="padding-top:30px; padding-bottom:20px;"><table width="780" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="540" valign="top"><table width="540" border="0" align="left" cellpadding="0" cellspacing="0">
          <tr>
            <td valign="top" class="body"><form id="form1" name="form1" method="post" action="">
              <table width="93%" border="0" align="center" cellpadding="2" cellspacing="4" class="border">
{literal}

<script src="http://www.google.com/jsapi" type="text/javascript"></script>

	<script type="text/javascript" charset="utf-8">

		google.load("jquery", "1.3");

	</script>






	<link rel="stylesheet" href="css/prettyPhoto.css" type="text/css" media="screen" title="prettyPhoto main stylesheet" charset="utf-8" />

	<script src="js/jquery.prettyPhoto.js" type="text/javascript" charset="utf-8"></script>

<script type="text/javascript">

<script type="text/javascript" src="js/login.js"></script>


<style type="text/css">


.error {

font: normal 12px arial;

text-align:center;

font-weight:bold;

background-color: #ffc;

border: 1px solid #c00;

}



.ok {

font: normal 12px arial;

text-align:center;

font-weight:bold;

background-color:#EFFFDF;

border: 1px solid #339966;

color:#009900;

}



</style>

{/literal}

 

and

<script type="text/javascript" charset="utf-8"> 

	$(document).ready(function(){

		$("a[rel^='prettyPhoto']").prettyPhoto();

	});

</script> 

   
			</table> 

</form> 
		 </td> 
	  </table> 
	  </tr> 
	  

</td> 
	 </tr> 
</td> 
</tr>

 

anything within the loops aren't showed.

the scripts inside the section.

{section name=a loop=$det}

<tr>

        <td width="580" align="center" valign="top"><table width="580" border="0" cellspacing="0" cellpadding="0">

          <tr>

            <td height="672" align="center" valign="top" background="images/boby_bg_top.jpg" style="background-position:top; background-repeat:repeat-x; background-color:#FFFFFF;"><table width="100%" border="0" cellspacing="0" cellpadding="0">

              <tr>

                <td height="19"> </td>

                <td> </td>

              </tr>

              <tr>

                <td width="580" valign="top"><table width="580" border="0" align="left" cellpadding="0" cellspacing="0">

                  <tr>

                    <td height="620" align="center" valign="top"><table width="98%" border="0" align="center" cellpadding="5" cellspacing="0">

                      

                      <tr>

                                

                                <td width="32%" align="left" valign="middle"><!--<a href="carforsale.php"><img src="images/back.jpg" name="back" width="80" border="0" /></a>--></td>

                                <td width="43%" align="left" valign="middle"> </td>

                       </tr>

                      <tr align="left">

                        <td width="12%" class="tit_1">{$det[a].prod_name}</td>

                        <td width="88%" class="tit_1"> </td>

                      </tr>

                      

                      <tr align="left">

                        <td colspan="2" valign="top" class="tit_1"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="registration_border">

                          <tr>

                            <td height="228" valign="top" bgcolor="#FFFFFF"><table width="95%" border="0" align="center" cellpadding="5" cellspacing="0">

                              	

                              <tr>

                                <td height="15" colspan="3"></td>

                              </tr>



                              

                                

                              <tr>

                               
                                <td align="center" class="content_text" valign="top" colspan="2">
                                {if $det[a].prod_imgsize1 eq '0' and $det[a].prod_imgsize2 eq '0' and $det[a].prod_imgsize3 eq '0' and $det[a].prod_imgsize4 eq '0' and $det[a].prod_imgsize5 eq '0' and $det[a].prod_imgsize6 eq '0' and $det[a].prod_imgsize7 eq '0'}<img src="product_img/no_image.gif" width="100" align="absmiddle"  border="1" style="border-color:#CCCCCC; padding:5px;"/>

                                {else}
<!--{if $det[a].prod_imgsize1 neq '0'}-->

<a href="product_img/{$det[a].prod_imgname1}"rel="prettyPhoto[mixed]"><img src="product_img/{$det[a].prod_imgname1}" width="140" height="100" border="1" style="border-color:#CCCCCC; padding:5px;"/></a>{/if}
{if $det[a].prod_imgsize2 neq '0'}<a href="product_img/{$det[a].prod_imgname2}"  rel="prettyPhoto[mixed]"><img src="product_img/{$det[a].prod_imgname2}" width="140" height="100" border="1" style="border-color:#CCCCCC; padding:5px;"/></a>{/if}
{if $det[a].prod_imgsize3 neq '0'}<a href="product_img/{$det[a].prod_imgname3}"  rel="prettyPhoto[mixed]"><img src="product_img/{$det[a].prod_imgname3}" width="140" height="100" border="1" style="border-color:#CCCCCC; padding:5px;"/></a>{/if}
{if $det[a].prod_imgsize4 neq '0'}<a href="product_img/{$det[a].prod_imgname4}"  rel="prettyPhoto[mixed]"><img src="product_img/{$det[a].prod_imgname4}" width="140" height="100" border="1" style="border-color:#CCCCCC; padding:5px;"/></a>{/if}
{if $det[a].prod_imgsize5 neq '0'}<a href="product_img/{$det[a].prod_imgname5}" rel="prettyPhoto[mixed]"><img src="product_img/{$det[a].prod_imgname5}" width="140" height="100" border="1" style="border-color:#CCCCCC; padding:5px;"/></a>{/if}
{if $det[a].prod_imgsize6 neq '0'}<a href="product_img/{$det[a].prod_imgname6}" rel="prettyPhoto[mixed]"><img src="product_img/{$det[a].prod_imgname6}" width="140" height="100" border="1" style="border-color:#CCCCCC; padding:5px;"/></a>{/if}
{if $det[a].prod_imgsize7 neq '0'}<a href="product_img/{$det[a].prod_imgname7}"  rel="prettyPhoto[mixed]"><img src="product_img/{$det[a].prod_imgname7}" width="140" height="100" border="1" style="border-color:#CCCCCC; padding:5px;"/></a>{/if}
{/if}{if $det[a].feat eq '1'}




                                  <div style="margin-top:-5px;" align="center"><img src="administrator/images/favorites.png" width="36" border="0" /></div>


                                {/if}</td>

                              </tr>

                              <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">Car Name : </strong></td>

                                <td class="content_text">{$det[a].prod_name}</td>
                              </tr>

                              <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">Category : </strong></td>

                                <td class="content_text">{$det[a].category}</td>

                                </tr>
                                
                               <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">Agent Name : </strong></td>

                                <td class="text1">{$fname} {$lname}</td>

                                </tr>

                              

                              <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">Agent Email : </strong></td>

                                <td class="text1">{$det[a].email}</td>

                                </tr>

                              

                              <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">Agent Code : </strong></td>

                                <td class="text1">{$det[a].agent}</td>

                                </tr>

                                 <tr>

                                <td class="car_1_blc" valign="top"><strong class="car_1_blc">Contact No. : </strong></td>

                                <td class="text1">{$phone}<br /><br />{$phone2}</td>

                                </tr>
                                
                              <tr>


                                <td class="car_1_blc"><strong class="car_1_blc">Sale Price : </strong></td>

                                <td class="content_text">${$det[a].saleprice}</td> 

                                </tr>  

                             {if $smarty.session.user_log neq ''}
                              <tr>


                                <td class="car_1_blc"><strong class="car_1_blc">Dealer Price : </strong></td>

                                <td class="content_text">{$det[a].prod_price}</td>

                                </tr>

			{/if}
                              

                           <!--   <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">Car Quantity : </strong></td>

                                <td class="content_text">{$det[a].quant}</td>

                                </tr>-->

                              

                              <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">Road Tax : </strong></td>

                                <td class="content_text">{$det[a].roadtax}</td>

                                </tr>

                              

                              <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">Transmission  : </strong></td>

                                <td class="content_text">{$det[a].trans}</td>

                                </tr>

                              

                              <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">Engine Capacity : </strong></td>

                                <td class="content_text">{$det[a].capacity}</td>

                                </tr>

                              

                              <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">Mileage : </strong></td>

                                <td class="content_text">{$det[a].mile}</td>

                                </tr>

                                                            

                              <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">Register date  : </strong></td>

                                <td class="content_text">{$det[a].regdate}</td>

                                </tr>
                                

                                
                              <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">Features  : </strong></td>

                                <td class="content_text">{$det[a].features}</td>

                                </tr>
                                
                              <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">Accessories  : </strong></td>

                                <td class="content_text">{$det[a].acc}</td>

                                </tr>
                                
                              <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">COE  : </strong></td>

                                <td class="content_text">{$det[a].coe}</td>

                                </tr>
                                
                               <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">OMV  : </strong></td>

                                <td class="content_text">{$det[a].omv}</td>

                                </tr>
                                
                               <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">Depreciation  : </strong></td>

                                <td class="content_text">{$det[a].dep}</td>

                                </tr>
                                
                               <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">No. of owners  : </strong></td>

                                <td class="content_text">{$det[a].owner}</td>

                                </tr>
                                
                                <tr>

                                <td class="car_1_blc"><strong class="car_1_blc">Type of Vehicle   : </strong></td>

                                <td class="content_text">{$det[a].type}</td>

                                </tr>

                              

                              <tr>

                                <td class="car_1_blc" valign="top"><strong class="car_1_blc">Description  : </strong></td>

                                <td colspan="2" class="content_text">{$det[a].desc}</td>

                              </tr>



                              

                              <tr>

                                <td height="10" colspan="3"></td>

                                </tr>



                              <tr>

                                <td width="25%"> </td>

                                <td colspan="2"><a href="sendmail.php?id={$det[a].prod_id}"><img src="images/sendthemail.jpg" border="0" style="padding:10px;" /></a></td>

                              </tr>

                              

                            </table></td>

                          </tr>

                        </table></td>

                      </tr>

                      

                    </table></td>

                  </tr>

                </table></td>



                <!-- Side panel -->

              	<td width="32%" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">

                {include file="side.tpl"}

                 </table></td>

               <!-- Side ends -->



              </tr>

              <tr>

                <td width="68%"> </td>

                <td> </td>

              </tr>

              

            </table></td>

          </tr>

        </table></td>

      </tr>

{/section}

 

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.