Jump to content

simonrs

Members
  • Posts

    30
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

simonrs's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Have a look by doing print_r($gamespace); - see if you can work out for yourself how to get the sum out
  2. Think you're best served by the file_put_contents function. For more info take a look here: http://uk3.php.net/manual/en/function.file-put-contents.php If your server is running on a unix server, your script will need to have write permissions for the directory. The command you would need for this is chmod, you will need ftp or command line access to the server to use it. Google it for more information! A big part of web development is research. Good luck!
  3. Yep forms can't be embedded (they can't be within another form). http://validator.w3.org/ You can copy and paste code into the validator there. Strictly speaking, every page should be valid. Part of my testing runs this validator on every page on my website before I publish pages live - this means if something doesn't work at least it's the fault of the browser and not me!
  4. No I believe he means: SELECT SUM(`column`) FROM `tablename` I believe that's correct. Note the use of: `, and not '.
  5. You need to add a "LIMIT" clause to your original query. For instance, $result = mysql_query("SELECT * FROM berichten ORDER BY id DESC LIMIT 10, 10") Will skip over the first 10 results, so the first result you get will be the 11th, and the last the 20th. You will want to develop this further using a constant for the number of items per page and querying some kind of variable, most likely in the $_GET array, for how many items to skip over: // number of items to show on each page define('ITEMS_PER_PAGE', 10); // now we're getting the number to start fetching from. This line of code is saying, // if $_GET['start'] is set and it is numeric, then use it, otherwise default to zero $start = (isset($_GET['start']) && is_numeric($_GET['start'])) ? $_GET['start'] : 0; // now do the query: notice now that I'm actually fetching one more than the // ITEMS_PER_PAGE constant: this will allow us to know whether or not to show // another "next 10 items" link $result = mysql_query("SELECT * FROM berichten ORDER BY id DESC LIMIT $start, " . ITEMS_PER_PAGE + 1) I'm running out of time now but then you can go ahead, iterate through and print out a link which will be something like: echo '<a href="yourpage.php?start=' . $start + 10 . '">next 10 ยป</a>'; I personally prefer a "get next 10 items" link which uses ajax and similar techniques to get the next 10. *disclaimer: above isn't debugged!
  6. You really need to be clearer. PHP is an interpreted language. The interpreter is called by a web server when the web server sees the tag <?php in a file called something.php. PHP in this instance runs automatically. I guess this is more of a coding query given the forum you've posted in in which case I'm going to guess that your query is, "how can I get PHP to run at certain times without relying on people visiting my website at that time?". The answer to that is cron jobs on unix based servers, and windows scheduling on windows based servers. I'd suggest googling these terms and doing some reading, although you will need server admin privileges to be able to set either up.
  7. There is no way really that you can read the contents of a directory on another server. That would essentially be hacking. You would need some kind of compliance from the other server, like a script on there that you could remotely call that would output the filenames in a directory.
  8. Sounds like you need something like Javascript for this. I would have a table or a set of div's for each day, then I would observe each cell/div in javascript for a click, and fire a function when it's clicked to update the form to hold that date. Look into JS frameworks like jQuery (most popular) and prototype (imo the best) for more info. This is the prototype page that would help you: http://api.prototypejs.org/dom/event.html#observe-class_method
  9. Yes there is, but it depends greatly on how the site processes logins. You may need to do two seperate requests, one to login, and one to fetch the file. Examples of how the login might be processed could be through a .htaccess or by posting get or post variables along with the request. In the past I've used something like: $ctx = stream_context_create($params); try { $fp = @fopen($url, 'rb', false, $ctx); } catch(Exception $e) { return false; } $response = @stream_get_contents($fp); return $response; Where the $params variable has get, post or a header with a username and password for .htaccess in. Difficult to help more without knowing exactly how the site processes logins.
  10. I've tried sending mail from xampp before and had zero luck - it's a nightmare. Basically in order to actually send email you need a mail server. Mercury allegedly does this but I couldn't get it to work. I also tried squirrel mail but that didn't work either. Suffice to say, if you're eventually running the scripts on a unix server, just trust that mail() will work unless the server admin is highly retarded. What I usually do is check if the script is running on a test or production server by use of a DEBUG constant, then either print/save the emails to the screen or a file in I'm on the test server, or call mail() if it's running on the live production server.
  11. Hi guys, I'm using tinyMCE to power a blogging site I'm working on. The area of the site is sports so I'd very much like to allow users to post youtube videos and the like into their blog posts. This as I'm sure you know will involve allowing them to post content with the object and param tags. I know object tags can also be used to embed, for instance, java applets. Are there any security concerns I should be aware of in allowing users to do this? For instance, could they put a java applet in which will steal sessions of other users? I'm thinking it's dangerous obviously to allow users to post script tags for this reason and wondering if any of these problems apply to object tags. Thanks in advance for any help anyone can offer.
  12. Hi all, Subject says it all really... I had a script that was posting XML files to a URL, it was working absolutely fine. Then my client put apache basic auth (you know, like a .htaccess file, with the popup that asks for username and password) on the page that receives the XMLs. Now I can achieve the authorisation with a header line I found on PHP.net's documentation, but now the file doesn't get through - the stream is empty when it is sent. Has anyone managed to do this or can anyone see a flaw in my code? $boundary = "---------------------".substr(md5(rand(0,32000)), 0, 10); $data = "--$boundary\n"; $fileContents = file_get_contents($file); $parts = split('/', $file); $filename = end($parts); $data .= "Content-Disposition: form-data; name=\"file\"; filename=\"$filename\"\n" . "Content-Type: $contentType\n" . "Content-Transfer-Encoding: binary\n\n" . $fileContents . "\n" . "--$boundary--\n"; $header = 'Content-Type: multipart/form-data; boundary=' . $boundary; if(isset($username)) { $auth = base64_encode("$username:$password"); $header .= "\nAuthorization: Basic $auth"; } $params = array('http' => array( 'method' => $method, 'header' => $header, 'content' => $data)); $ctx = stream_context_create($params); $fp = fopen($url, 'rb', false, $ctx); if(!$fp) trigger_error('Invalid URL specified for httprequest', E_USER_ERROR); $response = @stream_get_contents($fp); return $response; Many thanks
  13. Hi all, Have an issue that Google hasn't provided an answer for. I want a PHP script, run by cron, to check for email in a POP3 mailbox, reading each received email's subject and body so I can then act on the contents. Does anyone have any ideas at all as to how this can be done? Thanks Simon
  14. But if I wanted to search over two fields, how would that work? Let me give a simple query (may not be syntactically perfect but you'll get the idea) that will work, for searching on the title of a blog: SELECT `content`.`id`, `content`.`value` FROM `content`, `content_fields` WHERE `content`.`class` = 'blog' AND `content`.`id` = `content_fields`.`content_id` AND `content_fields`.`field` = 'title' AND `content_fields`.`value` LIKE '%search text%' That'll work fine, returning to php a data structure of all matching content id's and titles. What if I wanted to extend that query, though, so as well as the titles, it also returned the body and author of each post? They don't have a different column name, so they can't be specified in the list of columns to select. And what if I wanted to extend it further to search over more than just the title, say it had to match a certain title string, and be by a certain author? Unfortunately I want (or at least, want to be able to have) the ability to do both those things, so I think I'm looking at a schema change. Any ideas? Or am I going to be forced to add a table for each content type, which I'd prefer not to do as I'd have to change the database manually or by code (messy) everytime I add a new content type or change the schema of one.
  15. Ok... could you suggest a better schema that doesn't involve dynamic adding of tables or columns?
×
×
  • 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.