Jump to content

gizmola

Administrators
  • Posts

    5,945
  • Joined

  • Last visited

  • Days Won

    145

Everything posted by gizmola

  1. &AOE- is not the code for anything. Are you trying to use an html entity? Those have the pattern &...; For a specific UTF-8 character you would use ✏ If you have a utf8 string, then you should just be able to echo it out.
  2. $stmt->bind_param is fairly simple: your first param is a string that contains a letter for the type of each parameter you are binding. In your case you've got 3 placeholders (?) in your query. If we assume they are all char types (char,varchar,text) then you would use the 's' for strings. $stmt->bind_param('sss', ... Then you simply follow up with the variables that have the data you want to bind to the query: $stmt->bind_param('sss', $var1, $var2, $var3);
  3. I don't have anything more to add -- your question is extremely general. My suggestion is that you should read the guzzle php documentation, install it, and write a script that queries one of the sites you mentioned, and try to display the results in a table.
  4. You need to do that in your procedural code. When you get the result set, you can use a variable and as you fetch each row you increment that counter variable. It is not something you do in SQL or in trying to manipulate your query results.
  5. This is basic html. You can not just embed a picture in an html document. Images have to be sourced independently using the: <img src="path_to_image"> This is one of several reasons that people don't typically store image data in a database table. However, given the current design it appears you have, what you will have to do instead is write a seperate script that will lookup the row that contains the image data so that in your img tag you can provide the path in a manner similar to this: <img src="getimage.php?id=<?php echo $row['id'] ?>"> the get image.php script would lookup the row by id, set the mime type to the one appropriate for the type of image that was stored (jpg, gif, png) and return the image data.
  6. Yes, if you need to run multiple statements in a script you have to close each one in turn, before you can run the next one. To quote the manual:
  7. I'm guessing that the question is: how do you reset the auto_increment id for a table back to 1? This will only work if all the rows are removed from the table, either with DELETE or TRUNCATE table. ALTER TABLE yourtable AUTO_INCREMENT = 1; To accomplish this with renumbering, you can select into a temp table and then reinsert, omitting the old id column.CREATE TABLE t_yourtable AS SELECT * FROM yourtable; TRUNCATE TABLE yourtable; ALTER TABLE yourtable AUTO_INCREMENT = 1; INSERT INTO yourtable (col2, col3... etc) SELECT col2, col3... etc FROM t_yourtable; *Note* I think that truncate table may set the auto_increment back to 1, but test it with our version just to be sure.
  8. Sounds like you want to write a spider -- not an easy task. Typically people have used the curl library extension, however, there are now a number of really nice HTTP client libraries like Guzzle you can consider. http://guzzlephp.org/ is worth looking at.
  9. It sounds like a databse design/query issue. Without some information about your design, and the queries you are doing, there is no way to help you but I can offer a few ideas to get you started: -You didn't state what database you are using, but I'm going to assume it's mysql. Step 1 should be to run EXPLAIN EXTENDED on your queries from the mysql command line tool (or phpMyAdmin). This will help you understand what your query is actually doing (and it's most likely tablescanning and looking at your whole table for every single query) -If your tables are using myisam storage engine move to innodb. Innodb has a true data cache component, so if the server has sufficient memory, it can keep much if not all the dataset in memory all the time. -If you have LIKE queries which include wildcard-something-wildcard, those are never going to use an index. For example, I often see people doing this: SELECT * FROM TABLE WHERE somecolumn LIKE "%criteria%"; Those types of queries will NEVER be performant, because a btree index can not be used. Full text based searches really need to be done with a fulltext search system. Mysql does have a fulltext search index type, that might get you what you need, but most large sites use solr or sphinx, or if on aws, elastic search. Most sites use some sort of caching system to store the results of queries in memory. Memcache and Redis are two of the most popular solutions, and there is also the option of using APC for a single server that has plenty of available RAM. In all cases, you really need to understand the resources available to you, as far as server os, RAM, db configuration etc.
  10. Mysql wants the format of the date to be 'yyyy-mm-dd'
  11. When you wrote "auto number" did you really mean "auto increment"? Omitting the column from the values entirely is correct. You probably have an error of some sort --- check out http://www.php.net/manual/en/pdostatement.errorinfo.php in order to get specifics.
  12. That is a shell script. What that means is that they expect you will ssh into the server, and execute that script from the command line. The only issue in doing that is that the execute permission must be set on the script in order to run it. With that said, you've also looked inside the script and can see that there are a series of commands you could run from the shell, one after another. If you google the commands chmod, find and xargs, you could learn quite a bit about basic linux file system permissions in the process.
  13. https://groups.google.com/forum/?fromgroups#!forum/android-developers http://forum.xda-developers.com
  14. No it's not necessary because everything will be garbage collected at the end of the script.
  15. Create a script in your webroot that has this simple code: Point your browser to that page, and it will show you lots of information about your php setup including the location of the ini files.
  16. There are several alternatives to that function, that could be substituted, although there is nothing exactly like it. You should look at number_format or printf. These are listed as related functions on the manual page I linked. What makes money_format unique in this way is that it determines the monetary unit and symbol to use via the locale, but in this case it's 'en_US' so the symbol for money is the '$'. In short, you're going to have to replace that code with a simpler numeric formatting function, and then concatenate '$' onto the front of the result.
  17. A text file is not a database. You can't delete a random line in a text file. All you can do is add to the file, or write a new file on top of the old one. In your example you are appending lines to a file. If you want to write a file, then delete it 3 seconds later, in order to use the existence of the file as some sort of semaphore, you can have the script write the file, then sleep for 3 seconds, then delete the file. // Write file sleep(3); // Delete file. unlink('path/to/yourfile');
  18. A notice is not an error. It is a warning. Notices are typically used during development to help perfect code by pointing out non-fatal issues like the ones in this script. The notices you are receiving can be avoided using isset, but it is not unusual for scripts to do the types of comparisons that are producing the notices you show. Those comparisons will still work properly because they will evaluate to false, even though the variables in the comparison do not actually exist if rhw url parameters are not passed into the $_GET or $_REQUEST. You can turn off the display of notices by changing that setting in the php.ini, or in the script you can turn down the level or reporting using: error_reporting(E_ALL ^ E_NOTICE);
  19. Did you read the manual page for that function? http://php.net/manual/en/function.money-format.php There are caveats to its use like:
  20. With javascript you can. Here's a jsfiddle of how to accomplish this easily with jquery: http://jsfiddle.net/gizmola/TS4QE/10/ Essential code: $(".pr9").parents("#101").addClass("hilight");
  21. We really need specific questions. We can't read your mind, or guess what specifically you're stuck on. Generally speaking, the service provides a RESTful api where you POST for new entries, PUT for updates, and DELETE for removal. You would probably want to use curl, or a library like Guzzle to interact with their service.
  22. There is also a technique for variable parameters called "Currying" you can look into. However, I have to question what the actual problem you are trying to solve is. PHP is already loosely typed and you could pass an array which contained the parameters, and use foreach() to go through them.
  23. A server with sufficient memory will do a really good job of caching the file system data. Typically a linux server will use memory that is not otherwise allocated as file system buffer memory, so this may explain why you are seeing good performance. With that said, if you really want to ensure that you are getting memory speed caching, I would suggest you look at using APC, Memcache or Redis, and explicitly put in caching calls for this data. Since you should have an opcode cache installed anyways, I'd start with APC, assuming you are in a single server setup.
×
×
  • 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.