trq
Staff Alumni-
Posts
30,999 -
Joined
-
Last visited
-
Days Won
26
Everything posted by trq
-
Having a lot of trouble just getting to the simple machines installer!!!
trq replied to machinus's topic in Microsoft IIS
I'm certain the windows installer is problematic. I have always done a manual install (though I use Linux now days). There are instructions in the manual: http://www.php.net/manual/en/install.windows.iis7.php -
Get yourself a decent host, you get what you pay for it really as that simple.
-
Having a lot of trouble just getting to the simple machines installer!!!
trq replied to machinus's topic in Microsoft IIS
It looks more like a mis-configured server to me. What steps exactly did you take to install php? -
Having a lot of trouble just getting to the simple machines installer!!!
trq replied to machinus's topic in Microsoft IIS
Have you tried executing a simple phpinfo script first? -
Move your function definitions up so they occur before you call them, or better still, use anonymous functions. success: function(data) { if (data == "true") { $("#loading").show(); $('#lightbox_content').hide('slow', function() { $('#login_content').show('slow', function() { $("#loading").hide(); }); }); $("#login_content").append("<p>Login successful</p>"); } else { $("#login_content").append("<p>Sorry the username and password did not much. Please try again or <a href=\"\">register here</a></p>"); } }
-
This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=314530.0
-
Please, don't create new pages for each user. PHP is a dynamic language, this means you can use a single page for each user. Hell, you don't even need to actually create the directories.
-
Code Critique: Using $_GET. Critique bashing welcome!
trq replied to OldWest's topic in PHP Coding Help
No. You need to check that $posts_by_city_results is a resource (true) before passing it to mysqli_num_rows(). Otherwise, if your query fails, you will get an error. You are however using 'or die()' after your call to mysqli_query() which will catch this error, its not at all a nice way of doing it though. All queries should be something like..... $sql = "your query"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { // $rows contains records and is good to use } else { echo "No Results found"; } } else { trigger_error('Query failed ' . $sql); } The reason you use trigger_error() instead of a simple die is that error reporting can be adjusted via configuration. You don't want php error messages (especially ones that might hint about your database setup) to be displayed to a user in production. -
I should probably explain where $this comes from within the view script as well considering they themselves are not classes (and I'll bet that's your next question). Within your controller script you pass data into the 'View' object. This in turn would have a render() method which would be responsible for pulling in the view script (via include). This means that $this within your view scripts refers to the 'View' object. So, your BlogController might have an index() method for instance that is responsible for returning your latest blog post. It might look something like... public function indexAction() { $model = new blogModel; $blogs = $model->getLatest(1); $this->view = $blogs; $this->view->render('viewscripts/blog/index.php'); } Where $this->view refers to your actuial 'View' object (instantiated within the controllers __construct. You don't normally need to call the render() method because the controller should be able to take care of that automatically for you. It also know what view script to render based on what action method is called. This is all usually configurable somewhere.
-
Most of these examples will be highly out of context, because your implementation would depend entirely on how your framework is designed. They are basically html files with minimal php within them. Template like. <div id="blogs"> <?php foreach ($this->blogs as $blog): ?> <div class="blog"> <div class="header"><?php echo $blog->title ?></div> <div class="content><?php echo $blog->content ?></div> <div class="footer"></div> </div> <?php endforeach; ?> </div> Helpers are just that, classes built to aid within a view script. So, something like.... <div class="footer"><?php echo $this->helpers->format->author($blog->author) ?></div> The Response object is generally responsible for storing output (and headers) reading to send back to the client (respond). Something like.... <form action="action.php" method="post"> <label>Your Email: <?php echo $this->helpers->form->text('umail', array('size' => 32)) ?> </label> <label>Your Password: <?php echo $this->helpers->form->pass('upass', array('size' => 32)) ?> </label> <?php echo $this->helpers->form->submit('Login') ?> </form> Of course you would likely also have methods available to produce the opening and closing <form> tags as well. Because logging in is a 'process', not something to look at (view). These examples probably won't help much within this context. I know you said you weren't keen on using an existing framework (not sure why as its probably the best way to learn good design & OOP) but you should at least be looking at the documentation of some of these frameworks. (Zend's is awesome, though maybe a little steep - http://framework.zend.com/manual/en/manual.html). Look at there documentation and implement your own design if you like, its a good reference for this sort of thing.
-
Code Critique: Using $_GET. Critique bashing welcome!
trq replied to OldWest's topic in PHP Coding Help
You might want to re-read my original reply. Its the argument passed to mysqli_num_rows that needs checking. (Well, both actually) -
Code Critique: Using $_GET. Critique bashing welcome!
trq replied to OldWest's topic in PHP Coding Help
mysqli_num_rows will throw an error if $posts_by_city_results is not a resource. You need to check it is 'true' before using it. Also, don't you get sick of typing? Your variables are extremely explicit. Its probably good while your learning, but IMO it makes code even harder to read. -
Problems with php includes from diff file paths. Need help
trq replied to Lexicon's topic in PHP Coding Help
Considering website is 1 directory back up the tree you would need to use.... include "../functions.php"; -
This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=314405.0
-
No, you would use the command line: Make a dump: mysqldump -p dbname > dump.sql Import to another database server (empty db needs to exist first) mysql -p dbname < dump.sql
-
This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=314506.0
-
You might want to post some relevent code.
-
This topic has been moved to PHP Coding Help. http://www.phpfreaks.com/forums/index.php?topic=314448.0
-
If you have shell access you *should* be able to configure your own cron jobs. Of course, your host may also have disabled this functionality.
-
Considering php executes server side your link is of absolutely no use. Have you tried viewing a simple phpinfo script? What have you tried? A simple "doesn't work' will get you knowhere, we need information.
-
Censored at PHP Freaks--Don't post about mod_security--shame
trq replied to xtian's topic in PHPFreaks.com Website Feedback
That is a blatant lie. You posted in the wrong board, its not rocket science. Nearly as much as newcomers like posting wherever they like without thinking. You asked where to find a desktop application (html editor) in a board with a topic of "Help with HTML". I don't see ANY relation. -
IRC - Can't connect to remote server.
trq replied to alexi's topic in PHPFreaks.com Website Feedback
Ah, so your talking about the irc server on phpfreaks? There is nothing wrong with the server itself, I just tested it. Not sure whats happening with the web client however, I'll need to investigate as soon as possible. -
This topic has been moved to PHPFreaks.com Questions, Comments, & Suggestions. http://www.phpfreaks.com/forums/index.php?topic=314437.0
-
A 'view' is the part of the MVC that produces output. 'View Scripts' are basically like templates that can also contain 'View Helpers'. These are typically gathered and processed via a 'View' object, which in turn passes output to the 'Response' object. A html 'form' per say could (and often is) implemented as a 'View Helper'. You may also have a 'Form' object which is specifically designed to validate user inputted data, before passing that data to a Controller for processing by a Model. This 'Form' object would not be considered a part of the 'View'