Jump to content

ludo1960

Members
  • Content Count

    123
  • Joined

  • Last visited

Everything posted by ludo1960

  1. Thanks for advice, wasn't getting anywhere till I found this https://www.php.net/manual/en/mongodb.tutorial.library.php now it works a treat, Once installed, you have access to all the mongo goodies https://docs.mongodb.com/php-library/current/ MongoDB\Client was indeed correct! Thanks again!
  2. Sorry, the link is here https://www.php.net/manual/en/set.mongodb.php there is our chum MongDB\Driver\Manager .
  3. Hi there, Thats the old driver, i'm using the new one here: https://www.php.net/manual/en/set.mongodb.php
  4. Hello guys, I've installed the mongoDB PHP driver using "sudo pecl install mongodb" Testing shows driver is installed correctly and it appears nicely in phpinfo(): ludo@aegir:~$ php7.2 -i | grep -i mongodb mongodb MongoDB support => enabled MongoDB extension version => 1.5.3 MongoDB extension stability => stable mongodb.debug => no value => no value For connecting I've got: $db = new MongoDB\Driver\Manager("mongodb://localhost:27017"); Now I want to define a collection and insert a record, i've been using code from here https://www.php.net/manual/e
  5. Good news guys, found the error: I was having a tough time trying to install xdebug, I used the output from php -v and put it in here: https://xdebug.org/wizard.php The output from my php.ini was PHP 7.2.18-..... Then the wizard gave me the steps to follow. The script needs phpize from the php-dev bundle seemingly. As I had just rebuilt my dev box, I was watching the xdebug install doing its thing and I noticed that php7.0 and php7.3 kept whizzing by as the script progressed. Strange I thought, i've got php7.2 why is xdebug downloading all this stuff?? Needless to say when i tried to get
  6. only because I sorted the table by item, here it is sorted by id:
  7. Ok, after trying it all again ie truncate, load page again, still double entries. Here's the maria.err log 2019-05-14 20:37:23 139840968318336 [Note] InnoDB: innodb_empty_free_list_algorithm has been changed to legacy because of small buffe$ 2019-05-14 20:37:23 139840968318336 [Note] InnoDB: Using mutexes to ref count buffer pool pages 2019-05-14 20:37:23 139840968318336 [Note] InnoDB: The InnoDB memory heap is disabled 2019-05-14 20:37:23 139840968318336 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 2019-05-14 20:37:23 139840968318336 [Note] InnoDB: GCC builtin __atomic_thr
  8. I have no idea what you mean by general log
  9. ok, I added !include /etc/mysql/mariadb.cnf to my /etc/mysql/my.cnf and added log_error=/var/log/mysql/mariadb.err to /etc/mysql/mariadb.cnf restarted mysql, truncated and tried again, still double entry and no mariadb.err where it should be??
  10. Added it to /etc/php/7.2/cli/php.ini : error_reporting = E_ALL error_reporting(E_ALL); ini_set('display_errors', '1'); Restarted Nginx, sudo service php7.2-fpm reload, truncated the database table, tried page again, still double entry and no errors.
  11. sure, here you go: <?php error_reporting(E_ALL); ini_set('display_errors', '1'); include_once 'connection.php' ; $url = "http://admin.contenta.com/api"; //$url = 'https://live-contentacms.pantheonsite.io/api'; $jsondata = file_get_contents($url); $response = json_decode($jsondata, true); $myarray = $response['links'] ; foreach ($myarray as $k => $v) { $newarr[strval($k)] = $v['href']; } $res = $db->prepare("INSERT INTO apidata (item, value) VALUES (?, ?)") ; foreach ($newarr as $key => $value) { $res->execute( [ $key, $value ] );
  12. Just tried it: error_reporting(E_ALL); ini_set('display_errors', '1'); Still no errors reported, double entries persist. I think a re-install of my dev box is on the cards.
  13. Stranger and stranger, if I run the code with the original code above: i get: Array ( [self] => h [blocks] => h [comments] => h [reviews] => h [commentTypes] => h [consumer--consumer] => h [files] => h [graphql_query_map--graphql_query_map] => h [imageStyles] => h [mediaBundles] => h [images] => h [articles] => h [pages] => h [recipes] => h [node--tutorial] => h [contentTypes] => h [menus] => h [vocabularies] => h [categories] => h [tags] => h [rol
  14. Try this yourself and you will see double entries: <?php include_once 'connection.php' ; //$url = "http://admin.contenta.com/api"; $url = 'https://live-contentacms.pantheonsite.io/api'; $jsondata = file_get_contents($url); $response = json_decode($jsondata, true); $myarray = $response['links'] ; foreach ($myarray as $k => $v) { $newarr[strval($k)] = $v['href']; } $res = $db->prepare("INSERT INTO apidata (item, value) VALUES (?, ?)") ; foreach ($newarr as $key => $value) { $res->execute( [ $key, $value ] ); } echo "<pre>
  15. Yes, USE mydb; ---->then SELECT COUNT(*) FROM apidata;
  16. And here was me thinking I found the error, back to the drawing board! Oh, and I added error_reporting(E_ALL); to the page, but still no errors show?
  17. foreach ($myarray as $k => $v) { $newarr[strval($k)] = $v['href']; } Does not work??
  18. From the mysql shell, i'm runnig: SELECT COUNT(*) FROM apidata;
  19. Reading https://www.php.net/manual/en/language.types.array.php the $newarr array at the moment is [article] => somevalue, should be ['article'] => somevalue so, foreach ($myarray as $k => $v) { $newarr[$k] = $v['href']; } // how to cast $newarr key to string ??
  20. oops posted in wrong place, sorrry!
  21. Already got that in my connection.php, and no errors are shown? function pdoConnect() { $dsn = "mysql:dbname=".DBNAME."; host=".HOST."; charset=utf8"; $db = new pdo($dsn, USERNAME, PASSWORD, [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, ]); return $db; } $db = pdoConnect();
  22. Gonna read up on error reporting, and try and find out why the double entry is haappening, many thanks, for all the help!
  23. I changed the item column to be UNIQUE, and now 23 records are inserted. Don't thinks it is a proper fix, would love to know why the code causes a double insert. I don't see how the code is being run twice, surely a web page just refreshes itself once?
  24. I am using PHPmyadmin, but have also tried from the mysql shell and the results tally
  25. HTML displays correctly as does php echo
×
×
  • 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.