Jump to content

gizmola

Administrators
  • Posts

    5,945
  • Joined

  • Last visited

  • Days Won

    145

Everything posted by gizmola

  1. PHP is a serverside language. It could be used to initialize a clock, but anything interactive by necessity needs to run on the client. You have the options of coding in javascript, flash or java. You want to look into time(), the Datetime object and the use of the timezone object to convert between times.
  2. Possibly the tip of the iceberg in terms of your problems, but this: <?php $f['images']; Has to be either: <?= $f['images'] ?> or <?php echo $f['images']; ?>
  3. As Dannon pointed out, you can not concatenate a string onto a language construct (in this case your if statement). However, since your goal is output html in this section of code, I'd recommend that you utilize PHP's ability to intermix html and php code. <?php // prior code here // Now end php block ?> <input type="radio" name="BGimageID" value="<?= $row2['BGimageID'] ?>" <?= $row2['pages.BGimageID'] == $row2['bgimages.BGimageID'] ? ' checked' : ''; ?> /> <img src="../images/<?= $row2['BGimage'] ?>" width="150" /> <?php //More php code if needed
  4. I'm not sure I understand why they felt the needed to add traits, other than to appease people who really can't live without multiple inheritance. The syntax does seem a bit wonky. Still, I agree it looks like it can make things simpler and reduce the need for boilerplate code when using interdependent class libraries.
  5. gizmola

    Symfony

    Good start with Github. If you don't mind your source code being public you already have access to the most successful vcs in a saas environment. Of course you can also pay them to allow you to have private repos. However, even before you get this all hooked up, just install git on your server, git init your directory, and you will have made a great start and begun to address 448191's original point. This is because git is fundamentally different from older spoke-hub systems like subversion. Git was designed to be decentralized, so you in essence have a full repository on your local system. Of course people want to collaborate with others that requires github or some other server, but aside from pushing code to another server, there is nothing you don't already have available in your local git. You can make branches, commit code, and merge branches together -- all on your existing server. And of course you get the immmediate benefit of being able to get back prior commits, diff between them, and all the goodness you expect from a vcs. As soon as you get that going, and configure your server and github with the appropriate keys, you can push your code up to github, but it's not something you have to have going before you can start to benefit from git.
  6. gizmola

    Symfony

    Symfony2 has a lot of thinking that went into how professional developers typically work. It represents best practices. Yes, almost all professional developers use one of 3 methods these days: - Working locally in a MAMP or WAMP - Working locally in a VM (Vagrant, Virtualbox etc) - Working remotely on a server that has shell access So, first of all, yes symfony2 requires command line access, but this is primarily in order to give you essential productivity and testing tools you run from the command line. They also create these things you might have heard of called "unit tests" which help insure that you have well tested framework, and encourage their users to do the same. Secondly, every modern library and framework in the php world is moving to support PSR-0 and the composer tool. Composer requires a shell. I know about the issue you encountered, which is that symfony starts with intrinsic "environment" configuration. There are 2 main environments they support -- 'dev' and 'prod'. These are enforced through the "Front controllers" that are the bootstrap for the framework. The actual scripts are in the /web directory and are named app.php (prod) and app_dev.php (dev). The problem you had is that in app_dev.php, there is a small rule that you need to comment out: // This check prevents access to debug front controllers that are deployed by accident to production servers. // Feel free to remove this, extend it, or make something more sophisticated. /* if (isset($_SERVER['HTTP_CLIENT_IP']) || isset($_SERVER['HTTP_X_FORWARDED_FOR']) || !in_array(@$_SERVER['REMOTE_ADDR'], array( '127.0.0.1', '::1', )) ) { header('HTTP/1.0 403 Forbidden'); exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.'); } */ Do that and you can call the app_dev.php controller on your remote server and develop away.
  7. I'm pointing out that the names of the form inputs do not match what you are using in the SQL script. If you look at those blocks i quuoted *carefully* you should notice the discrepencies. For example, you look for $_POST['schedule'] in the !magicquotesgpc block and $_POST['eventdate'] in the magicquotesgpc section. Neither is correct because your form inputs have the names of 'venu' and 'yourfield'! You also have them swapped, in the form.
  8. Set the mime type correctly using header() and return the data. Here's a fairly typical example ... you'd have to fill in the details regarding how/where the original file is generated: <?php $path_to_zip = '/some/path/somefile.zip'; header("Content-Type: application/zip"); header("Content-Transfer-Encoding: Binary"); header("Content-Length:".filesize($path_to_zip)); header("Content-Disposition: attachment; filename=yourfile.zip"); readfile($path_to_zip); exit; As you can see most of this code is focused on the mechanics of the HTTP protocol.
  9. This depends on what database client library you are using (mysql, mysqli, pdo)? If you're using the old mysql_ functions then you should have been using mysql_real_escape_string() to escape all of your string input.
  10. Your form inputs do not match what you are looking for when you process the form: <td width="100">Venu Name</td> <td><input name="yourfield" type="text" id="yourfield"></td> </tr> <tr> <td width="100">Date</td> <td><input name="venu" type="text" id="venu"></td> </tr> And you look for: if(! get_magic_quotes_gpc() ) { $yourfield = addslashes ($_POST['venu']); $eventdate = addslashes ($_POST['schedule']); } else { $yourfield = $_POST['venu']; $eventdate = $_POST['eventdate']; } You're not even consistent between the form and the block that checks for get_magic_quotes_gpc (and magic_quotes_gpc has been removed entirely from PHP so this always returns false now!) I'm guessing you used a timestamp? Because you are not even getting a user submitted date with your current form input names and the variables you are looking for.
  11. Use the DOM: http://www.php.net/manual/en/book.dom.php
  12. I'm not sure this is a good idea, however, what you want to do can be done with variable variables. The question that has to be asked is... how will you know that a variable '$chair' even exists? Instead, why wouldn't you want to simply store an array key in an array. With the array you can easily foreach through it. variable variables while (....) { $name = $row[0]; $$name = 'n'; // If $name = 'chair', you now have a variable $chair available. } echo $chair; Why not this however? $mystuff = array(); while (....) { $mystuff[$row[0]] = 'n'; } foreach ($mystuff as $key => $value) { echo "$key: $value<br>\n"; } Considering your statement that you want to set all the values to 'n', it's hard to understand what you're going for here.
  13. Yes, just group by country, area. SELECT * FROM calendar GROUP BY country, area ORDER BY country, area You'll get one result set, with one row per country/area combination.
  14. Haha. Well I didn't think I would ever consider phpBB again, but I think this bodes well for the project's future. People are going to use phpBB no matter what any of us think about its history or architecture, so at least this is an acknowledgement that they needed to go back to the drawing board.
  15. Yes what you say makes sense, but putting a bunch of queries in one file is not the way to go about this. What you instinctively have been seeking is what the MVC pattern provides... especially the "M" or Model portion of that design pattern. What you want to have is a set of Model classes for handling data. I'd recommend one class per Table to start with. The other thing you are looking for is a database class to consolidate your database connection handling and provide yourself an API that reduces the repetition of the database handling. I'd suggest you start with the database class, and then use it in the models. Then in your seperate functional scripts all the sql queries will be consolidated into the model classes.
  16. Very true. With the popularization of composer, PHP is really entering a period where quality component libraries that can be shared across projects is finally a reality, and not a minute too late for the continued viability of the language. While Drupal 8 is indeed a ground - up rebuild based upon a number of the symfony2 components, there's also been a lot of cross pollination, as a number of the Drupal core developers have become very active in the symfony project. Only time will tell whether this is for the good of both projects or not, but the Drupal people sure bring a lot of passion for their vision to the table, which is one of the reasons that they were forward thinking enough to embrace the idea of using components in a very proactive manner. PHPBB is also taking the same path, and doing a rebuild on top of the symfony core components from what I've heard.
  17. Include/require functions basically act as if you had inserted their contents at the point you include them. With that said, having a separate include file does not imply "storage". PHP has "page" scope, which is to say, that one php script can run at a time. When you include files, you're simply adding to the source of the running script. I'm not clear on what you're getting at with this question, but if it pertains to persistence of data across requests/pages, then you need to utilize dbs, files, caches or sessions for that. Including files are really an organizational mechanism in support of DRY/libraries/configuration.
  18. Um yeah, we need to see some code, but I'll hazard a guess you're trying to pass this name as a url parameter, and because the '&' is a separator for url's you get apparent truncation. When you utilize a string in a url, you need to urlencode() it.
  19. Although sessions often are used to support authentication, they are not the same thing. A session is simply a set of variables tied to a browser instance through a cookie. When you session_start() the server creates a session file on the server, generates a session id and issues a setcookie call with the session id it created. On subsequent calls, it will use that cookie to lookup the session id on the server, and if it exists, it will set the contents of $_SESSION array. In other words, it just loads any session variables you might set and makes them available to your script. Of course you can add whatever you want to to the array, so people typically will store user_id as a session variable to indicate a successful login, and can then check that variable to indicate login: if (isset($_SESSION['user_id']) && $_SESSION['user_id'] > 0) { // user logged in } else { // redirect to login page } It's important not to confuse the session system with authentication. Every visitor will get a session once you issue session_start, regardless of whether the user is authenticated or not. Sessions facilitate authentication, but they are not equivalent to it.
  20. You can also learn a lot by examining an existing system to see how the creators solved the problem. You stated you were interested in CMS systems. Take a look at the source code for Drupal and Joomla to see how they were designed and coded.
  21. Ajax is simply a method for javascript to send normal HTTP requests to a web server. The server gets its parameters the same way it would if it was a normal GET or POST method. Using jquery you would call: http://api.jquery.com/jQuery.get/ The url parameter is the normal href target: 'http://yoursite.com/categories.php?filterCat=2&page=3'. You get those params in the serverside script as usual ... using $_GET.
  22. You are using mysql_fetch_assoc. $codeArray = mysql_fetch_assoc($res); This returns you an array where the elements are the column names. In your case, it would be 'value'. Try: $code = $codeArray['value'];
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.