Jump to content

gizmola

Administrators
  • Posts

    5,878
  • Joined

  • Last visited

  • Days Won

    139

Everything posted by gizmola

  1. You can consider this method. Just keep in mind that before you assign this to a user you have to check for collision. Even if the chances are minuscule, there is always the possibility that you'll have generated this number previously. <?php // seed with microseconds function make_seed() { list($usec, $sec) = explode(' ', microtime()); return (float) $sec + ((float) $usec * 100000); } mt_srand(make_seed()); for ($i=0; $i < 25; $i++) { $id = mt_rand() . '.' . mt_rand(); echo $id . "\n"; } You'll get this: Based on php's implementation of the Mersenne Twister algorithm.
  2. You aren't obligated to do work for them in advance of securing the contract. Once you get the contract, that's a good time to provide them the information, either as an FYI as part of what you're doing, or as an upsell, if there are things you can do to add security to your solution.
  3. The -1 looks better, however, I actually had $count += $start in the code. Hopefully the OP gets the idea.
  4. What is likely happening is, as was pointed out, you are trying to make 600 database connections. On your host, this is limited and you are running out of resources and memory at 20, and then you get the 500 error. cyberRobot's post should fix your problem and is the standard way to have code like this. You should also try and work in 2 parameters: start= count= This will allow you to have this script be used to email any batch of your database. This is the type of script you would want to run from a shell, but I'm guessing you don't have shell access to your host. Taking Cyber's example and expanding on it: <?php // Get params if (isset($_GET['start'])) { $start = (int)$_GET['start']; } else { $start = 0; } if (isset($_GET['count'])) { $count = (int)$_GET['count']; } else { //default to 600 rows $count = 600; } $count += $start; //CONNECT TO DATABASE $con = mysqli_connect("host","database","password"); if (!$con){die('Could not connect: ' . mysqli_error($con));} mysqli_select_db($con,"database"); //GET EMAILS $sql = "SELECT email FROM emails WHERE id BETWEEN $start AND $count AND email IS NOT NULL"; $result = mysqli_query($con,$sql); while($row = mysqli_fetch_assoc($result)) { echo $row['email']; // Send email here } //CLOSE DATABASE mysqli_close($con); Now you could call your script as:
  5. Nobody can help you without clarification of your question. What can't you do? -Edit your index.php file on the new server? -Having edited that file, you are still receiving the error? Last but not least, you need to show us the code that causes the error message to display.
  6. Yes. You can use PHP to make any type of site you want. It's a building block. It's not the only building block typically used, but it can work with many other types of building blocks. CMS's are built to publish content. For the most part that content needs to be static content. CMS's typically allow for expansion upon the basics, but they don't magically have the ability to morph into an application. You have to write those as modules if you want to start with a CMS platform.
  7. I'm afraid it's more complicated than that, probably. What is happening is that they are using javascript to manipulate their API. View source is not going to be as helpful as a javascript debugging tool like Firebug, which will let you actually trace what is happening, but I'm doubtful you'll be able to just get some static url's you could stick on a page. You might be able to get someone really versed in the Facebook api and javascript to create you a small app that would utilize the api to login to Facebook and then change context for you in a more efficient way for you, but it's doubtful you will be able to explore this idea yourself, unless you are capable of reverse engineering how this works in their app, and even then, if they don't want you to do this, it could be difficult to accomplish.
  8. I took the last code you pasted, and fixed it. $insert = mysqli_query("INSERT INTO 1141650_sigma22.JoinDNO (ID, FirstName, LastName, City, State) VALUES (NULL, '$FirstName', '$LastName', '$City', '$State')"; if ($insert) { echo '<p>adding your name in list successfully</p>'; } else { echo '<p>Sorry, I could not add your name to list</p>'; }
  9. Following up on Requinix's answer, print_r exists so you can just quick dump out an array or object. So you wouldn't print_r a single element. His answer shows you how you can reference elements in multiple nested arrays.
  10. When people don't provide code, we can only call out things that sound hinkey. Regardless, you are complicating something that is simple. You display images in a browser using the img tag. Whether you stored one image file or many in a specific row, that is not going to change the fact that each individual image you want to display on a web page has to be available in the src= param of the the img tag. With that said, as ginerjm advised, it's a lot easier to write an img helper script if you have a solid table structure with one image per row referenced. Then you tend to write something like: // getimg.php $id = (int)$_GET['id]; $sql = "SELECT * FROM images WHERE id = $id"; //query for image row if ($found) { $fp = fopen($row['filepath'], 'rb'); //Determine right header -- jpeg example here // .... $imgMimeType = 'image/jpeg'; header('Content-Type: ' . $imgMimeType); header("Content-Length: " . filesize($row['filepath'])); fpassthru($fp); exit; } else { //return data for default img. Remember this is returning image data, so you have to return a valid image. } Then of course where you want to display the images you will have markup like this in your output script: echo '<img src="getimg.php?id=' . $images_id . '">';
  11. There are basically 2 modern php5+ frameworks right now that have most of the mindshare. Symfony -> http://symfony.com Laravel -> http://laravel.com Both of these frameworks have a lot of similarities, excellent documentation, tutorials, and highly active communities that support people. My suggestion to you would be to take a look at both of them and try building a small test app with them to see how they can help you. I don't want to put the cart before the horse, but they also both have CMS components available, but before you get in over your head, I'd urge you to try and build a basic app first so you're clear on the basics like routing, db/orm/models, views/templates, session/security etc. You'll find state of the art support for search solutions any number of different ways.
  12. An interface is typically used by framework and library creators. It facilitates certain types of design patterns, for example the factory pattern or for use in dependency injection situations. What an interface guarantees is that *your* class will be sure to include some number of methods that another class can call. For example, let's say that I have a "shapeMaker" class that instantiates a graphic canvas and then adds and removes objects of different shapes to it. It might have a method like this: class ShapeMaker($canvas) { private $shapes = array(); private $canvas; ..... function addShape($shapeObj) { $this->shapes[] = $shapeObj; $shapeObj->draw($this->canvas); } } The designer of the framework will very probably include an interface for people to create new shape classes, which include the draw($shapeObj) method signature. By providing that interface, they guarantee that any object that is passed into the shapeMaker class via the addShape, can then immediately have it's draw($canvas) method called. The details of exactly how draw works are left to the class developer, but the interface helps establish the contract of methods needed by the factory class in order to manipulate any object that implements an interface. I rarely see the use of interfaces outside of a framework or library, but there is no reason you can't use them yourself if you have a solid grasp of what they are for. Usually people are utilizing inheritance rather than interfaces, but in complicated class dependency situations, it's good to keep in mind that you can write a class that can implement 2 or 3 different interfaces, and still inherit from a base class. In PHP, you only have single inheritance, so interfaces were a way to get around that limitation in some circumstances, although in php5.4 they added traits which are another way of getting around single inheritance in many cases.
  13. Ok, great, so we can dispense with the curiosity aspect of it. You just made up some wild claim of a decade of php development experience for god knows what reason. You're not an experienced php developer. That was pretty evident from the get-go and really wasn't that great of a charade. Stop kidding yourself that your question was some model of clarity right out of the back of Eric Raymond's dissertation on the subject. Most of us found the idea of spitting out a 10k row html table to be far too ridiculous a premise to be what someone would actually want. Google was not involved. I quoted the manual page for a function you used, but did not understand. If you actually read what was quoted to you, and spent a second trying to understand it, you'd understand why you got your so called "Goofy results" and possibly you'd use that monster intellect of yours to fix your code, which would probably take all of 30 seconds. Your comments in regards to a community of people who donate their time helping others try to improve their skills make you look sad and petty. If indeed most of the people who responded are far younger than you, what does that say about you?
  14. Are you seriously so lazy or clueless that you can't identify what to remove from that file to accomplish this task? If you can't, with all due respect, you have no business being given the task of taking on anything having to do with that project
  15. If you can afford a learnable account, that is a good option. You basically have access to their complete library and there are a number of books as well as online courses you can take. The books can be downloaded in a variety of formats so you can read them offline with different reader apps like Kindle or as a pdf. One book that sounds appropriate for you would be: https://learnable.com/books/php-mysql-novice-to-ninja-5th-edition I wouldn't worry about the latest/greatest book until such time as you are already at least comfortable with PHP Oop, as many of the recent changes have been in that area of the language and will unneeded by you and hard to grasp initially. You want something that teaches you all the core programming concepts first. As QOC stated above, you should at least attempt to go through the official tutorial until such time as you feel you are lost and not able to follow. With that said, most intro books also walk you through getting a localhost environment of some sort setup. The latest version of PHP of course has a built-in web server that's easy to start up, but you will very quickly want a database like mysql, and perhaps other things from there.
  16. To add to mac's answer, your user table should allow for several different types of users ('member', 'guest') and at that point all you have to focus on is the differences in things like login/logout and checkout behavior between the types, and methods to convert guests to members. You will find that you generate many basically empty guest accounts, but a cron job that looks for accounts with incomplete orders older than a certain age, which then deletes the cart and guest account is easy enough to code.
  17. The point of a CMS is not to provide functionality so you do not have to code. The point of a CMS is so that 'end users' who are not programmers can do things like add content and sections of the site using an interface that hides the details of site functionality from them, and makes it efficient to publish new material. Of course there is a learning curve to CMS applications just like there is to any complicated application. Wordpress is like a Frankenstein monster. I understand it's very popular but that doesn't make it a good CMS. It made some really wise decisions in the early days that lead to its popularity --- namely providing sexy functional UI for the end users. The fact that it has never had the best architecture for developers to expand upon isn't important to the people using wordpress in most scenarios. We'd really need to hear more from you about what you need a CMS for in the first place, especially since you have a self professed history of coding everything from scratch. Speeding up development these days tends to mean starting with a framework and making use of components in the modern PHP world where standard PSR-0 component libraries can be easily added to your project saving you person-years of time.
  18. This information comes from the php manual for mail here -> http://php.net/manual/en/function.mail.php. Did you read that? $headers = 'From: ' . $_POST['field_4'] . "\r\n" . 'Reply-To: ' . $_POST['field_4'] . "\r\n" . 'X-Mailer: PHP/' . phpversion(); These additional headers can be sent as an optional parameter to mail(). So your code would probably be: $headers = 'From: webmaster@example.com' . "\r\n" . 'Reply-To: webmaster@example.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail("mail@example.co.uk","Blah Blah - Website Contact","Contact Form Data: Title: " . $_POST['field_1'] . " First Name: " . $_POST['field_2'] . " Last Name: " . $_POST['field_3'] . " Your email address: " . $_POST['field_4'] . " Your phone number: " . $_POST['field_5'] . " Message: " . $_POST['field_6'] . " ", $headers);
  19. There is software called rsync that is very good for synchronizing data between 2 servers. I'd recommend looking at that, and using rsync to move files from your workstation up to the server.
  20. A lot of these types of identification strings come from the client, therefore they are dependent upon good behavior. The same goes for proxy servers. In the case of a proxy server, it is making the actually connection to the server, and not the client directly. If it's well behaved it will provide the HTTP_X_FORWARDED_FOR. If it chooses not to, the server has no way of knowing that the client was a proxy server. As far as "Elite Proxy Server" is concerned, I have no idea what that is, but it seems like some scammy marketing phrase that has no specific technical meaning. From what I gather you are associating the term to mean a proxy server that doesn't pass on the client IP in the HTTP_X_FORWARDED_FOR variable. If this was important to determine, you could maintain a database of proxy servers and use that information to do whatever it is that you are concerned with, but that will never a perfect answer, because that data can be whatever the "client" wants it to be. This is similar to HTTP_USER_AGENT or the use of a robots.txt. Many sites implement controls or behavior based on HTTP_USER_AGENT but clients routinely spoof that string for their own purposes (bots masquerading as a specific browser for example).
  21. Yes, but there are standards for valid emails. This seems to be lost on most people. There is no such thing as html emails -- there are text emails with attachments which can include an html portion as an option. It is up to the email client to handle the email. Just because the majority of email clients will handle an html email doesn't mean it's proper to just send html. Furthermore, it's a bad idea because security paranoid people will have configured their email to disable any html and your emails will never be seen. This is why the only proper and 100% valid emails that want to include html need to be multipart. It's more complicated, but as pointed out, it's also a problem solved for a long time and formalized in any of the many libraries you were already pointed to. Otherwise --- you really need to figure out some ways to debug it, including writing the output to a file so you can look at it by hand, or possibly turning on settings in your MTA that will give you some information.
  22. You did not show us any code that binds to the result or fetches. Where is that code?
  23. Find the line in the function that has this: if ( $display_date ) $signatures_list .= '<td class="dk-speakup-signaturelist-date">' . date_i18n( $dateformat, strtotime( $signature->date ) ) . '</td>'; At that point, if you add a new ... you'll inject it at the end of the existing row of content. $signatures_list .= '<td><img src="some/image/path?"></td>'; What is the idea here? Well this code builds up a variable ($signatures_list) that is ultimately displayed a single html table row. In php, '.' concatenates, so the code here simply keeps concatenating extra values onto the end of the string until it is fully formed. That is basic idea of the pattern of $signatures_list .= 'something new to add to the end'; What the image would be, where it's stored, and what you meant with your rollover comment are all mysteries you didn't adequately explain for anyone to offer you any more help.
  24. If you try and alias the name of the computed column back to the same name as the original column, it won't work correctly. Your computed name (and the name you use in the GROUP BY) have to be the computed name. I'm not sure if there's a way to finesse this issue, although Barand might know. With that said, it doesn't explain your result. To get only one group, there seems to be something wrong with your GROUP BY or your WHERE clause.
  25. Did you look at my answer?
×
×
  • 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.