Page is a not externally linkable
- Code, Content, and Presentation
-- PHP Server Side Scripting
---- Choosing row name dynamically


CyBerAliEn - 4:59 pm on Apr 29, 2010 (gmt 0)


Your code is logically sound; it appears now that something/somewhere isn't what it should be (ie: a variable is probably missing).

Modify your code with Matthew's suggestion, such as the following:

if (!$foundData){
$result = mysql_query("SELECT * FROM ".$targetTable." WHERE ".$primary." LIKE '".$primaryValue."'");
while($row = mysql_fetch_array($result)) {
$fieldName = $targetList[$i];
$oldValue = $row[$fieldName];
echo "<hr><pre>";
echo "i($i)\n";
echo "fieldName($fieldName)\n";
echo "oldValue($oldValue)\n";
echo "targetList...\n";
print_r($targetList);
echo "row...\n";
print_r($row);
echo "</pre><hr>";
}


This should give you all of the values in HTML/readable form so you can SEE what is actually going on. It is possible it is something as simple as "i" being wrong, etc. You need to put debugging code (temporarily) in like this to track and trace where the issue is coming from.


Thread source:: http://www.webmasterworld.com/php/4124405.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com