offsprg01 Posted February 14, 2007 Share Posted February 14, 2007 well this is causing me issues, mainly becuase the server admin won't turn on php errors. so the script just stops when it's broken making it really hard to trouble shoot. anyway here's the code that causing the issues. <?php function truncateTickerMessage($String, $limit = 100) { $len = strlen($String); if ($len > $limit) $String = substr($String, 0, $limit) . '...'; return $String; } require_once('../Connections/TestDB.php'); mysql_select_db($database_TestDB, $TestDB); $query_Ticker = "SELECT * FROM Ticker ORDER BY TickerDate DESC LIMIT 5"; $Ticker = mysql_query($query_Ticker, $TestDB) or die(mysql_error()); $row_Ticker = mysql_fetch_assoc($Ticker); $c = 0; do { $c = $c++; $tickerLink[$c] = $row_Ticker['Link']; $tickerTitle[$c] = truncateTickerMessage($row_Ticker['Title']); $tickerMessage[$c] = truncateTickerMessage($row_Ticker['Message']); } while ($row_Ticker = mysql_fetch_assoc($Ticker)); ?> can you guys seen anything i'm missing? it all looks correct to me. Quote Link to comment Share on other sites More sharing options...
Balmung-San Posted February 14, 2007 Share Posted February 14, 2007 What's the problem? As well, why don't you run error_reporting(E_ALL) at the top of your script? That's not something that the server admin will usually block against, as it's specific to that script. Quote Link to comment Share on other sites More sharing options...
offsprg01 Posted February 14, 2007 Author Share Posted February 14, 2007 this is the problem http://www.harwoodmarketinggroup.com/WIP/index.php and running error_reporting(E_ALL) returns no errors Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 14, 2007 Share Posted February 14, 2007 you'll also have to do ini_set('display_errors', 1); Quote Link to comment Share on other sites More sharing options...
Balmung-San Posted February 14, 2007 Share Posted February 14, 2007 It could be that you're not outputting anything, at least not with this code. As well, $tickerLink, $tickerTitle, and $tickerMessage are all local within the loop, at least that's what I can tell from the little code you've given us. Quote Link to comment Share on other sites More sharing options...
offsprg01 Posted February 14, 2007 Author Share Posted February 14, 2007 you'll also have to do ini_set('display_errors', 1); still returns the same blank back ground and here's the output code, i know this code worksm if i run it with some test data in the variable it works. <script type="text/JavaScript"> <!-- //ticker java //scroller width var swidth=310; //scroller height var sheight=15; //background color var sbcolor='#000000'; //scroller's speed var sspeed=1; //messages are set below: <?php require('/includes/tickerSQL.php'); ?> var msg='' msg += '<a href="<?php echo $tickerLink['1'] ?>" target="_blank" title=""><?php echo $tickerTitle['1']; ?></a><br />'+ '<?php echo $tickerMessage['1']; ?><br />'+ '<br />'+ ''; Quote Link to comment Share on other sites More sharing options...
Balmung-San Posted February 14, 2007 Share Posted February 14, 2007 Use $tickerLink[1], $tickerTitle[1], and $tickerMessage[1]. You're trying to use the string '1' as the key, when the key is the numeric 1. Quote Link to comment Share on other sites More sharing options...
offsprg01 Posted February 14, 2007 Author Share Posted February 14, 2007 i tried replacing the sting 1 with numeric 1, still did not work. the error is in the included tickerSQL.php, which is the first code i posted i know the code in my last post works becuase when i replace <?php require('/includes/tickerSQL.php'); ?> with <?php $tickerLink[1] = '#'; $tickerTitle[1] = 'Title 1'; $tickerMessage[1] = 'Message 1'; ?> it works. i currently have it replace now, if you'd like to see it working http://www.harwoodmarketinggroup.com/WIP/index.php Quote Link to comment Share on other sites More sharing options...
Balmung-San Posted February 14, 2007 Share Posted February 14, 2007 Then the issue has to be scope. Try declaring $tickerLink, $tickerTitle, and $tickerMessage before the require statement. Quote Link to comment Share on other sites More sharing options...
offsprg01 Posted February 14, 2007 Author Share Posted February 14, 2007 what do you mean by scope? Quote Link to comment Share on other sites More sharing options...
Balmung-San Posted February 14, 2007 Share Posted February 14, 2007 Scope is basically where the variable can be seen. Since the first use is within a while loop in the included file, I'm thinking the variables stay local to that loop, and die once the loop is done. Quote Link to comment Share on other sites More sharing options...
offsprg01 Posted February 14, 2007 Author Share Posted February 14, 2007 well i tried declaring them but still got nothing. i may try rewritting my code to get rid of the loop. that would sure be a dirty way to do it though. Quote Link to comment Share on other sites More sharing options...
offsprg01 Posted February 14, 2007 Author Share Posted February 14, 2007 well i found one problem it was this <?php require('/includes/tickerSQL.php'); ?> should have been this <?php require('includes/tickerSQL.php'); ?> but now i get no data in my variables check out http://www.harwoodmarketinggroup.com/WIP/index.php to see what i mean. the black box that says click here at the top of the screen. Quote Link to comment Share on other sites More sharing options...
Balmung-San Posted February 14, 2007 Share Posted February 14, 2007 It's probably this line: $c = $c++; Instead, use either: $c = ++$c; or just: $c++; Quote Link to comment Share on other sites More sharing options...
Ninjakreborn Posted February 14, 2007 Share Posted February 14, 2007 I see the data. If it's not working in ie, but it's working in firefox (which is what I am checking it in), it's a browser issue. Quote Link to comment Share on other sites More sharing options...
Balmung-San Posted February 14, 2007 Share Posted February 14, 2007 Yes, I'm currently using IE (blah, company standards) and I can't see the data. In that case, it's an issue with the JavaScript. Quote Link to comment Share on other sites More sharing options...
offsprg01 Posted February 15, 2007 Author Share Posted February 15, 2007 lol i finally found the error. it was a stupid aphostrophe in the database. i just got rid of it. but for future refrence, how do you escape something coming from a db if you don't know it's there or if it is there where it will be? thanks for the help though. Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted February 15, 2007 Share Posted February 15, 2007 The addslashes function will escape single and double quotes for you. http://www.php.net/addslashes Alternatively, use htmlentities http://www.php.net/htmlentities Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted February 15, 2007 Share Posted February 15, 2007 When trying to trouble shoot a blank page, here's what I do. At the very top of the script before anything: echo "hi2u"; exit(); If I reload the page and don't see hi2u, 99% sure its a syntax error. If I do see hi2u, just cut the echo line, move down a small chunk, and re-paste it. Do this until you narrow down the one line that is causing it to blow up. You'll often find is a bad file path, undeclared function, etc. Quote Link to comment 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.