Jump to content

Search the Community

Showing results for tags 'linux'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (Dreamweaver, Zend, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 33 results

  1. hello dear all , topic: questions with some eplanations - for db-related areas and topics - export er-diagram i want to post questions with some eplanations - for db-related areas and topics. Well i know that there are some good tools out there which help here alot. The question is : how to export the data so that i can implement the data into a forum like this !?! Question can i export the data form https://www.draw.io/ to this forum!? Love to hear from you regards
  2. I want to build a online "app builder" project that users can create android / iphone applications online without any coding knowledge. These sites are very common in market. They offer onclick app builder. I have skill in development of web applications using php frameworks. My question is How we can generate android apk from our server after getting the necessary information from user? (Appname, icon, packagename etc) PHP can do this entire task?, if yes any framework for that? Can you give me some basic tips to generate apk from our server? Can we genrate both android and iphone app from one single code? What are the requirements needed for the server? Anybody having skills in these areas, please help me. I need basic tips to get started this project. Thanks
  3. Hi all, I've done something similar with my wp-content folder where I protect the files from being downloaded if you are not logged in and everything works just fine. With the following code I am trying to say: #if the user doesen't have the cookie "wordpress_login_in" # and the url is wp-json ... # redirect to google RewriteCond %{HTTP_COOKIE} !.*wordpress_logged_in.*$ [NC] RewriteCond %{REQUEST_URI} ^.*wp-json/wp/v2/(users|comments|posts|pages|media|types|statuses|taxonomies|categories|tags|settings) [NC] RewriteRule ^ http://www.google.com [NC,L] Can anybody tell me why the script doesn't work? I am still seeing the JSON file (i have tried redirects from files and folders and everything seems okay. I've also tried creating wp-json folder but then that breaks the api from displaying)
  4. The following is a little OSM Overpass API example with PHP SimpleXML I've compiled because we do not have it here for PHP and I love OSM, so let's show some useful examples. The first part shows how tro query an Overpass Endpoint with standard PHP. For you the second part is more interesting. That is querying the XML data; This is most easily done with xpath, the used PHP XML library is based on libxml which supports XPath 1.0 which covers the various querying needs very well. see the code: ... and Goal: The output has to be stored into a mysql-db: <?php /** * OSM Overpass API with PHP SimpleXML / XPath * * PHP Version: 5.4 - Can be back-ported to 5.3 by using 5.3 Array-Syntax (not PHP 5.4's square brackets) */ // // 1.) Query an OSM Overpass API Endpoint // $query = 'node ["amenity"~".*"] (-54.5247541978, 2.05338918702, 9.56001631027, 51.1485061713); out;'; $context = stream_context_create(['http' => [ 'method' => 'POST', 'header' => ['Content-Type: application/x-www-form-urlencoded'], 'content' => 'data=' . urlencode($query), ]]); # please do not stress this service, this example is for demonstration purposes only. $endpoint = 'http://overpass-api.de/api/interpreter'; libxml_set_streams_context($context); $start = microtime(true); $result = simplexml_load_file($endpoint); printf("Query returned %2\$d node(s) and took %1\$.5f seconds.\n\n", microtime(true) - $start, count($result->node)); // // 2.) Work with the XML Result // # get all school nodes with xpath $xpath = '//node[tag[@k = "amenity" and @v = "school"]]'; $schools = $result->xpath($xpath); printf("%d School(s) found:\n", count($schools)); foreach ($schools as $index => $school) { # Get the name of the school (if any), again with xpath list($name) = $school->xpath('tag[@k = "name"]/@v') + ['(unnamed)']; list($website) = $school->xpath('tag[@k = "website"]/@v') + ['(no website)']; list($email) = $school->xpath('tag[@k = "contact:email"]/@v') + ['(no email)']; printf("#%02d: ID:%' -10s [%s,%s] %s %s %s\n", $index, $school['id'], $school['lat'], $school['lon'], $name, $website, $email); } //node[tag[@k = "amenity" and @v = "school"]] //tag[@k = "name"]/@v' $query = 'node ["addr:postcode"~"RM12"] (51.5557914,0.2118915,51.5673083,0.2369398); node (around:1000) ["amenity"~"fast_food"]; out;'; $context = stream_context_create(['http' => [ 'method' => 'POST', 'header' => ['Content-Type: application/x-www-form-urlencoded'], 'content' => 'data=' . urlencode($query), ]]); $endpoint = 'http://overpass-api.de/api/interpreter'; libxml_set_streams_context($context); $result = simplexml_load_file($endpoint); printf("Query returned %2\$d node(s) and took %1\$.5f seconds.\n\n", microtime(true) - $start, count($result->node)); so far so good: see the results: #37158: ID:5243708521 [-3.6852719,33.4154523] Buhangija primary school (no website) (no email) #37159: ID:5243805321 [-1.5071460,31.1599459] Kakiro Primary School (no website) (no email) #37160: ID:5243883144 [-10.4578962,39.0935938] Nangoo primary school (no website) (no email) #37161: ID:5244163476 [-6.8637976,39.2586565] PK Academic School (no website) (no email) #37162: ID:5244163478 [-6.8603893,39.2564774] Good Shepherd School (no website) (no email) #37168: ID:5247155223 [-1.6856759,29.0159534] Institut Miteetso (no website) (no email) #37169: ID:5247165222 [-1.7063811,29.0168647] Institut Lwanga-Bobandana (no website) (no email) #37170: ID:5247312700 [9.0129509,38.7290080] EiABC (Ethiopian Institute of Architecture Building Construction & City Devlopment) www.eiabc.edu.et (no email) #37171: ID:5248364671 [-4.3973951,29.1373596] École primaire Makama (no website) (no email) #37172: ID:5248372022 [-1.7101942,29.0233846] Institut Minova (no website) (no email) #37173: ID:5248439027 [-4.2744570,35.7445025] F . t . sumaye secondary school (no website) (no email) #37177: ID:5248974492 [-4.5490651,29.1559410] École primaire Kilicha (no website) (no email) #37178: ID:5248974495 [-4.5476651,29.1508141] École primaire Kazimia 2 (no website) (no email) #37179: ID:5248974504 [-4.5543585,29.1479282] École primaire Lwata (no website) (no email) so - and now i need to store all that stuff into a mysql-db i have to think "JSON". we need to have a closer look at http://php.net/json_decode So a idea for writing to a db table CREATE TABLE `node` ( `id` bigint(20) NOT NULL, `amenity` varchar(30) DEFAULT NULL, `name` varchar(100) DEFAULT NULL, `housenumber` varchar(5) DEFAULT NULL, `housename` varchar(50) DEFAULT NULL, `street` varchar(50) DEFAULT NULL, `city` varchar(50) DEFAULT NULL, `postcode` varchar(10) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; this code will do it $jsn = 'INSERT YOUR DATA HERE'; $jsn = str_replace('addr:','',$jsn); // legalise db column names $data = json_decode($jsn,1); // create array from json data $template = array ( // template array for db inserts 'id' => '', 'amenity' => '', 'name' => '', 'housenumber' => '', 'housename' => '', 'street' => '', 'city' => '', 'postcode' => '' ); $db = new mysqli(HOST,USERNAME,PASSWORD,DATABASE); // prepare the sql statement $sql = "INSERT INTO node (id, amenity, name, housenumber, housename, street, city, postcode) VALUES (?,?,?,?,?,?,?,?)"; $stmt = $db->prepare($sql); $stmt->bind_param('isssssss',$id, $amenity, $name, $housenumber, $housename, $street, $city, $postcode); // process the data foreach ($data['elements'] as $elem) { $tags = array_intersect_key($elem['tags'],$template); // get the tags we need $nodedata = array_merge($template,$tags); // add tag data to template array $nodedata['id'] = $elem['id']; // add id to template array extract($nodedata); $stmt->execute(); // insert in db table "node" }
  5. hello dear community, i am currently workin on a little python programme that does some extracting from BS4 and storing as list elements in Python. As i am fairly new to Python i need some help with that. Nonetheless, I'm trying to write a very simple Spider for web crawling. Here's my first approach: I need to fetch the data out of this page: http://europa.eu/youth/volunteering/evs-organisation_en Firstly, I do a view on the page source to find HTML elements? view-source:https://europa.eu/youth/volunteering/evs-organisation_en i have to extract data wrapped within multiple HTML tags from the above mentioned webpage using BeautifulSoup4. I have to stored all of the extracted data in a list. But I want each of the extracted data as separate list elements separated by a comma. here we have the HTML content structure: <div class="view-content"> <div class="row is-flex"></span> <div class="col-md-4"></span> <div class </span> <div class= > <h4 Data 1 </span> <div class= Data 2</span> <p class= <i class= <strong>Data 3 </span> </p> <p class= Data 4 </span> <p class= Data 5 </span> <p><strong>Data 6</span> <div class=</span> <a href="Data 7</span> </div> </div> well an approach would be: from urllib.request import urlopen as uReq from bs4 import BeautifulSoup as soup import urllib my_url ='http://europa.eu/youth/volunteering/evs-organisation_en' uClient = uReq(my_url) page_html = uClient.read() uClient.close() page_soup = soup(page_html, "html.parser") cc = page_soup.findAll("td",{"class":""}) for i in range(10): print(cc[0+i].text, i) guess i need some slight changes to code in order to get the thing working.- Code to extract: for data in elem.find_all('span', class_=""): This should give an output: data = [ele.text for ele in soup.find_all('span', {'class':'NormalTextrun'})] print(data) Output: [' Data 1 ', ' Data 2 ', ' Data 3 ' and so forth] question: / i need help with the extraction part... love to hear from you yours dilbert
  6. Hello, I've got a question about ddos attack. As happen before our site has been attack, i think it was a ddos attack which crash our server. Back then our web app and database are on the same server. As now web app and database are separate. site is on windows server and its connected to database from other server also (Linux). If an attack like that happen again, is the database server can be prevent from crashing as it is now separate? Thanks. I have a site running on windows server and its connected to database from other server also (Linux).
  7. hello dear community, hung up of Libreoffice - i cannot start it in terminal. How to fix this issue!? dilbert ;-)
  8. The server is AWS linux apache running PHP, with me the sole developer as owner ec2-user. Objective: To upload files from the app user's browser (handled) to a temporary directory (/test_sub below) within the /html tree, then for security purposes, to have PHP move this file to outside the /html tree (/private_sub below) where it will remain unable to be read, written to or deleted except when the app requires PHP to do this. The app needs PHP to make any directory permission changes via chmod, and perhaps owner changes and group changes (preferably not the last two). Here is the directory structure and SUDO output to accomplish this: /var drwxr-xr-x 21 root root 4096 Dec 11 19:23 /var /www drwxrwsr-x 11 root www 4096 May 1 16:50 /var/www : /html drwxrwsr-x 5 root www 4096 Apr 25 19:51 /var/www/html : : /AWS_s drwxrwsr-x 8 ec2-user www 4096 May 1 16:54 /var/www/html/AWS_s : : : /test_dir drwxrwsrwx 3 ec2-user www 4096 May 1 16:52 /var/www/html/AWS_s/test_dir : : : : /test_sub drwxrwsrwx 4 ec2-user www 4096 May 1 23:14 /var/www/html/AWS_s/test_dir/test_sub : : : : : /test_file.txt -rw-r--r-- 1 ec2-user www 13 Apr 24 13:36 /var/www/html/AWS_s/test_dir/test_sub/test_file.txt : : /private_dir drwxrwxrwx 3 ec2-user www 4096 May 1 21:02 /var/www/private_dir : : /private_sub drwxrwxrwx 2 ec2-user www 4096 May 1 21:19 /var/www/private_dir/private_sub : : : /moved_file.txt -rw-r--r-- 1 ec2-user ec2-user 13 Apr 24 13:36 /var/www/private_dir/private_sub/moved_file.txt : : : /copied_file.txt -rw-r--r-- 1 apache apache 13 May 1 23:49 /var/www/private_dir/private_sub/copied_file.txt : : /private_sub2 drwxr-xr-x 2 apache apache 4096 May 2 00:18 /var/www/private_dir/private_sub2 The PHP scripts are run in the /test_sub directory. The default permissions for directories are drwx rws r-x 2775. Only when the /private directories are both set to 777 and the setgid is unset will they allow files to be written to them. When the two /test directories are set to the default of 775 with the setgid set, they allow files to be copied from them. However, when the move (rename) script is run, the delete function of the copy and delete process throws an error unless both /test directories are reset to 777 clearly allowing files to be deleted. I'm concerned that the /test and /private directories need to be 777, opening them up to bad actors. I've spent days researching and testing many options but have failed to resolve this. Clearly, I'm missing something fundamental here My questions: 1. Why do the two /test and the two /private directories need to have the 'other' set to rwx? I read that PHP uses group www and therefore that group www should allow the writes in the /private directories and the reads and deletes in the /test directories. 2. Why does copied_file.txt have owner:group as apache:apache instead of ec2-user:www and likewise when I mkdir /private_sub2 in PHP? 3. Why does moved_file.txt have owner:group ec2-user:ec2-user instead of ec2-user:www? 4. Why did PHP mkdir create the non-default permission 0755 in /private_sub2? 5. Why, using PHP, do chown, chgrp and chmod fail to make changes to /private_sub/moved_file.txt?
  9. I've been searching for sources to help me understand Linux Apache permissions from the PHP programmer's perspective getting only the rwx and 755 type descriptions and processes in abundance. What I need is a *source* that I can learn Linux permissions from the perspective of the *PHP programmer*, not for the Linux admin who has the box locally or remotely. I'd like to know, for example, when to give each of the three users which permissions for my PHP app's directories, data files and PHP scripts on the basis of heightening security.
  10. new to the work with PHPSimpleXML I want to filter the data to get the nodes with special category. Here is sample of the OSM data I want to get the whole schools within an area. The first script runs well - but now i want to refine the search and add more tags. Finally i want to store all into the MySQL-db So we need to make some XML parsing with PHP: The following is a little OSM Overpass API example with PHP SimpleXML I've compiled it because I love OSM, so let's show some useful examples. The first part shows how we can query an Overpass Endpoint with standard PHP. we do not need that part if we have already saved the data on the harddisk. <?php /** * OSM Overpass API with PHP SimpleXML / XPath * * PHP Version: 5.4 - Can be back-ported to 5.3 by using 5.3 Array-Syntax (not PHP 5.4's square brackets) */ // // 1.) Query an OSM Overpass API Endpoint // $query = 'node ["amenity"~".*"] (38.415938460513274,16.06338500976562,39.52205163048525,17.51220703125); out;'; $context = stream_context_create(['http' => [ 'method' => 'POST', 'header' => ['Content-Type: application/x-www-form-urlencoded'], 'content' => 'data=' . urlencode($query), ]]); # please do not stress this service, this example is for demonstration purposes only. $endpoint = 'http://overpass-api.de/api/interpreter'; libxml_set_streams_context($context); $start = microtime(true); $result = simplexml_load_file($endpoint); printf("Query returned %2\$d node(s) and took %1\$.5f seconds.\n\n", microtime(true) - $start, count($result->node)); // // 2.) Work with the XML Result // # get all school nodes with xpath $xpath = '//node[tag[@k = "amenity" and @v = "school"]]'; $schools = $result->xpath($xpath); printf("%d School(s) found:\n", count($schools)); foreach ($schools as $index => $school) { # Get the name of the school (if any), again with xpath list($name) = $school->xpath('tag[@k = "name"]/@v') + ['(unnamed)']; printf("#%02d: ID:%' -10s [%s,%s] %s\n", $index, $school['id'], $school['lat'], $school['lon'], $name); } ?> For you the second part is more interesting. That is querying the XML data you have already. This is most easily done with xpath, the used PHP XML library is based on libxml which supports XPath 1.0 which covers the various querying needs very well. The following example lists all schools and tries to obtain their names as well. I have not covered translations yet because my sample data didn't have those, but you can also look for all kind of names including translations and just prefer a specific one): The key point here are the xpath queries. Two are used, the first one to get the nodes that have certain tags. I think this is the most interesting one for you: //node[tag[@k = "amenity" and @v = "school"]] This line says: Give me all node elements that have a tag element inside which has the k attribute value "amenity" and the v attribute value "school". This is the condition you have to filter out those nodes that are tagged with amenity school. Further on xpath is used again, now relative to those school nodes to see if there is a name and if so to fetch it: tag[@k = "name"]/@v' This line says: Relative to the current node, give me the v attribute from a tag element that as the k attribute value "name". As you can see, some parts are again similar to the line before. I think you can both adopt them to your needs. Because not all school nodes have a name, a default string is provided for display purposes by adding it to the (then empty) result array: list($name) = $school->xpath('tag[@k = "name"]/@v') + ['(unnamed)']; ^^^^^^^^^^^^^^^ Provide Default Value so far so good: **note**. i need to have the adress-data, of the school with cf Key:addr - OpenStreetMap Wiki and even more important cf Key:contact - OpenStreetMap Wiki btw. here my results for that code-example: martin@linux-70ce:~/php> martin@linux-70ce:~/php> php osm1.php Query returned 1691 node(s) and took 3.34569 seconds. 23 School(s) found: #00: ID:332534486 [39.5017565,16.2721899] Scuola Primaria #01: ID:1428094278 [39.3320912,16.1862820] (unnamed) #02: ID:1822746784 [38.9075566,16.5776597] (unnamed) #03: ID:1822755951 [38.9120272,16.5713431] (unnamed) #04: ID:1903859699 [38.6830409,16.5522243] Liceo Scientifico Statale A. Guarasci #05: ID:2002566438 [39.1349460,16.0736446] (unnamed) #06: ID:2056891127 [39.4106679,16.8254844] (unnamed) #07: ID:2056892999 [39.4124687,16.8286119] (unnamed) #08: ID:2272010226 [39.4481717,16.2894353] SCUOLA DELL'INFANZIA SAN FRANCESCO #09: ID:2272017152 [39.4502366,16.2807664] Scuola Media #10: ID:2358307794 [39.5015031,16.3905965] I.I.S.S. Liceo Statale V. Iulia #11: ID:2358307796 [39.4926280,16.3853662] Liceo Classico #12: ID:2358307797 [39.4973761,16.3858275] Scuola Media #13: ID:2358307800 [39.5015527,16.3941156] I.T.C. e per Geometri #14: ID:2358307801 [39.4983862,16.3807796] Istituto Professionale #15: ID:2358344885 [39.4854617,16.3832419] Istituto Tecnico Statale Commerciale G. Falcone #16: ID:2448031004 [38.6438417,16.3873106] (unnamed) #17: ID:2458139204 [39.0803263,17.1291649] Sacro Cuore #18: ID:2552412313 [39.0765212,17.1224610] (unnamed) #19: ID:2582443083 [39.0815417,17.1178983] Liceo Socio Biologico Gravina #20: ID:2585754364 [38.8878393,16.4076323] Scuola Elementare #21: ID:2585754366 [38.8877600,16.4076216] Scuola Media #22: ID:2755576944 [39.3641541,17.1310900] (unnamed) martin@linux-70ce:~/php> note. i need to have the adress-data, of the shool with and even more important Key:contact - OpenStreetMap Wiki How to add this .. into the query ? and how to finally store all into the MySQL-db ?
  11. ajoo

    linux command sed

    Hi all ! Can someone please explain what the following command does:- sudo sed -i s,scotchbox.local,$DOMAIN,g /etc/apache2/sites-available/$DOMAIN.conf sudo sed -i s,/var/www/public,/var/www/$DOMAIN/public,g /etc/apache2/sites-available/$DOMAIN.conf I can across these commands in here. I have tried them out in the terminal as a modified example :- sudo sed -i, s,www,the,g test.txt. where test.txt has 2 lines of some text containing the word 'the' a couple of times. The command seems to do nothing. There is no change in test.txt. I cannot get any example of sed -i, s on google. In fact i cannot get a similar example of sed anywhere on google. But then i believe sed is extremely versatile and has tons of usages. Grateful for any help. Thanks all.
  12. good day dear php-freaks i need to rename files in _ one _ directory - more than 50 files are in this..folder: the files are named like so: 01 02 03 04 ... 49 50 each file has got a number as a file name. each file should get a character - like so: r01, r02, r03, r04 and so on . .... r50 how can we do this on commandline
  13. hello dear community I’m trying to capture the output of the top command into a file. When I execute top > output.txt, the output.txt file contains lot of junk characters. What is the best method to capture the output of the top command into a readable text file? i tried to use the top command batch mode operation option ( -b ) to capture the top command output into a file. top -n 1 -b > top-output.txt or this one less top-output.txt but - unfotunatly they do not work for me... : linux-a9sq:/home/martin # -n 1 > top-output.txt -n: command not found linux-a9sq:/home/martin # top-output.txt If 'top-output.txt' is not a typo you can use command-not-found to lookup the package that contains it, like this: cnf top-output.txt linux-a9sq:/home/martin # top -n 1 -b > top-output.txt linux-a9sq:/home/martin # top -n1 -b | head5 If 'head5' is not a typo you can use command-not-found to lookup the package that contains it, like this: cnf head5 linux-a9sq:/home/martin # what can i do!? love to hear from you greetings
  14. In the following pages I'm trying to validate if a user is signed in or not. If the user is signed in I would like to see 'Log Out' printed to the screen(I'll do more with that later). If the user is not signed in I would like to see a login form at the top right of the screen. As it stands I'm only seeing 'Log Out' on the screen, I can't get the form to show up anymore. I thought it might be because the session variable was still hanging around but I restarted my computer to make absolutely sure but I'm still just getting 'Log Out'. At the moment I need this program to work as is as much as possible. If you see an entirely different approach that you would use that's fine but I don't currently have the time to go changing a lot, I need to get this going kinda quick. Thanks. records-board.php <?php require_once('includes/init.php'); if(!isset($_SESSION)) { init_session(); } ?> <html> <head> <Title>Pop Report</title> <link rel="stylesheet" type="text/css" href="styles/popreport2.css"> <h1>Pop Report</h1> </head> <body> <?php if(isset($_POST['nameinput']) && isset($_POST['passinput'])) { $nameinput = $_POST['nameinput']; $passinput = $_POST['passinput']; User::sign_in($nameinput, $passinput); } if(!isset($_SESSION['user'])) { print_form(); } else { echo "Log Out "; echo $_SESSION['user']->name; // this line was just trouble shooting, it told me nothing! } ?> user.php <?php if(!isset($_SESSION)) { init_session(); } class User { public $name; public function __construct($username, $password) { $connection = get_db_connection(); $query = $connection->query("SELECT * FROM users WHERE username='$username' AND password='$password'"); if(!$query) { echo "Invalid username or password"; } else { $result = $query->fetch(PDO::FETCH_ASSOC); if(!$result['username'] == $username || !$result['password'] == $password) { echo "Invalid username or password"; } else { $this->name = $result['username']; } } } public static function sign_in($username, $password) { $_SESSION['user'] = new User($username, $password); } } ?> <?php function print_form() { echo "<form id='loginform' name='loginform' action='records-board.php' method='post'>"; echo "Username: <input type='text' name='nameinput'>"; echo "Password: <input type='text' name='passinput'><br />"; echo "<input type='submit' value='Sign In'>"; echo "</form>"; } ?>
  15. I'm getting the following errors when I run `cat /var/log/apache/error.log` -> PHP Notice: Undefined variable: db_connection in /var/www/html/popreport/includes/inmate.php on line 18 -> PHP Fatal error: Call to a member function query() on a non-object in /var/www/html/popreport/includes/inmate.php on line 18 When I try this in my browser I start with test.php test.php <?php require_once("./database.php"); require_once("./inmate.php"); // foreach($query as $row) // { // print_r($row) . "<br />"; // } $inmate = array(); $inmate = new Inmate($inmate); foreach($inmate as $row) { print $row->firstl_name . "<br />"; } ?> database.php <?php include("./constants.php"); try { $db_connection = new PDO("mysql:host=$host;dbname=$db_name", $db_user, $password); $db_connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (PDOException $e) { print "Error!: " . $e->getMessage() . "<br />"; die(); } ?> inmate.php <?php require_once("./database.php"); class Inmate { private $first_name = ''; private $last_name = ''; private $full_name = ''; private $race = ''; private $number = 0; private $facility = ''; private $type_of_transit = ''; public function __construct($inmate) { $sql = "SELECT * FROM inmate_board"; $query = $db_connection->query($sql); $result = $query->fetch(PDO::FETCH_ASSOC); foreach($result as $row) { $this->$first_name = $result['first_name']; } } public function get_property($property) { return $this->$property; } } ?> In inmate.php I also tried to change the line `$query = $db_connection->query($sql);` to `$query = global $db_connection->query($sql);` but I didn't have any luck here either. Any ideas?
  16. [Linux] PHP Notice: Undefined variable: connection in /var/www/html/popreport/functions.php on line 23 PHP Fatal error: Call to a member function query() on a non-object in /var/www/html/popreport/functions.php on line 23 The fuction output in the following program is called from another file called records records-board.php If you look at the program below you'll see that I did define $connection above line 23 in the file functions.php And for the second error I'm really not getting it because that same foreach loop was working fine with the exact same argument list when it was in the file records-board.php, but now that I've copied most of the code from records-board.php and placed it in functions.php all the sudden my program can't see the variable $connection and has a problem with my foreach loop on line 23. Again, both of those lines worked fine when they were in another file. functions.php <?php //session_start(); // open a DB connectiong $dbn = 'mysql:dbname=popcount;host=127.0.0.1'; $user = 'user'; $password = 'password'; try { $connection = new PDO($dbn, $user, $password); } catch (PDOException $e) { echo "Connection failed: " . $e->getMessage(); } $sql = "SELECT full_name, tdoc_number, race, facility FROM inmate_board WHERE type = 'COURT'"; function output() { foreach($connection->query($sql) as $row) { echo "<tr><td>$row[full_name]</td></tr>"; } } ?> records-board.php <? include 'functions.php'; php output(); ?> Any ideas?
  17. Hi all. I have a script that i want to run in a cronjob. but i dont know why it's not running. i am using godaddy cpanel ps: when i visit the url of the file, it works as expected, and also when i run it via a form button, it works also. what could be the problem? below is the command i used: /usr/local/bin/php -q /home/username/directory/directory/file-name.php thanks
  18. Hello All, Have a GoDaddy MySQL PHP:PDO hosting questions. Using a database class to make script queries. Unfortunately, I'm required to use GoDaddy Windows hosting. However, I'm a Linux kind of guy. Here's the issue. The viewer script includes database credentials defined as constants, in a file outside the root directory. Typically, these constants are available to all sub processes including class objects. Everything works as expected on development server. The error message I get with version using constants: L226: projectGallery_class datapull Caught Exception --- invalid data source name with host string userDBName.db.6482519.hostedresource.com;dbname=userDBName However when I deploy to GoDaddy's production server, the constants are defined - but empty. Here is the example code. /* works on Linux */ class datapull { var $host; // not assigned here var $userName; // not assigned here var $userPass; // not assigned here protected function conn() { try { $DB = new PDO(DB_HOST,DB_UNAME,DB_PASS); $DB->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); return $DB; } catch( Exception $e ) { $mes = "L226: datapull::conn() Caught Exception --- "; $mes .= $e->getMessage(); error_log($mes); } } public function dbquery($qqueue) { $DB = (!isset($DB)) ? $this->conn() : $DB; /* some query stuff here */ return $result } The modified class for GoDaddy Windows class datapull { var $host = “mysql:host=userDBName.db.1234567.hostedresource.com;dbname=userDBName”; var $userName = “userDBName”; //godaddy user and database naming convention var $userPass = “userPWDString”; //user password protected function conn() { try { $DB = new PDO($this->host,$this->userName,$this->userPass); $DB->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); return $DB; } catch( Exception $e ) { $mes = "L226: datapull::conn() Caught Exception --- "; $mes .= $e->getMessage(); error_log($mes); } } public function dbquery($qqueue) { $DB = (!isset($DB)) ? $this->conn() : $DB; /* some query stuff here */ return $result }
  19. hello dear php-experts, i want to run and show facebook-actiity feeds (in other words "streams of two different facebook sites) that said i cannot do this with one plugin - can i? well some guys taled bout a solution of copying and cloing a wordpress plugin I want to have multiple instances of the plugin running so i can have different related content on a single page. that said i heard that some guys just do one thing; they coly the copy the plugin. https://wordpress.org/support/topic/installing-2-copies-of-the-same-plugin?replies=8 but thie does not work - so i have to do one facebook-feed with a version like so question - how to include the code: https://developers.facebook.com/docs/plugins/activity Initialize the JavaScript SDK using this app: booksocial123 Include the JavaScript SDK on your page once, ideally right after the opening <body> tag. <div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_GB/sdk.js#xfbml=1&appId=473241986032774&version=v2.0"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script> Place the code for your plugin wherever you want the plugin to appear on your page. <div class="fb-activity" data-site="facebook.com/literaturen" data-action="likes, recommends" data-width="350px" data-height="350px" data-colorscheme="light" data-header="true"></div> how to include that into a wordpress
  20. hello dear php-experts, the question of the day - how to find a file with a certain text - the commands below do not help here .... the are good but they do not open the file find . | xargs grep "texthere" * grep -r "texthere" . grep -r "a target="_blank"" find ./ -type f | xargs grep "foo" hmm - well i guess that the grep command will help here. well i want to do a seach recursively - through all files in a folder. And i want to open fhe file - after it is found. How can we do this!? love to hear from you
  21. I've spent the last year building a web application on my local machines using the typical LAMP stack. I've been a developer for 10+ years and am fairly good when it comes to scripting but the server/hosting/system admin thing scares me. I've taken tons of sites live but they always exist on shared hosting and require minimal maintenence...simply ftp changes...no big deal. With my latest personal projects I've used revision control (git or mercurial) simply as a way to let me work from different machines. It's awesome. I push code from home, work, and my laptop and everything is in sync with one another. It really has changed the game for me. ( I use bitbucket) My latest project will involve paying customers and has a huge code base. FTPing files is not going to cut it. I've heard of having a "staging" environment so that you can push code to the staging environment, test it, and then push to production. That sound perfect! Every time I google git/staging I get pages and pages of command line stuff. I'm used to using version control GUI's like tower and sourcetree. Are there server environments that would allow me to use a GUI to manage version control? Or are linux server environments command line only? Are there any hosting companies you know of that would be a good fit for these needs? I'm looking to keep the hosting <= $20/month Thanks
  22. ant to install linux on a notebook (which i want to buy ) The notebook: hewlett packard - hp 14r103ng notebook with 4 (8GB) what do you think bout this idea. Question: i do not do play games. I only need the notebook to have a good one for being mobile. I plan to set the RAM to 8 GB immitiately after buying it. do you think that this is a good choice or do you suggest to go to a notebook that has a INTEL i 3 or INTEL i 5 processor again: i only need a notebook that does basic things... The notebook costs 260 to 290 Euro in Germany - thats a fair price - reasonable and okay i think. The notebook has got a dvd-drive... love to hear from you
  23. hello i want to crate a passepartout photo how to create a passepartout size in irfanview - do you have any experience? btw: if i have to change the background. - can i do this with irfanview too!? many thanks for any and all feedback
  24. hello dear PHP-experts i run opensuse 13.2 i ve set up an apache webserver - well - if i type localhost into the browser then i see: it works but i want to see also phpmyadmin: the phpmyadmin on apache server - installed but not visible - what can i do now. I think that i have to check the running services on the machine!!? Which test can be done - with the terminal ? Which tests can i run on commandline ? love to hear from you greetings
  25. hello dear PHP-experts, today i create a rescue-system for the emergency-situation: i am creating a little resque-usb for SUSE-DVD on USB-Stick currently plan to create a litle Rescue-USB while using Suse-ISO DVD on a USB medium 1:1 copied step 1. Suse-ISO download: here: http://ftp5.gwdg.de/pub/linux/suse/opensuse/distribution/13.2/iso/openSUSE-13.2-Rescue-CD-x86_64.iso step 2 copy the file onto a USB stick with the following command dd if=openSUSE-13.2-Rescue-CD-x86_64.iso of=/dev/sdX bs=32kwhere sdX=sdb or sdc is the USB stick ready - now i can test the rescue-usb
×
×
  • 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.