Search Results

Search found 9 results on 1 pages for 'blerh'.

Page 1/1 | 1 

  • Help with my PHP template class

    - by blerh
    I want to separate the output of HTML from my program code in my projects, so I wrote a very simple database class. <?php class Template { private $template; function load($filePath) { if(!$this->template = file_get_contents($filePath)) $this->error('Error: Failed to open <strong>' . $filePath . '</strong>'); } function replace($var, $content) { $this->template = str_replace("{$var}", $content, $this->template); } function display() { echo $this->template; } function error($errorMessage) { die('die() by template class: <strong>' . $errorMessage . '</strong>'); } } ?> The thing I need help with is the display() method. Say for example I use this code: $tplObj = new Template(); $tplObj->load('index.php'); $tplObj->replace('{TITLE}', 'Homepage'); $tplObj->display(); And the index.php file is this: <html> <head> <title>{TITLE}</title> </head> <body> <h1>{TITLE}</h1> <?php if($something) { echo '$something is true'; } else { echo '$something is false'; } ?> </body> </html> I'm just wondering if the PHP code in there would be run? Or would it just be sent to the browser as plaintext? I was using eval() in my template class but I hate that function :P Thanks.

    Read the article

  • VB.NET WebBrowser control not navigating to a local document

    - by blerh
    I have this code set up to navigate to a certain .html document depending on what's selected from a ListBox: Private Sub FileList_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FileList.SelectedIndexChanged HelpWindow.Navigate(System.AppDomain.CurrentDomain.BaseDirectory & "help\" & fileArray(FileList.SelectedIndex, 1)) End Sub The problem is, when I first select something in the ListBox, it successfully navigates to that file and displays it. But when I select something a second time it doesn't change. All of the paths it's trying to navigate to are correct. I've checked this 1000 times. Anyone have any clues why this isn't working? Thank you.

    Read the article

  • Displaying recntangles in game window with XNA

    - by blerh
    I want to divide my game grid into an array of rectangles. Each rectangle is 40x40 and there are 14 rectangles in every column, with a total of 25 columns. This covers a game area of 560x1000. This is the code I have set up to make the first column of rectangles on the game grid: Rectangle[] gameTiles = new Rectangle[15]; for (int i = 0; i <= 15; i++) { gameTiles[i] = new Rectangle(0, i * 40, 40, 40); } I'm pretty sure this works, but of course I cannot confirm it because rectangles do not render on the screen for me to physically see them. What I would like to do for debugging purposes is to render a border, or fill the rectangle with color so I can see it on the game itself, just to make sure this works. Is there a way to make this happen? Or any relatively simple way I can just make sure that this works? Thank you very much.

    Read the article

  • Providing help documentation in VB.NET?

    - by blerh
    I have written up troubleshooting documents for my project and would like them included in my program. I remember in VB6 there was a very easy way to do this with a control, where it already has the help document tree set up on the left and you just set it to point to certain files. Does something like this exist for .NET? I am aware of the HelpProvider control but as far as I know this just puts in tooltips and opens documents on a button press? Thanks for any help. :)

    Read the article

  • INET_ATON() and INET_NTOA() in PHP?

    - by blerh
    I want to store IP addresses in my database, but I also need to use them throughout my application. I read about using INET_ATON() and INET_NTOA() in my MySQL queries to get a 32-bit unsigned integer out of an IP address, which is exactly what I want as it will make searching through the database faster than using char(15). The thing is, I can't find a function that does the same sort of thing in PHP. The only thing I came across is: http://php.net/manual/en/function.ip2long.php So I tested it: $ip = $_SERVER['REMOTE_ADDR']; echo ip2long($ip); And it outputs nothing. In the example they gave it seems to work, but then again I'm not exactly sure if ip2long() does the same thing as INET_ATON(). Does someone know a PHP function that will do this? Or even a completely new solution to storing an IP address in a database? Thanks.

    Read the article

  • Finding part of a string that a user has sent via POST

    - by blerh
    My users can send links from popular file hosts like Rapidshare, Megaupload, Hotfile and FileFactory. I need to somehow find out what filehost they sent the link from and use the correct class for it appropriately. For example, if I sent a Rapidshare link in a form on my web page, I need to somehow cycle through each file host that I allow until I find the text rapidshare.com, then I know the user has posted a Rapidshare link. Perhaps a PHP example: switch($_POST['link']) { case strstr($_POST['link'], 'rapidshare.com'): // the link is a Rapidshare one break; case strstr($_POST['link'], 'megaupload.com'): // the link is a Megaupload one break; case strstr($_POST['link'], 'hotfile.com'): // the link is a Hotfile one break; case strstr($_POST['link'], 'filefactory.com'): // the link is a Filefactory one break; } However, I know for a fact this isn't correct and I'd rather not use a huge IF statement if I can help it. Does anyone have any solution to this problem? If you need me to explain more I can try, English isn't my native language so it's kinda hard. Thanks all.

    Read the article

  • Displaying rectangles in game window with XNA

    - by blerh
    I want to divide my game grid into an array of rectangles. Each rectangle is 40x40 and there are 14 rectangles in every column, with a total of 25 columns. This covers a game area of 560x1000. This is the code I have set up to make the first column of rectangles on the game grid: Rectangle[] gameTiles = new Rectangle[15]; for (int i = 0; i <= 15; i++) { gameTiles[i] = new Rectangle(0, i * 40, 40, 40); } I'm pretty sure this works, but of course I cannot confirm it because rectangles do not render on the screen for me to physically see them. What I would like to do for debugging purposes is to render a border, or fill the rectangle with color so I can see it on the game itself, just to make sure this works. Is there a way to make this happen? Or any relatively simple way I can just make sure that this works? Thank you very much.

    Read the article

  • Directory.GetFiles returning entire path, I only want the filename?

    - by blerh
    This is the code I have set up to scan a directory of files: Dim fileArray() As String fileArray = Directory.GetFiles(System.AppDomain.CurrentDomain.BaseDirectory & "help\") And it successfully gets all files in the directory, but it gets their absolute paths aswell. For example, one of the entries in fileArray() is: F:\Project\Project\bin\x86\Debug\help\book_troubleshoot.html And I want it to just be: book_troubleshoot.html Is there a way to do this without parsing through all the array entries to trim off the path? Thanks.

    Read the article

  • Database class is not correctly connecting to my database.

    - by blerh
    I'm just venturing into the world of OOP so forgive me if this is a n00bish question. This is what I have on index.php: $dbObj = new Database(); $rsObj = new RS($dbObj); This is the Database class: class Database { private $dbHost; private $dbUser; private $dbPasswd; private $dbName; private $sqlCount; function __construct() { $this->dbHost = 'localhost'; $this->dbUser = 'root'; $this->dbPasswd = ''; $this->dbName = 'whatever'; $this->sqlCount = 0; } function connect() { $this->link = mysql_connect($this->db_host, $this->db_user, $this->db_passwd); if(!$this->link) $this->error(mysql_error()); $this->selection = mysql_select_db($this->db_name, $this->link); if(!$this->selection) $this->error(mysql_error()); } } I've shortened it to just the connect() method to simplify things. This is the RS class: class RS { private $username; private $password; function __construct($dbObj) { // We need to get an account from the db $dbObj->connect(); } } As you can probably see, I need to access and use the database class in my RS class. But I get this error when I load the page: Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\xampp\htdocs\includes\database.class.php on line 22 The thing is I have NO idea where it got the idea that it needs to use ODBC as a user... I've read up on doing this stuff and from what I can gather I am doing it correctly. Could anyone lend me a hand? Thank you.

    Read the article

1