Navarr
Members-
Posts
19 -
Joined
-
Last visited
Never
Everything posted by Navarr
-
With a billion more Google Queries, and finally finding something that works. I am so very pleased that this is no longer an issue (no thanks to you people ) This is how to get it to work, if you ever exprience a similar problem:
-
So, I'm pulling news from a MySQL database. I have it setup so that if the language is different, the news changes (JP or en-US). The problem is that the UTF-8 Japanese characters in the MySQL database are not pulling through PHP correctly, and all PHP is outputting is question marks. The page is setup to display in UTF-8 and is working as such (because the other japanese characters in the language files are working properly) but the ones pulled from MySQL do not. How can I fix this within PHP? I know its possible, because phpMyAdmin shows the Japanese characters. Can someone please please please please Help? The Code for the pages effected are below. index.php <?php require('inc.php'); $tpl->assign('page','news'); $browser = (array)get_browser(); $tpl->assign('browser',$browser['browser']); $forum = 1; if ($language == 'en-US') { $forum = 1; } if ($language == 'JP') { $forum = 2; } $news = array(); $q = mysql_query("SELECT * FROM `xt_bbs_posts` WHERE `parent` IS NULL AND `forum`=".$forum." ORDER BY `time` DESC LIMIT 0,10") or die(mysql_error()); while($r = mysql_fetch_array($q)) { $i = count($news); $news[$i]['ico'] = ''; $news[$i]['icoalt'] = ''; $news[$i]['title'] = $r['title']; $news[$i]['time'] = lang_time($language,$r['time']); $news[$i]['date'] = lang_date($language,$r['time']); $news[$i]['post'] = $r['post']; $news[$i]['poster'] = $r['uid']; $news[$i]['commamt'] = 0; } $tpl->assign('news',$news); $tpl->display('index.tpl'); ?> index.tpl <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg-flat.dtd"> <html xmlns = "http://www.w3.org/1999/xhtml" xml:lang="en-US" xmlns:svg = "http://www.w3.org/2000/svg" xmlns:xlink = "http://www.w3.org/1999/xlink"> <head> <title>{$lang.title}{$title}</title> <link rel="stylesheet" type="text/css" href="/style.css" /> </head> <body>{strip} <div id="logodiv"><h1 style="visibility:hidden;">POKéQUEST - Pokémon Online Game - Pokemon Online Game - Pokemon MMO - Pokémon MMO - Pokemon MMORPG - Pokémon MMORPG</h1></div> <div id="navidiv"> {include file="navi.tpl"} </div> <div id="maindiv"> {if $browser == "IE"} <div id="iewarning">THIS PAGE DOES NOT WORK PROPERLY IN IE, PLEASE GET <a href="http://opera.com/">OPERA</a> OR <a href="http://getfirefox.com">FIREFOX</a></div> {/if} {include file="$page.tpl"} </div> {/strip}</body> </html> news.tpl {strip}{section name=i loop=$news} <table class="news_table"> <tr> <th class="news_table_topic"><img src="{$news[i].ico}" alt="{$news[i].icoalt}" title="{$news[i].icoalt}" /> {$news[i].title}</th> <td class="news_table_time">{$news[i].date}<br />{$news[i].time}</td> </tr> <tr> <td class="news_table_post" colspan="2">{$news[i].post}</td> </tr> <tr> <td class="news_table_poster"><a href="{$news[i].posterurl}">{$news[i].poster}</a></td> <td class="news_table_comment"><a href="{$news[i].commurl}">{$news[i].commamt} {if $news[i].commamt == 0}Comments{/if}{if $news[i].commamt > 1}Comments{/if}{if $news[i].commamt == 1}Comment{/if}</a></td> </tr> </table> <br /> {/section}{/strip}
-
[SOLVED] Sockets binding and accessing problem
Navarr replied to AbydosGater's topic in PHP Coding Help
What type of router do you use? -
MySQL, PHP, Smarty, Apache and East Asian Characters
Navarr replied to Navarr's topic in PHP Coding Help
The problem seems to be when my PHP script grabs the information from MySQL. I can't figure out how phpMyAdmin manages to grab it properly, but it does. If anyone could help make some pointers to what the problem is, I would greatly appreciate it.. Nobody has yet, and I'd really like some help here. Its not that the page isn't encoded properlly, its sending header('Content-Type: text/html;charset=utf-8'); So the error is somewhere in the PHP. If anybody could help, that would be wonderful wonderful. -
ERROR: Cannot redeclare downloadsize() (previously declared in...
Navarr replied to suttercain's topic in PHP Coding Help
Okay, Your code is really messed up, and I'm not entirely sure how to fix it as is. But I can tell you your problem. Your function is being declared inside of a while loop. That means, that each time the while loop runs, it redeclares the function. Thats a bad thing. A function can only be declared once. You need to move your function outside of the while loop, and use it as an external function (just like you would normal php commands). -
[SOLVED] Sockets binding and accessing problem
Navarr replied to AbydosGater's topic in PHP Coding Help
If there is a router on your end, did you port forward 1234? And, if you have a firewall running, does it allow PHP through this port? -
You mean you want to know what the product id is when someone selects to buy that product using a "Buy" button? If so, then using individual forms for each product, you can create a hidden input <input type="hidden" name="productid" value="<?php echo $record['PD_ID']; ?>" /> If not, then please explain further.
-
[SOLVED] Sockets binding and accessing problem
Navarr replied to AbydosGater's topic in PHP Coding Help
Try binding to 0.0.0.0 192.168.1.136 is a LOCAL Ip Address. Computer's that are accessing your server via that IP, will be able to get in. Others, will not. Why its not binding to 86.42.77.153 I'm not sure, but try for 0.0.0.0. Also, the problem could be that something else is running on that port for the outside IP, and that could be your binding problem. -
To display the newer messages at the top; just echo the older messages first. It depends on how your script was written. If its in MySQL and has timestamps, its easy. SELECT * FROM `table` ORDER BY `timestamp` DESC
-
This is more of a JavaScript problem then a PHP problem. Google around for scripts for shoutboxes that make them scroll down. I don't think this can truly be done with PHP, because its something that needs to happen client side instead of server side.
-
Fatal error: Maximum execution time of 30 seconds exceeded
Navarr replied to jlryan87's topic in PHP Coding Help
http://www.php.net/manual/en/function.set-time-limit.php <?php set_time_limit(0); ?> -
[SOLVED] Radio Buttons--checking if clicked
Navarr replied to ali_2kool2002's topic in PHP Coding Help
If this was a problem, one could just set a selected value to one of the radio buttons checked="checked" i do believe. -
[SOLVED] Radio Buttons--checking if clicked
Navarr replied to ali_2kool2002's topic in PHP Coding Help
<input type="radio" name="a" value="1" /> <input type="radio" name="b" value="1" /> <?php if ($_POST['a'] && $_POST['b']) { /* WONDERFUL! */ } else { die("Both Radio Buttons Not Selected"); } ?> Should work properly... -
MySQL, PHP, Smarty, Apache and East Asian Characters
Navarr replied to Navarr's topic in PHP Coding Help
Could someone please help? -
MySQL, PHP, Smarty, Apache and East Asian Characters
Navarr replied to Navarr's topic in PHP Coding Help
Sorry to double post, but there is no edit feature that I could find. This is the code: index.php <?php require('inc.php'); $tpl->assign('page','news'); $browser = (array)get_browser(); $tpl->assign('browser',$browser['browser']); $forum = 1; if ($language == 'en-US') { $forum = 1; } if ($language == 'JP') { $forum = 2; } $news = array(); $q = mysql_query("SELECT * FROM `xt_bbs_posts` WHERE `parent` IS NULL AND `forum`=".$forum." ORDER BY `time` DESC LIMIT 0,10") or die(mysql_error()); while($r = mysql_fetch_array($q)) { $i = count($news); $news[$i]['ico'] = ''; $news[$i]['icoalt'] = ''; $news[$i]['title'] = $r['title']; $news[$i]['time'] = lang_time($language,$r['time']); $news[$i]['date'] = lang_date($language,$r['time']); $news[$i]['post'] = $r['post']; $news[$i]['poster'] = $r['uid']; $news[$i]['commamt'] = 0; } $tpl->assign('news',$news); $tpl->display('index.tpl'); ?> index.tpl <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg-flat.dtd"> <html xmlns = "http://www.w3.org/1999/xhtml" xml:lang="en-US" xmlns:svg = "http://www.w3.org/2000/svg" xmlns:xlink = "http://www.w3.org/1999/xlink"> <head> <title>{$lang.title}{$title}</title> <link rel="stylesheet" type="text/css" href="/style.css" /> </head> <body>{strip} <div id="logodiv"><h1 style="visibility:hidden;">POKéQUEST - Pokémon Online Game - Pokemon Online Game - Pokemon MMO - Pokémon MMO - Pokemon MMORPG - Pokémon MMORPG</h1></div> <div id="navidiv"> {include file="navi.tpl"} </div> <div id="maindiv"> {if $browser == "IE"} <div id="iewarning">THIS PAGE DOES NOT WORK PROPERLY IN IE, PLEASE GET <a href="http://opera.com/">OPERA</a> OR <a href="http://getfirefox.com">FIREFOX</a></div> {/if} {include file="$page.tpl"} </div> {/strip}</body> </html> news.tpl {strip}{section name=i loop=$news} <table class="news_table"> <tr> <th class="news_table_topic"><img src="{$news[i].ico}" alt="{$news[i].icoalt}" title="{$news[i].icoalt}" /> {$news[i].title}</th> <td class="news_table_time">{$news[i].date}<br />{$news[i].time}</td> </tr> <tr> <td class="news_table_post" colspan="2">{$news[i].post}</td> </tr> <tr> <td class="news_table_poster"><a href="{$news[i].posterurl}">{$news[i].poster}</a></td> <td class="news_table_comment"><a href="{$news[i].commurl}">{$news[i].commamt} {if $news[i].commamt == 0}Comments{/if}{if $news[i].commamt > 1}Comments{/if}{if $news[i].commamt == 1}Comment{/if}</a></td> </tr> </table> <br /> {/section}{/strip} -
<?php function random_tenthou_gen() { $numlist = array(); for($i = 0;$i < 10,001;$i++) { $numlist[] = rand(1,10000); } return $numlist; } ?> Should do what you want.
-
<?php function size_hum_read($size) { $i = 0; $iec = array("B","KB","MB","GB","TB","PB","EB","ZB","YB"); while (($size/1024)>1) { $size = $size/1024; $i++; } return round($size,2).$iec[$i]; } ?> Should do what you want. It takes prozente's idea, and incorporates it properly into the script.
-
Calling functions with variables in the name. Can it be done?
Navarr replied to alecks's topic in PHP Coding Help
$name = "test"; if (function_exists($name."_function") { eval($name."_function()"); } That should do what you want.. I think ._.;; -
Well, this has to be the worst problem I've ever had with MySQL, PHP, Smarty, and Apache. MySQL isn't having the problem. Using phpMyAdmin, I can put Japanese into the database, and phpMyAdmin will echo it back out as Japanese. But, when my website tries to set it to a variable after grabbing it from MySQL, and then displays it with Smarty, all I get are question marks! @.@ A good example of whats happening is at http://tempdev.pkqst.com/changelang.php?lang=JP (Any browser thats not IE should work, the script changes a cookie to make the language japanese before redirecting you to the homepage). As is visible there, Language Variables set in a PHP Script and are called as a variable by smarty show up fine, but when its grabbed from MySQL, it and stored to a Smarty variable and attempts display, it doesn't work. Can anyone help with this?