Forum Moderators: coopster

Message Too Old, No Replies

same code on two pages doesnt work on both

         

oxidetones

12:58 am on Aug 18, 2007 (gmt 0)

10+ Year Member



this is really weird...

I have this query:

mysql_select_db($database_BBAddict, $BBAddict);
$query_rsModels = "SELECT id, Type, Name, img FROM bb_data ORDER BY Type DESC";
$rsModels = mysql_query($query_rsModels, $BBAddict) or die(mysql_error());
$row_rsModels = mysql_fetch_assoc($rsModels);
$totalRows_rsModels = mysql_num_rows($rsModels);

on two different pages, which feeds this form:

<form id="form3">
<select name="menu3" id="textfield1" onchange="MM_jumpMenu('parent',this,0)">
<option value="">please choose...</option>
<?php do {?>
<option value="Model.php?id=<?php echo $row_rsModels['id']?>"><?php echo $row_rsModels['Type']?></option>
<?php
} while ($row_rsModels = mysql_fetch_assoc($rsModels));
$rows = mysql_num_rows($rsModels);
if($rows > 0) {
mysql_data_seek($rsModels, 0);
$row_rsModels = mysql_fetch_assoc($rsModels);
}?>
</select>
</form>

The code is identical on both pages, however the drop down list is only populated with parameters from the db on one... anyone have any idea what causes this?

JMusic

2:41 am on Aug 18, 2007 (gmt 0)

10+ Year Member



Are both pages in the same directory/on the same server?

oxidetones

3:28 am on Aug 18, 2007 (gmt 0)

10+ Year Member



yes, both are in the root directory. It cant be the sql query, as I can call data from it, but within the form it won't work on the one page....

Borgscan

9:20 am on Aug 18, 2007 (gmt 0)

10+ Year Member



Is there any error on the page where it doesn't work or is the select box simply empty?

oxidetones

2:52 pm on Aug 18, 2007 (gmt 0)

10+ Year Member



no error, just an empty drop down...

borntobeweb

9:36 pm on Aug 18, 2007 (gmt 0)

10+ Year Member



Did you check the generated page's source code for errors? I ask because browsers tend to ignore extraneous text within <select> elements. Without seeing the rest of the code, i'd guess towards a variable scope problem, maybe a missing 'global' declaration?

oxidetones

2:26 am on Aug 19, 2007 (gmt 0)

10+ Year Member



i fixed it by building the page from scratch... no idea what the issue was, thanks for the suggestions though :)

Habtom

6:28 am on Aug 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




...
$row_rsModels = mysql_fetch_assoc($rsModels);
$totalRows_rsModels = mysql_num_rows($rsModels);

You had the above and again you tried to use it in the while loop.

php.net on mysql_fetch_assoc


Returns an associative array that corresponds to the fetched row and moves the internal data pointer ahead.

That is a bit of a logical reason I could find out.

Whatever it was, it seems you have moved forward.

Habtom

oxidetones

9:25 pm on Aug 19, 2007 (gmt 0)

10+ Year Member



thanks habtom, I guess that I had some code debris in there, which was solved by rebuilding the page....