Jump to content


  • Content count

  • Joined

  • Last visited

  • Days Won


gizmola last won the day on June 21

gizmola had the most liked content!

Community Reputation

142 Excellent

About gizmola

  • Rank
    Prolific Member

Contact Methods

  • AIM
  • Website URL

Profile Information

  • Gender
  • Location
    Los Angeles, CA USA

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. gizmola

    need help $url from $value

    I would use Barand's suggestion. With that said, your code has a syntax error and that is why it didn't work as you expected: echo '<p>' . '<a href=' . $url;'></a>' . '</p>'; You have an extraneous ';' in there. To fix it would just require: echo '<p>' . '<a href=' . $url . '></a>' . '</p>'; You are doing needless concatenation of string constants which is one reason I would prefer Barand's take. However, my opinion is that html attributes should be enclosed within double quotes (even though single quotes are acceptable), so a more complete fix would be: echo '<p><a href="' . $url . '"></a></p>';
  2. gizmola

    php code problem from command line?

    Yes exactly. APC cache has no benefit for CLI because the cache is tied to each php process. For CLI scripts the php process gets created and destroyed on each excecution. If you want an in memory cache you need to use one of the old standby methods: memcached or Redis. Those also have the advantage of being independent of the application server, so they are inherently capable of working in a cluster. The other option is to use the shared memory functions
  3. I'm with Kicken. Laravel has a lot of heat, but I'm partial to Symfony. Also in regards to NotionCommotion's comment, the focus of Symfony's recent release was adding in options to reduce the initial footprint of the framework and make it more ala-cart.
  4. Here's some examples that might help illustrate the issue with encoding a url with parameters that could include a url or in fact any string using special characters like the '&' <?php $url = 'http://www.phpfreaks.com?foo=Hi there&bar=7323'; $title = 'Fred & Wilma Flinstone!'; $link = 'http://www.example.com?url=' . $url . '&title=' . $title; echo "Link without encoding: $link" . PHP_EOL; $link = htmlentities($link); echo "Link run through htmlentities: $link" . PHP_EOL; $link = 'http://www.example.com?url=' . urlencode($url) . '&title=' . urlencode($title); echo "Link with variables urlencoded: $link" . PHP_EOL; echo "Url decoded link: " . urldecode($link) . PHP_EOL; $link = 'http://www.example.com?url=' . urlencode(htmlentities($url)) . '&title=' . urlencode(htmlentities($title)); echo "Link with variables urlencoded: $link" . PHP_EOL; echo "Url decoded link: " . urldecode($link); Results:
  5. An if -else construct branches on the truthiness of the condition. if (condition) { // This block executes if condition evaluates as TRUE } else { // This block executes if condition evaluates as FALSE } Note that in PHP the condition must be enclosed within parens ie. (). There is really nothing more to it than that. If you have a more specific question, let us know.
  6. Just speaking generally it depends on how you intend the system to work. If I ask to follow you, and you accept the follow, does that mean we are friends? If that is how you want it to work, you can make it work even with your structure, but the queries and ORM code will be more complicated and less efficient. You'll have to query and get all the "Accepted" status relationship rows for a user OR "Accepted" status relationship rows where the user_id = friend_id. This is not going to be clean within the ORM, or with a raw SQL query. It's messy, but you can certainly make it work. The implication in the code snippet you had, was that you want to query for 'Pending' rows where the friend_id = the user_id of the user with the Pending request. If that request was found, you would need to update that relationship row to "accepted". It seems to me that you were on the right track -- you just need to add that conditional code.
  7. A couple of things: URL Parameters are intrinsic to the web. It doesn't matter what the serverside language might be. There are some rules for URL parameters which can be better understood by looking at the php manual for the urlencode function. So the issue with url parameters, aside from what urlencode solves, is that when you pass a url parameter that is itself a url with url parameters, things can get confusing. As far as "security" is concerned, I don't see the applicability to your situation, as it sounds like you are rendering the page with the banners and the associated urls. If you are writing a script that accepts INPUT via url parameters, that INPUT always has security concerns in that it could be malicious, malformed or in violation of the valid parameters. Again this is not unique to PHP, but simply the way the web works. You can never trust user input regardless of the source, and if your script is DESIGNED to receive input via url parameters then you need to take steps to conform/strip/convert the input as needed. If the source of the data is a database, or file or included source file, then any concerns regarding url parameters is unwarranted. What might be of concern is you rendering out a url to be used by others, in a way that it is valid and will be correctly resolved by a browser to the intended target location.
  8. What is your specific question? Also, to clarify, "Following" and "Friendship" are 2 different concepts: Following --------------- 1 User -> Many Followers For example: User A -> Followed by User B User B -> (Not Followed by User A) This is possible in a Following Model Friendship ----------------- User A -> Friend to B User B -> Friend to A You state that this is friendship problem, but your code implies it is a Follower model. In a friendship model, you would need a different db structure OR when a friendship is established from A -> B, then you need to also create an associated relationship from B -> A. I don't see you doing that anywhere. This is important because, in a follower model, as illustrated, I might follow someone who does not follow me back. With your table structure, that is implied. This is relevant to what I think your question concerns, which is recognizing that UserA has requested to follow UserB, but UserB already requested to Follow UserA. If that is your question, then the solution is to: Create a New follow Request from User A -> UserB and set it as "accepted". Set the follow Request from User B -> UserA = "accepted"
  9. Correct. This is what was told to you initially when this was brought up. You don't need the double quotes UNLESS you are trying to INTERPOLATE the variables together into one or more strings. I showed you how you could get to the same result (concatenating multiple string variables and/or string constants together using '.' OR Using INTERPOLATION (Variables and string constant snippets inside of " ". Also -- because code compiles (doesn't create an error) does not mean that it is CORRECT. Mkdir is looking for a STRING that represents the correct path to the directory you want to create. If you feed it this input: $user = 'bob smith'; mkdir('O M G $ 779/' . '$user', 0777, TRUE); Then the final path variable is going to be 'O M G $ 779/$user' That is a string. It might even be accepted by the operating system as a legitimate path, and you may end up with a directory created: O M G $ 779/ And inside of it will be another directory: $user That might work, but it certainly isn't what you intended. I also think you should note, that you should always check the result of an operation like mkdir() because otherwise you have no idea if it worked or not. if (mkdir('O M G $ 779/' . '$user', 0777, TRUE)) { // Proceed } else { echo "Unable to create the Directory"; }
  10. gizmola

    html css mobile menu issue

    How did that address the original question?
  11. gizmola

    PHP sessions

    In the olden days of early microsoft SDK's products and GUI standards, this idea was referred to as a "wizard". You need to get from A -> B, with a series of decision points essentially configuring things along the way. The "wizard" would lead the user along the way pointing out configuration options and perhaps setting defaults for you, so that you had a next/back chain of dialogs that lead you to the same place, but in a stepwise fashion: A -> A1 -> A2 -> B. The problem with the Wizard is that as soon as someone no longer needed the hand holding, the Wizard becomes an impediment that gets in the way of the power user, so in best practice. The consideration I'd be concerned about is the person that comes to your site, goes through much of the decision tree, then stops for whatever reason, and comes back to it 5 minutes later. This happens ALL THE TIME. Beware the design that forces this stepwise chain of dialogs for users that have already gone through some part of it. While I understand the point being made by some of my esteemed fellow phpfreaks, sessions do have the advantage that they will persist for a configurable period of time, even if the user was to close out their browser entirely (assuming the default use of a session cookie is in place). A person who has already given you their email and perhaps picked the category and seen the other screen whatever that might be, certainly should not be forced down the same path again upon return, unless you would rather not have that user as a customer.
  12. gizmola

    New member Introduction

    I guess it depends on your activity, as to whether or not you fit in for any period of time.
  13. I linked you to the manual page, and you clearly didn't read it. I don't know how you went from my comment to the assumption that the solution was to turn all your variables into string constants. Here's what the line should be: if (file_exists($directory_path . $user . '/' . $file_name)) I leave it to you to look at these two lines, and determine why one actually parses and the other doesn't. // Run this somewhere and play with it until you understand $name = 'Dorothy'; echo 'Hello Toto, my name is $name' . PHP_EOL; echo "Hello Toto, my name is $name" . PHP_EOL; $basePath = "/var/www/mysite/"; $picDirName = "pictures"; $fullPath1 = $basePath . $name . '/' . $picDirName; echo $fullPath1 . PHP_EOL; $fullPath2 = "$basePath$name/$picDirName"; echo $fullPath2 . PHP_EOL; $wrongPath = '$basePath' . '$name' . '/' . '$picDirName'; echo $wrongPath . PHP_EOL;
  14. You really need to read the page on PHP Strings This is the closest to being correct, yet includes a glaring problem and would actually produce a syntax error.
  15. Did you determine the problem? If so, what was it? If you are still encountering an error, let us know the error message you received when running ffmpeg from the command line.

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.