Jump to content

eludlow

Members
  • Posts

    24
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

eludlow's Achievements

Member

Member (2/5)

0

Reputation

  1. Hi all. I've a table that UNIONs 12 tables together. I then have a query (call it x) that will identify one row in this view (so it could be in one of 12 tables). I then need to update one field in that one row. I can't update the view, as it contains UNION. Is there a way I can get mysql to tell me the name of the table that contains a row of data from the view? This will make the update query a lot simple. Otherwise, I will have to search EACH of the 12 tables for the row returned by my first query (x) and then update based on the table returned by that. Thanks, Ed
  2. I have a large data set that for various reasons is split over 12 tables, with identical structures. I know this sounds slightly odd, but trust me, I have to manage the data this way Anyway, I have a query that "UNIONS" certain records from each table into one view, which all works fine. However, is it possible, when querying the database, to find out which table each record belongs to? So I have, let's say, 12 rows in my view, one from each table and I want to not only extract the data from each column of each row, but the "originating" table the data is in? I can do this by searching each table it MAY be in, but that seems a bit long winded. Many thanks, Ed Ludlow
  3. Perfect, thanks. Solved a very similar problem I had earlier using explode() (after posting on the forum - see reg ex forum!) - should have thought of it myself Many thanks.
  4. I have an array in which each element is two numbers separated by a comma, eg 50,3 How would I go about checking whether a certain number matches the first half of the element? Ie, I provide a variable $x and want to output each element that starts $x,5 or $x,49 etc etc I tried using in_array but then realised that this only matched the element in its entirety. I've a feeling it may need regular expressions? Many thanks, Ed Ludlow
  5. Ignore above - brain fade moment I think. Much simple to do with explode() which is now working. Thanks!
  6. I have an array that has values in the form x,y For each element of the array I want an "x" variable and a "y" variable. I believe the way to do this is with preg_split - can someone help with the regex and explain what is being done. Thanks, Ed Ludlow
  7. Many thanks effigy and Ken - much appreciated.
  8. I have a string that takes the following form: {1}{2}{3} I need to split the string into an array based on the curly brackets - I think this is best achieved using preg_split() - would that be correct? This would also be one of my first forays into regular expressions - would someone be able to show me the regex needed and explain how it's achieving the split, please? Many thanks in advance, Ed Ludlow
  9. OK, as a follow up, I've found this works: SHOW TABLES FROM pssru LIKE 'tr_%' Can someone explain what the % actually means, as opposed to using an asterisk? Thanks, Ed
  10. I have taken over a database with several hundred tables, which I am slowly trying to organise into a more meaningful structure ie adding table name prefixes etc. If I want to list all the databases that, for example, have the prefix "tr_" then this code: SHOW TABLES FROM whateverdatabase LIKE '%tr_%'; works fine EXCEPT it also returns table names such as "rmm_entries" - I guess because it contains "tr" and an underscore. How would I change the query to so as to exclude the "rmm_entries" and JUST list tables starting with "tr_"? Many thanks in advance, Ed Ludlow
  11. Do you want to show all the records that are OLDER than 10 months? If so then I'd have thought: $tenMonthOldTimestamp = time() - 24192000; (number of seconds in ten months..) then mysql_query("SELECT * FROM `prop_tbl` WHERE create_data <= ' $tenMonthOldTimestamp'"); E
  12. OK I've set upload_tmp_dir to /tmp/ in php.ini, given apache a restart, and I'm still getting exactly the same E
  13. I've a php upload script I've used many times on hosted servers, but I've just tried it on my Ubuntu machine and I cannot get it working. The script is: PHP Code: $uploaddir = '/var/www/intranet/uploaded_files/'; $uploadfile = $uploaddir . $_FILES['filename']['name']; if (move_uploaded_file($_FILES['filename']['tmp_name'], $uploadfile)) { echo "File is valid, and was successfully uploaded.\n"; } else { echo "File not uploaded - " . $_FILES['filename']['error'] . "\n"; } In my phpinfo() the settings for uploads are as follows: file_uploads: on upload_max_filesize: 2M upload_tmp_dir: no value I'm wondering should upload_tmp_dir be set? I would guess it defaults to /tmp if it's not set. /tmp is CHMODed to 777, as is /var/www/intranet/uploaded_files/ $_FILES['filename']['error'] is not outputting anything. I've been playing with this for an hour or so now...and am stumped! Any help appreciated. Thanks, Ed Ludlow
  14. Solved, mysql_insert_id() is my new best friend Ed
×
×
  • 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.