Jump to content

eludlow

Members
  • Posts

    24
  • Joined

  • Last visited

    Never

Everything posted by eludlow

  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
  15. If I insert a row that has an auto_increment value (use it as row id field..) but then I want to use that id value immediately after the insert is complete (I am sending a mail containing, amongst other things, the latest id), what is the best way of getting the latest value? So for instance I have: mysql_query("INSERT INTO `table` VALUES ('', 'field two')"); And the first field in the above is the auto_increment field. I obviosuly don't know what the value of that is to now SELECT the row in question. Hope this makes sense! Many thanks, Ed Ludlow
  16. I've got a fairly big table that has a list of members of an organisation. However, some of these records are out of date, and I'd like to move them all to another table of "lost" members that will have the same structure as the main table. It's easy for me to make something that inserts the old date into the new table and then deletes the record from the original table, but curious if mySQL has a function that will do this automatically? I can imagine it's a fairly common thing to want done.... Thanks, Ed Ludlow
  17. Done it! Turns out left is a mySQL function...so.... `left` = '$left' does the trick Thanks!
  18. OK this is driving me totally round the bend. My query is this: $editQuery = mysql_query("UPDATE `membership` SET title='$title', initials='$initials', surname='$surname', address1='$address1', address2='$address2', address3='$address3', address4='$address4', county='$county', postcode='$postcode', left='$left', type='$type', email='$email', phone='$phone' WHERE id='$toEditId'"); Which returns the following error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'left='', type='Annual', email='', phone='' WHERE id='223'' at line 1 However, if I remove the " left='$left' " part of the query it all works fine. The column "left" is fine, and is beign used by other queries fine...the variable $left is also fine, can be echoed no worries. (FWIW $left = a four digit year, which is being put into a text field...so no problems there I don't think?). If I use this.... $editQuery = mysql_query("UPDATE `membership` SET title='$title', initials='$initials', surname='$surname', address1='$address1', address2='$address2', address3='$address3', address4='$address4', county='$county', postcode='$postcode', type='$type', email='$email', phone='$phone' WHERE id='$toEditId'"); if (!$editQuery) { $dbError = "An error has occured. " . mysql_error(); die("$dbError"); } #die($left); which has the troublesome part removed, it executs fine, and then prints the $left variable fine and then dies..as I want. So what's its problem??!! Any help appreciated. Thanks, Ed Ludlow
  19. The user logs onto the PC workstation via active directory, and then the PHP page opens automatically.  It's the username they've logged onto AD with that I wish to have, either to tail on a file, or put in mySQL DB. E
  20. Thanks. I've just realised that wasn't a very clear account of what I'm trying to do, sorry! What happens is... A user logs onto an active directory domain.  When they log on, a PHP file opens in a browser window (all done through group policies) which then asks users to download a certain file.  What I am wondering is if PHP can get the user's AD username, and then with that I can write it to a log file so I know which domain users have downloaded the file. Hope that makes more sense! Thanks, Ed Ludlow
  21. Chaps, Is there a simple way that PHP can retrieve (guessing with LDAP??) the username of a user viewing a page? Basically, am running a network, and AD pops up a php file when users log on, prompting them to download a file, which is locally hosted.  I simply want to get the username of the domain user, and then append it to the end of a file, so I have a list of all users who have downloaded the file. LDAP is something I've been meaning to read up on for a while - but realised I'm supposed to have this script implemented by tomorrow morning - I see a fun evening VPNing onto the work network :( Many thanks in advance, Ed Ludlow
  22. As part of a website I'm developing, the website owner will need to put csv files on the web. It would be much easier if I could firstly convert these files into mySQL. However, I'd like to make this as user friendly as possibly, so that they simply submit the csv file and it converts it to mySQL. Is there a script anyone knows of that does this? I COULD give the users access to phpMyAdmin, but fear this could be a bit dangerous! Thanks, Ed Ludlow
×
×
  • 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.