Jump to content

tendrousbeastie

Members
  • Posts

    21
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

tendrousbeastie's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi, You are running the query twice, anbd the second time is probably what's generating the error. Your line 1 seems correct - you are running the SQL query and storing the result in the $sql variable. As I'm sure you know PHP doesn't store the results as an array or as directly accessible data, rather it stores a resource identifier, which can be passed to other php function to access the data. In your line 3 you are running another mysql_query, but this time you are passing it the $sql resource identifier generated from line 1, rather than an actual query. It is this that is generating the error. On line 3 you could perhaps do something like: if (!is_resource($sql)) or maybe: if (mysql_error() != '') or maybe both, either of which would execute the conditional die command if the query had failed. Hope this helps
  2. I was hoping (foolishly, I guess) that it could be done through an htaccess setting, so I could do it one a folder by folder basis. No worries, I'll have to rig something up in PHP to acheive the same end.
  3. Bugger, it relies on ModRewrite and doesn't seem to work when used in an HTAccess file. Alas, I don't have access to the main HTTPD.conf as the site is run on a shared server and the owners are a rather reluctant to make changes.
  4. Wow, thanks for the positive reply. I'll try it out tomorrow morning and let you know how it goes.
  5. No, fraid not. If you 'include' or 'require' scripts from other servers it will only include the output from that script. I.e. if you script contained "echo 2+2;", the if you included it from a different server all you would be including is "4". If your script was designed to set a cookie, then when you included it it would set a cookie on the remote server, not your one.
  6. Hi All, I have a question to which I'm sure the answer is no, but I will ask anyway... I'll explain my question and then explain why I need it, as someone may be able to suggest an alternative... What I need is someway within Apache to redirect all request for page xxx.htm to xxx.php, where xxx could be any filename, but only when xxx.htm doesn't exist. If xxx.htm does exist then it should be served up as normal, and only in its absence should its PHP counterpart be served. The reason I need this is because I administer a newletter site, which so far has about 700 editions, each of which is in the filename format of newxxx.htm (where xxx is the edition number). There are various system built on top of this filename system, such as search engines and keywords tagging, that all expect the files for each edition to follow this naming sequence. Arbitrarily changing the new editions to .php would mean that these subsystems could no longer find them, and I am hoping to avoid having to rewrite these subsystems (as I didn't write them in the first place, and the guy who did was not a tidy or well commented coder). Thanks for any suggestions.
  7. Hi all, This may be a really obvious question, but I had a search and couldn't find an answer to it. Apologies if its answered elsewhere. I need to be able to run an SQL query on my MySQL DB that is essentially like the code below: SELECT fields FROM table WHERE date > now()-12months Hopefully my intention is obvious, - I want to return all result from the table where the column date contains a datetime of within the last months (or xx months preferably). Does anyone know the syntax or commands necessary to do this?
  8. Without any more to go on it looks like the problem is simply with the line below at the bottom of the script you've posted - there is no column/field called 'name' in the table you're trying to update... $query = "UPDATE {$db_prfix}mf_forums SET name = {$newname} WHERE name = {$row['fname']}";
  9. Hi all, Sorry if this is a very obvious question - I had a search through but couldn't find any answers, but this feels like it should be obvious. I have a script running on a site I'm working on that does a very standard file upload - i.e. there's a standard form with an <input type='file' ... element that uploads the file. I can then access it through PHP using the $_FILES superglobal, and ultimately I then stick the files content, type, size and name in a MySQL database. Which is great. What I want is to be able to limit the size of a file that user can upload. Without a limit many users are just going to exceed my php.ini settings and thus see an ugly php error message (I don't have access to the php.ini file, I'm on a hosted server for our company, and our host doesn't even seem to allow iniset() overrides). I know that can easily check the size of the uploaded file server-side with php as one of the $_FILE properties, but the trouble is that in order to do that the file must first have been uploaded to the server, which doesn't help me. There's probably a javascript way of doing it, but then whats to stop someone without JS (or with JS disabled) from uploading a big file anyway. So, any ideas how to stop someone trying to stick a 10MB file on my upload form and being greeted witha PHP error message? Any ideas welcome. Thanks, Me.
  10. Thanks for the help chaps. Gamic, I'll try your query and see if I can get it working. Hopefully from this I can work out how the group option works, as I've not used it before. Fenway, can you tell me more about what the ALL subquery is and does?
  11. Hi all, Sorry for the stupid title, but I'm not sure how to summarise my question any more succinctly. I am updating a database that stores linguistic translations, so it is set up to have a tabl that has a row per translation job, and then a separate table that stores a the separate languages for each job (as a particular file may go into several languages). The table of the individual languages is where I am stuck. The three relevant fields for this question are: ID = A numeric ID for the row (this is not referenced anywhere else at all, it is purely there to act as a primary ket) JOB_ID = stores the INT value of the primary key of the main jobs table. This is how I can associate the various languages as being part of one job (i.e. they will all share the JOB_ID value) WORD_COUNT = An INT, storing the number of words in the translated file. What I want is a SELECT query that will return a DISTINCT set of JOB_IDs, where each returned JOB_ID has all of its WORD_COUNTS = NULL (or '' or 0,or whatever, but where they all equal some value). A basic "SELECT job_id FROM table WHERE word_counr IS NULL" obviously return the job_id for each set where any word_count is null. How do I do it to return only those where all are NULL. Ta for any help...
  12. Hi, I guess you've notice that sticking the BR tags in the forum post has just caused your message to break lines where you've put them. Not to worry. To add some other control characters along with the BRs when using the nl2BR function your can use the str_replace function. Immediately after running you nl2br run... str_replace('<br />', '\\t\\t<br />', $the_string_in_question); This would add the \t\t before each each html line break. Is this what you're after
  13. Scrap it, I've figured it out. My fault entirely - there was nothing wrong with the code at all. Sorry to have wasted people's time. Hopefully it wont happen again.
  14. I'm sorry, I forgot to point out that the error message says the problem is on the line: temp = parseFloat(document.quote[element].value); Although I can't see how, if the alert box in the line after is working. I have also tried it with putting a second alert immediately after the first containing alert(typeof temp), and it shows 'number' as a result.
  15. Hi, Don't ever ever ever pass anything from the superglobals ($_POST, $_GET, $_SERVER, etc) into an sql query, or really even to screen. People can put any data they want in these variables, and so can basically cause any commands they want to be executed as an SQL query. Make sure you sanitise your variables before you use them (clean them of any dangerous characters that could allow these things to happen). There are plenty of articles about on google about SQL injection that will show you how.
×
×
  • 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.