pommi Posted November 20, 2008 Share Posted November 20, 2008 Can some one please help, I have a problem with my code which I believe I have isolated to some where here. The code seems to stop after "print "<p><img src='../font/images/divider.jpg' /></p>";" Any ideas??? $x = 5; $row = 0; array_multisort($card, SORT_DESC); //Sort Array while ($row < $x) { //Divider print "<p><img src='../font/images/divider.jpg' /></p>"; //table results print $query; print "<p><a href='../creditcard_features.php?id=" . $card[$row]["id"] . "'>" . $card[$row]["bank"] . " " . $card[$row]["name"] . " - More Details</a></p>"; print "<table>"; //Interest Rate, Fee and Score print "<tr><td class='tbl_title'>Interest Rate</td><td class='tbl_title'>Annual Fee</td><td class='tbl_title'>Score</td><td></td></tr>"; print "<tr><td class='tbl_text'>" . $card[$row]["rate"] . "%</td>"; print "<td class='tbl_text'>$" . $card[$row]["fee"] . "</td>"; print "<td class='tbl_score'>" . $card[$row]["score"] . "</td></tr>"; print "<tr><td class='tbl_text'><a href=../creditcard_features.php?id=" . $card[$row]["id"] . "><img class=img src=../images/cards/" . $card[$row]["image"] . " /></a></td>"; print "<td class='tbl_text'><p>" . $card[$row]["interest_free"] . " days interest free</p>"; //Balance Tranfer if($card[$row]["balance_transfer"] == "Yes") { print $card[$row]["transfer_rate"] . "% balance transfer"; if(!empty($card[$row]["bt_period"])) { print " for " . $card[$row]["bt_period"] ;} print "</td>"; } //Apply session_start(); $campaign = $_SESSION['campaign']; print "<td class='tbl_text'><a href='../tracking.php?id=" . $card[$row]["id"] . "&campaign=" . $campaign . "' target='_blank'><img src='../font/images/appy_now.jpg' class='img' alt='Apply Online' /></a></td></tr>"; //Obtain Card Ranking Result print "<tr><td class=main colspan='3' class='tbl_text'>"; require'../search_rank_script.php'; //Rank Card print "<a href='../rank_menu?cr=" . $card[$row]["id"] . "#' class=menuLink2>Rate the " . $card[$row]["bank"] . " " . $card[$row]["name"] . "card</a></td></tr></table>"; $row++; } Quote Link to comment https://forums.phpfreaks.com/topic/133562-php-code-problem/ Share on other sites More sharing options...
ratcateme Posted November 20, 2008 Share Posted November 20, 2008 try adding error_reporting(E_ALL); ini_set(display_errors,true); to the top of your page. there are no syntax errors in it so it could be a problem with your vars Scott. Quote Link to comment https://forums.phpfreaks.com/topic/133562-php-code-problem/#findComment-694722 Share on other sites More sharing options...
pommi Posted November 21, 2008 Author Share Posted November 21, 2008 seems to be a problem with my query / mysql database.... but the strange thing is it works perfeclty on my test server but not the prod server. They both are running PHP 5 and MySQL client version: 5.0.22 (test) MySQL client version: 5.0.45 (prod) can anyone tell me why I may get a different result from the two machines?? Quote Link to comment https://forums.phpfreaks.com/topic/133562-php-code-problem/#findComment-694828 Share on other sites More sharing options...
Maq Posted November 21, 2008 Share Posted November 21, 2008 Can we see your query execution? Do you have any debugging statements? Are the test and production DBs located on the same server? Quote Link to comment https://forums.phpfreaks.com/topic/133562-php-code-problem/#findComment-694835 Share on other sites More sharing options...
pommi Posted November 21, 2008 Author Share Posted November 21, 2008 Ok, the error I am receiving is: "Fatal error: Cannot use string offset as an array in" I know the database query is working and passing a value.... I believe its some issue with PHP5 but I can't find the answer anywhere.... and anyone help?? $card[] = array( id => $row['id'], name => $row['name'], bt_period => $row['bt_period'], transfer_rate => $row['transfer_rate'], fee => ($row['fee'] + $row['reward_fee']), rewards => $row['rewards'], interest_free => $row['interest_free'], image => $row['img'], url => $row['link'] ); Quote Link to comment https://forums.phpfreaks.com/topic/133562-php-code-problem/#findComment-695237 Share on other sites More sharing options...
ratcateme Posted November 21, 2008 Share Posted November 21, 2008 which line is the error coming from? that code you just posted or the code you posted at the start could you post all your code including the query. Scott. Quote Link to comment https://forums.phpfreaks.com/topic/133562-php-code-problem/#findComment-695239 Share on other sites More sharing options...
mtoynbee Posted November 21, 2008 Share Posted November 21, 2008 I think it is because you have specied $row as 0 and then use it as an array. Put $row = array(); before you use it as an array. That should fix it. Quote Link to comment https://forums.phpfreaks.com/topic/133562-php-code-problem/#findComment-695240 Share on other sites More sharing options...
pommi Posted November 21, 2008 Author Share Posted November 21, 2008 Just tried declaring the $row, no luck sadly... $row is the variable storing the results of my sql call "$row = mysql_fetch_array( $mysql )" So I know the the values are passing into the variable $row, but they don't seem to be feeding into the cost in my previous comment, and I am receiving the error msg i posted Quote Link to comment https://forums.phpfreaks.com/topic/133562-php-code-problem/#findComment-695270 Share on other sites More sharing options...
samshel Posted November 21, 2008 Share Posted November 21, 2008 try this $card[] = array( 'id' => $row['id'], 'name' => $row['name'], 'bt_period' => $row['bt_period'], 'transfer_rate' => $row['transfer_rate'], 'fee' => ($row['fee'] + $row['reward_fee']), 'rewards' => $row['rewards'], 'interest_free' => $row['interest_free'], 'image' => $row['img'], 'url' => $row['link'] ); Quote Link to comment https://forums.phpfreaks.com/topic/133562-php-code-problem/#findComment-695274 Share on other sites More sharing options...
pommi Posted November 21, 2008 Author Share Posted November 21, 2008 sadly no good Quote Link to comment https://forums.phpfreaks.com/topic/133562-php-code-problem/#findComment-695298 Share on other sites More sharing options...
mtoynbee Posted November 21, 2008 Share Posted November 21, 2008 Perhaps can you post the whole script in relevant sections and the line number the error occurs? That would help to determine the issue. Quote Link to comment https://forums.phpfreaks.com/topic/133562-php-code-problem/#findComment-695324 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.