Jump to content

NigelRel3

Members
  • Posts

    69
  • Joined

  • Last visited

Everything posted by NigelRel3

  1. I would have thought that you need to use LOCK_EX instead of LOCK_SH as in both cases you are writing to the file. LOCK_SH allows shared access to the file.
  2. If public_html s a directory you have created, then it could be that the process which is running PHP doesn't have rights to that directory. So check the owner and rights to the directory your trying to write to (In linux, PHP is commonly run as www-data:www-data, so usually best to have all things within your web root directory owned by that user). One thing you have to consider is the difference between a URL path and a directory path. It looks as though the file your writing to is relative to the script that your running. It's assuming there is a directory called public_html in the same directory as the install.php. This may be the case, but you could also consider using something like realpath() which can give you the actual directory your writing to in the file system from the URL your using.
  3. (As stated before) If you consider what happens why the loop ends - it's when $message = mysqli_fetch_assoc($res) Returns NULL to show there are no more rows. So after this - $message will contain NULL and not any message at all. Also consider that even if it did contain a message - it may not be the one you want. If you want the first message - the one where $counter is 0, perhaps you could store this message somewhere and use those values further down.
  4. A simple way to get a list of the records which are different would be something like (changing names as appropriate)... select * from events where (end, id, start, title ) not in ( select end, id, start, title from events1 ) You can list all of the columns in the first set of brackets and list the same columns from the second table. The query should only return where the row has different values or there isn't a matching row. If in your case you use the new data as your driving table (so events would be unverified_data), it will check any unverified records against the existing data.
  5. If your id value on the database is an autoincrement key, then don't put it into your insert statement.
  6. My problem is that I've done more Java than PHP and so I was erroneously making that assumption about scope, I will now unscrew my head and make the appropriate adjustments
  7. You should be able to produce the same sort of results by using INSERT... SELECT. You may be able to reduce the whole thing down to 1 statement with some careful use of values in the SELECT.
  8. You could use something like select c.* from customers c where not exists (select 1 from type t where c.customer_id = t.customer_id and t.type in ('macintosh')) All this does is find the people where a record isn't found for a set of types.
  9. Thanks - it makes sense if the value persists beyond the scope of the foreach. I was under the impression that this value is only valid inside the foreach block and therefore would be forgotten after each loop :-/
  10. I'm working with something where I use references to allow me to modify arrays - and the reference on a field seems to 'stick'. The code I've cut down to show this is... <?php $tableName = "BinType"; $fields = [ [ "name" => "binTypeID" ], [ "name" => "description" ] ]; foreach ( $fields as $field ) { echo " name1='" . $field ['name'] . "' "; } $fieldNames = array (); foreach ( $fields as &$field ) { echo " name2='" . $field ['name'] . "' "; $fieldNames [] = $field ['name']; } foreach ( $fields as $field ) { echo " name3='" . $field ['name'] . "' "; } Which gives as the output... name1='binTypeID' name1='description' name2='binTypeID' name2='description' name3='binTypeID' name3='binTypeID' So it seems that the reference in the middle foreach seems to be still in place for the last foreach. Can someone shed some light on this or do I just do what I did and rename the last $field to $field1 and ignore the problem? Thanks ( PHP - PHP Version 7.0.15 )
×
×
  • 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.