please, need help in this error

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!

Moderator: General Moderators

Post Reply
minos_mks
Forum Commoner
Posts: 69
Joined: Thu Feb 04, 2010 1:58 am

please, need help in this error

Post by minos_mks »

i am almost done with my first dynamic php wesite. it's called copticlist. my problem apper only when i did the uploading but in my localhost every thing working fine and attached for you the pic of the error. and you can check the error in the url:
http://www.copticlist.webatu.com/catg_a ... =ad_S_DATE

i cheked already for this error and they said that may be the query doesn't have data but this is not my case cause if you open the combobox (the query) you will fiend data

and this is the code for the all page:

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Ajax Tutorial: Dynamic Loading of ComboBox using jQuery and Ajax in PHP</title>
<script type="text/javascript" src="jquery-1.3.2.js"></script>

<script type="text/javascript">

$(document).ready(function() {

	$('#loader').hide();
	$('#show_heading').hide();
	
	$('#search_category_id').change(function(){
		$('#show_sub_categories').fadeOut();
		$('#loader').show();
		$.post("get_chid_categories.php", {
			parent_id: $('#search_category_id').val(),
		}, function(response){
			
			setTimeout("finishAjax('show_sub_categories', '"+escape(response)+"')", 400);
		});
		return false; 
	});
    
});
  
function finishAjax(id, response){
  $('#loader').hide();
  $('#show_heading').show();
  $('#'+id).html(unescape(response));
  $('#'+id).fadeIn();
} 

function alert_id()
{
	
	$city =  $('#sub_category_id').val()  ; 
	return false;
}
</script>
<style>
</style>
<link href="css/Main.css" rel="stylesheet" type="text/css" />
</head>
<?php require_once("includes/functions.php"); ?>
<?php require_once("includes/connection.php"); 
      require_once('zipcode.class.php');?> 
<body>
<!-- <table width="852" border="0" background="#Ff6600" id="searchtable" align="center" > --> 
<div style="padding-left:30px;">
<form class="searchForm" action="catg_ads_disc.php?tablenumb=2&start=0&search_or_no=1&order=ad_S_DATE" method="post" >
<div>
	<div class="both">
		State
		<select name="state"  id="search_category_id">
		<option value="" selected="selected"></option>
		<?php
		$query = "select distinct state_name from zip_code ORDER BY state_name ";
		$results = mysql_query($query);
		
		while ($rows = mysql_fetch_assoc(@$results))
		{?>
			<option value="<?php echo $rows['state_name'];?>"><?php echo $rows['state_name'];?></option>
		<?php
		}?>
		</select>		
	</div>
	
	<div class="both2">
		<h4 id="show_heading"><img src="loader.gif" style="margin-top:8px; float:left" id="loader" alt="" /></h4>
		<div id="show_sub_categories" align="center"></div>
	</div>
</div>	

</div>
<div>
     
<table width="852" border="0" background="#Ff6600" id="searchtable" align="center">
<tr>
    <td colspan="2" align="left">Search for:  </td>
    <td colspan="7" align="left"><input name="disc" size="68" type="text"/></td>
    <td colspan="2">Model</td>
    <td colspan="4"><select name="model">
      <?php
  $cars_models=select_cars_models(cars_models);
  $model = mysql_fetch_assoc($cars_models);
do {  
?>
      <option value="<?php echo $model['cars_marke_code']?>"><?php echo $model['cars_model_name']?></option>
      <?php
} while ($model = mysql_fetch_assoc($cars_models));
  $models = mysql_num_rows($model);                               ///////   this is the error 
  if($models > 0) {
      mysql_data_seek($model, 0);
      //$row_Recordset1 = mysql_fetch_assoc($model);
  }
?>
    </select></td>
    </tr>
  
    <tr>
      <td width="62">Year</td>
    <?php
 $yearRange = 100;                                            //////  preview the list of the  min  year for 100 year        
      $thisYear = date('Y');
      $startYear = ($thisYear - $yearRange);
      
    //  echo       $startYear ;echo       $thisYear ;
       echo "<td colspan=\"2\"><select name=\"min_year\" id=\"min_year\">";
         $years = (range($startYear, $thisYear));                     
      foreach ($years as $year) {
         echo "<option value=$year>$year</option> "   ;   
      }
echo"</select></td>";
?>  
    <td width="6"><strong>:</strong></td>
    
    <?php                                                    //////  preview the list of the  max  year for 100 year
 $yearRange = 100;
      $thisYear = date('Y');                                                        
      $startYear = ($thisYear - $yearRange);    
       echo "<td width=\"63\"><select name=\"max_year\" id=\"max_year\">";                       
      foreach (range($thisYear,$startYear) as $year) {
         echo "<option value=$year>$year</option> "   ;   
      }
echo"</select></td>";?>

    <td width="46">Mileage</td>
    <td width="64"><input name="min_mileage" type="text" size="10"/> </td>
    <td width="4"><strong>:</strong></td>
    <td><label>
        <input type="text" name="max_mileage" id="max_mileage" size="10">
      </label></td>
    <td colspan="2">Price</td>
    <td width="60"><input name="min_price" type="text" size="10" /></td>
    <td width="5"><strong>:</strong></td>
    <td width="60"><input name="max_price" type="text" size="10" /></td>
  
    <td width="115">&nbsp;</td>
  
    </tr>
      <tr>
      <td colspan="6"  >
        <label>
          <input  type="checkbox" name="has_pic" value="1" id="has_pic_0" checked= checked >
         Has Pic</label></td>
   <td  align="center" colspan="4">
     <label>
       <input type="checkbox" name="only_titel" value="1" id="has_pic_0" checked= checked>
       Search Only on The Titel </label></td>     
       <td width="46"><input type="hidden" name="search_or_no" value="2"/></td>
      </tr> 
    <td colspan="14" align="right"><input name="submit" type="submit" id="submit" value="       Search For Autos       "></td>
    </tr>
</table>
</form>
</html>
Attachments
error.jpg
error.jpg (156.79 KiB) Viewed 1366 times
Gargoyle
Forum Contributor
Posts: 130
Joined: Wed Jul 14, 2010 12:25 am

Re: please, need help in this error

Post by Gargoyle »

Code: Select all

$model = mysql_fetch_assoc($cars_models);
(...)
while ($model = mysql_fetch_assoc($cars_models));
you're overwriting your resource id that is stored in §model.
minos_mks
Forum Commoner
Posts: 69
Joined: Thu Feb 04, 2010 1:58 am

Re: please, need help in this error

Post by minos_mks »

THANKX MAN SO MUCH , BUT SORREY I DON'T KNOW HOW I FIX IT !!!! :banghead: :banghead:
Gargoyle
Forum Contributor
Posts: 130
Joined: Wed Jul 14, 2010 12:25 am

Re: please, need help in this error

Post by Gargoyle »

use a different variable.

Code: Select all

while ($model2 = mysql_fetch_assoc($cars_models));
note that you will have to replace $model with $model2 within your loop as well
minos_mks
Forum Commoner
Posts: 69
Joined: Thu Feb 04, 2010 1:58 am

Re: please, need help in this error

Post by minos_mks »

if i change it in both of the line it's will be the same as it was , sorry can you explain that to me
Gargoyle
Forum Contributor
Posts: 130
Joined: Wed Jul 14, 2010 12:25 am

Re: please, need help in this error

Post by Gargoyle »

change

Code: Select all

$cars_models=select_cars_models(cars_models);
$model = mysql_fetch_assoc($cars_models);
do {  
?>
      <option value="<?php echo $model['cars_marke_code']?>"><?php echo $model['cars_model_name']?></option>
      <?php
} while ($model = mysql_fetch_assoc($cars_models));
to

Code: Select all

$cars_models=select_cars_models($cars_models);
do {  
?>
      <option value="<?php echo $model['cars_marke_code']?>"><?php echo $model['cars_model_name']?></option>
      <?php
} while ($model = mysql_fetch_assoc($cars_models));
minos_mks
Forum Commoner
Posts: 69
Joined: Thu Feb 04, 2010 1:58 am

Re: please, need help in this error

Post by minos_mks »

and how the $model will get the value ? where is fetch ?
Gargoyle
Forum Contributor
Posts: 130
Joined: Wed Jul 14, 2010 12:25 am

Re: please, need help in this error

Post by Gargoyle »

http://php.net/manual/en/control-struct ... .while.php

other than that

Code: Select all

mysql_num_rows($cars_models);
minos_mks
Forum Commoner
Posts: 69
Joined: Thu Feb 04, 2010 1:58 am

Re: please, need help in this error

Post by minos_mks »

sorry man , but when you look to the code you just told me to change mine to. you did write the Fitch statement and i don't understand how $model will get the value ???!! , thank you so much man for your immediate replay
Gargoyle
Forum Contributor
Posts: 130
Joined: Wed Jul 14, 2010 12:25 am

Re: please, need help in this error

Post by Gargoyle »

to understand, visit the link I provided and read the function reference. do-while is kinda backwards.
minos_mks
Forum Commoner
Posts: 69
Joined: Thu Feb 04, 2010 1:58 am

Re: please, need help in this error

Post by minos_mks »

ok thanx man 4 your help
Post Reply