PHP - Php And Wmi - Querying For Ip Addresses On Remote Hosts
Hello,
I'm attempting to write a PHP script to query WMI for an IP address of a host. The reason I'm doing this instead of getbyhostname is because NAT translations on the network can cause inaccurate results. The question is two-fold: 1) My Script is as follows <? $obj = new COM ( 'winmgmts://localhost/root/CIMV2' ); $wmi_network = $obj->ExecQuery("Select * From Win32_NetworkAdapterConfiguration"); foreach ( $wmi_network as $wmi_call ) { $ipaddr = $wmi_call->IPAddress; echo $ipaddr; } ?> I get the following error when running the script: Quote Catchable fatal error: Object of class variant could not be converted to string 2) How do I go about querying a remote host on the network with valid credentials? Thank you Similar TutorialsI hope this is a good place to post this. I saw another old post that was web host related so I thought this one might fit here too.
I am hoping someone could give me some advice on the best web hosts out there for PHP and LAMP. For now I am looking for a shared server that will allow me to experiment with using PHP to generate X3D scenes as well as to hone my HTML5, PHP, and javascript skills. I will be the only person using the site.
Important factors include cost, reliability (up time), reasonable speed, support, and the latest versions of PHP etc. I looked through a lot of "best of" lists but they all seem to be supported by advertising and discount deals from the hosts, so I have doubts about their objectivity.
Thanks.
im trying to make an art gallery site for my sister with free hosting, i need upload_max_filesize to be at least 3mb ive tried many free hosting services and they are all 1.5mb ive tried changing it with .htaccess files and php.ini files, seems the free hosts are cracking down on that stuff does anyone know of a free hosting service that has at least 3mb upload_max_filesize? or perhaps someone knows of a service where it can be changed with php.ini files or .htaccess files Hi guys, hoping you can help. Iv recently moved a site from one server to another. Needless to say this site encountered a few errors when the move was done. I believe i have corrected most of these errors but now it is as though the mysql data base isnt connecting correctly with the site. I can see the category's on the site but when i click on a category the products do not display. Its almost as though the info is not being pulled through from the data base. Im at a complete loss! It was originally on a site running MYSQL5.0.92 old and the new site is running 5.1.56 new.Not sure if that makes a difference. Any help greatly needed/appreciated Dear All, I am having 2 different DB on 2 different hosts. I am running MySQL Server on my local PC where the user is entering data in the tables. I have a website which has the identical DB on the web. I am able to connect to the database by using the codes on the server. I want to update the server DB with the local system DB by running one update command. I get the error "-SELECT command denied to user 'localusername'@'localhost' for table 'pst_data'" Given below is the code used for the process : //connecting the remote system DB $link = mysql_connect('IPAddress:3306', 'remoteusername', 'Password'); if (!$link) { die('Not connected : ' . mysql_error()); } $db_selected = mysql_select_db('remotedb', $link); if (!$db_selected) { die ('Can\'t use Remote System DB: ' . mysql_error()); } //connecting the local database on the webstite $weblink = mysql_connect("localhost","localusername","password"); if (!$weblink) { die('Not connected : ' . mysql_error()); } $webdb_selected = mysql_select_db('localwebdb', $weblink); if (!$webdb_selected) { die ('Can\'t use WebServer Database : ' . mysql_error()); } //query to fetch the records from remote ystem and insert into local website database $upd_Query=mysql_query("INSERT INTO localwebdb.`table` SELECT * FROM remotedb.`table` where field=' some condition' "); --------------------------------------------------- I have tested that I have connected the remote DB by running queries on the webserver. Could anyone bail me out so that i can copy the DB from remote to local Any help would be appreciated Hello, I am looking for a push in the right direction. I would like to be able to view a website that is duplicated on many servers by specifying the IP address. Similar to how one would use the hosts file. I can do this using netcat nc 1.2.3.4 80 Host: example.com GET /contact-us.html <CR><CR> Can someone tell me how I would go about porting this to PHP? I would just like to set up a small page on my webserver where I can enter the domain and IP address and have the page displayed back to me. Thanks Colin Hi guys. This is my first question on phpFreaks (the other 900+ posts I've made were always an attempt to help someone else) Here's the issue: when using gethostbyaddr($_SERVER['REMOTE_ADDR']) on a local machine (current using MAMP on OS X) the name returned is not the first entry in my /etc/hosts file. (On php.net there's another person also commenting on this and saying that apparently gethostbyaddr() selects a random entry from the file.) This is not really an issue, since everything will work fine on my FreeBSD production server where each IP address has only one DNS record (I'm building the company's intranet, so I know exactly what's in our DNS tables) but I'm curious to know if anyone has had the same issue/problem and if there's a way around it. (Logic/Common sense tells me the first record should be the one returned) Currently I have the following information in my /etc/hosts file: Code: [Select] 127.0.0.1 localhost 127.0.0.1 iSy 255.255.255.255 broadcasthost ::1 localhost fe80::1%lo0 localhost # Other names for testing purposes 127.0.0.1 name1.blablabla.com 127.0.0.1 name2.blablabla.com 127.0.0.1 name3.blablabla.com 127.0.0.1 name4.blablabla.com 127.0.0.1 name5.blablabla.com 127.0.0.1 name6.blablabla.com 127.0.0.1 name7.blablabla.com 127.0.0.1 name8.blablabla.com the value returned is always line 8: name2.blablabla.com. If I comment out that line, then it moves 'randomly' to line 12: name6.blablabla.com and sticks with it even if I shut down the servers and then boot up again. any ideas? cheers. Hi, I'm thinking about finding a free host and using a free sub domain to build and test the php-database stuff... Along with learning php and mysql stuff I've already got a lot of the php stuff setup but my file paths are all wrong. Is there anything I should do while I'm building this part of my site to make sure it still works when I move it to a permanent home ? So far I know that I shouldn't use the full path but instead something like assets/php/reallycomplex.php Once its complete and I have all of my info in the database my plan is to move to a real host and get a real domain name instead of the sub domain. Are there any other things I should know? Thanks for the advice. Is it possible to use a 'SELECT FROM' against a query in a new query? For example (and I know this would be bad practice but it is just a simple example so I can understand!!!), if you had a table called 'staff' with this sort of set up ID | NAME | SEX | AGE | DEPARTMENT and this query $staffquery = SELECT * FROM staff would it be possible to then use $males = SELECT * FROM $staffquery WHERE sex = 'Male' $females = SELECT * FROM $staffquery WHERE sex = 'Female' $males_in_despatch = SELECT * FROM $staffquery WHERE sex = 'Male' AND department = 'Despatch' or would I have to run the full query each time? The example I have given is not a good one as it only queries one table anyway but if it was querying several joined tables then it would obviously be a lot of repeated code. I am trying to set up a page which does various counts and sums from a query that links several different tables and I am trying to work out the best way to set it all up before worrying about actually getting the data. I can post the full query that I am actually using and some sample data if required. Thanks in advance Steve Hey all. I'm using this sort of thing to query with my application: Code: [Select] try { $stmt = $this->db->prepare($sql); /* Bind parameter if id was passed, ensure it's of integer type */ if(!empty($id)) { $stmt->bindParam(":id", $id, PDO::PARAM_INT); } $stmt->execute(); $results = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); return $results; } catch(Exception $e) { die($e->getMessage()); }which has been working out great, with the only annoyance that sometimes, I need to run a query and I know I'm supposed to get only one row. However, I have to access associated elements via $results[0]['fieldName']. How do I run a query to return exactly one result so I can just use $results['fieldName']? I have put together a query which is designed to display a single question from a database. However, it currently displays all the questions (and notes and category). The problem is I cant work out how to get it to display just the qid I am querying. This should display phpquestion.php?qid=2 but it just displays all the question as does phpquestion.php?qid=7 etc Code: [Select] ini_set('display_errors', 1); error_reporting(-1); $query = "SELECT * FROM questions"; if(isset($_GET['question'])) { $question = $_GET['question']; $query .= " WHEN qid is '$qid' LIMIT 0, 1"; } $result = mysql_query($query); while($row = mysql_fetch_assoc($result)) { $question = $row['question']; $notes = $row['notes']; $category = $row['category']; $qid = $row['qid']; echo "$question | $notes | $category </br> "; } if ($_GET['qid'] == $qid ) { echo 'Sorry, this question is not available. Please visit our <a href="http://www.ukhomefurniture.co.uk">Homepage</a>.'; } function sanitizeString($string) { return mysql_real_escape_string($string); } $question = sanitizeString($_GET['qid']); $query .= " WHERE question is '%$qid%'"; // close connection mysql_close(); ?> Hi everyone. I'm a query very similar to the one below with no success. Unfortunately SQLs and joins are not my strong suit. Code: [Select] SELECT f.field1, f.field2, f.field3 FROM fields_table f WHERE f.field1 = SOME_VALUE LEFT JOIN fields_table s ON s.field2 > f.field2 AND s.field3 <= f.field3 LIMIT 1 I would like the first SELECT query to be returned even if there are no matches on the join, also I'd like the second table query to be limited to 1. Is this possible? Could anyone revise the table above to make this work? Thanks! SELECT COUNT( City ) AS Hotel, City, CountryName, Country FROM `activepropertylist` WHERE MATCH(city,Countryname) AGAINST ('South shields*' IN BOOLEAN MODE) GROUP BY City,Countryname,Country ORDER BY City LIMIT 15hi all I have a query against the database table which uses the full text index's and I am limiting this to 15 rows for the ajax problem is it is returning Africa and other things before south shields is there something I am missing as I know South shields is in there when scrolling through all the results here is my query Hi, I'm very new to PHP and have managed to get through most of the problems I've encountered so far, but I have got to one point that I can't seem to solve. I have two mysql tables (Categories & Products), I have a page that shows the categories (generated from the categories table) and when a category is selected it lists the products in that category. Due to stock etc. not all categories always have products associated to them. The Category & Product Tables are automatically updated, so what I need to do is only show categories that have products associated to them, both tables have a column category_no, and nothing I've tried so far seems to work. The code I have so far is:- Code: [Select] Require_once('config.php'); Mysql_connect(db_host, db_user, db_password); @mysql_select_db(db_database) or die( "unable to select database"); $query="select * from categories"; $result=mysql_query($query); $num=mysql_numrows($result); Mysql_close(); Thanks Pete Here is where I'm starting: Code: [Select] SELECT * FROM wp_usermeta WHERE meta_key = 'wp_1_s2member_custom_fields' AND meta_value LIKE '%3%' As the PHP produces the page, I'm going to have 15 different options coming from the Code: [Select] meta_value LIKE part. I'm assuming I can set up my 15 different DIVs, each with their own IF statement involving the meta_value. Right? I'm not going to have to have 15 different queries, am I? I assume it would start like this: Code: [Select] $query = 'SELECT * FROM wp_usermeta WHERE meta_key = "wp_1_s2member_custom_fields"'; $results = mysql_query($query); while($line = mysql_fetch_assoc($results)) But from there, I don't know if it's possible to deal with partial data with IF statements. I have three tables: events, orderdetails & orders. First I query orderdetails to find all the records that match the EventID: $query1 = SELECT * FROM orderdetails WHERE EventID = $_SESSION['EventID']; This returns 4 records. These 4 records have a field called DetailOrderID which is the foreign key for orders.OrderID. Next I need to query the results of the first query to find all the records in the orders table that match up. For example: SELECT * from orders where $query1.DetailOrderID = orders.OrderID. How would I go about doing this? I'm head down the temporary table solution but wanted to through this one out for discussion before I invest too much time. Hi guys, I need help in my code, it states 'Error querying database' when I set $result = mysql_query($query, $dbc). And strange thing happens when I switched $query and $dbc place, and I got a different error msg $result = mysql_query($dbc, $query). 'Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in D:\inetpub\vhosts\championtutor.com\httpdocs\report.php on line 31 Error querying database' Any idea what is happening? Below is my code Lastly, do you guys have any debug tool software to recommend, so that it can assist me in debugging my code. Thanks <?php $first_name = $_POST['firstname']; $last_name = $_POST['lastname']; $when_it_happened = $_POST['whenithappened']; $how_long = $_POST['howlong']; $how_many = $_POST['howmany']; $alien_description = $_POST['aliendescription']; $what_they_did = $_POST['whattheydid']; $fang_spotted = $_POST['fangspotted']; $email = $_POST['email']; $other = $_POST['other']; $dbc = mysql_connect('*******', '*******', '*******', '*******') or die('Error connecting to MySQL server.'); $query = "INSERT INTO aliens_abduction (first_name, last_name, when_it_happened, how_long, " . "how_many, alien_description, what_they_did, fang_spotted, other, email) " . "VALUES ('$first_name', '$last_name', '$when_it_happened', '$how_long', '$how_many', " . "'$alien_description', '$what_they_did', '$fang_spotted', '$other', '$email')"; $result = mysql_query($query, $dbc) or die('Error querying database.'); mysql_close($dbc); echo 'Thanks for submitting the form.<br />'; echo 'You were abducted ' . $when_it_happened; echo ' and were gone for ' . $how_long . '<br />'; echo 'Number of aliens: ' . $how_many . '<br />'; echo 'Describe them: ' . $alien_description . '<br />'; echo 'The aliens did this: ' . $what_they_did . '<br />'; echo 'Was Fang there? ' . $fang_spotted . '<br />'; echo 'Other comments: ' . $other . '<br />'; echo 'Your email address is ' . $email; ?> Is there a way to query some information depending on if a table field DOES NOT include a specific value? I've got a table that contains over 100 locations. I want to organize the data on the frontend by country (specifically US and International). How would I go about filtering out locations that DO NOT belong in USA? $q = "SELECT * FROM table WHERE COUNTRY='USA'"; Hi all, I am currently storing dates and times for certain events in the following format: $now= date('Y-m-d H:i:s'); This variable is then stored in a MySQL field of type DATETIME. I am looking for a way to query the database to return all results in a certain month, or within a certain time range, or a certain year etc. How would this be achieved? e.g. If I wanted to select everything for the year 2009, would it be: SELECT * FROM table WHERE date BETWEEN '2009-01-01 00:00:00' AND '2009-12-31 11:59:59' ? Thanks! <?php include 'core/classes/Query.php'; include 'core/functions/recaptchalib.php'; $sqlQ = "SELECT * FROM `servers`"; $qResult = $database->query($sqlQ); $i = 0; while ($row = $qResult->fetch_assoc()) { $query = new Query($row['address'], $row['query_port'], $row['engine']); $info = $query->query(); if(!$info) { $info = $query->return_false(); } $details = array( 'players' => $info['players'], 'details' => $info['details'] ); $details = json_encode($details); $update = $database->prepare("UPDATE `servers` SET `status` = ?, `online_players` = ?, `maximum_online_players` = ?, `map` = ?, `details` = ?, `cachetime` = unix_timestamp() WHERE `server_id` = {$row['server_id']}" $update->bind_param('sssss', $query->status, $info['general']['online_players']['value'], $info['general']['maximum_online_players']['value'], $info['general']['map']['value'], $details) $update->execute(); } ?>What I'm trying to accomplish is query every server & update every one of the rows for each server listed. This does nothing ( its a cronjob , as it has to run every 5 minutes , newbie so not entirely sure if this is event the right approach ) I've been trying to fix this piece of script so i can query the results from a database. What i want to do is to display the results from the database like below: Product Heading price Subproduct - $price Each item would have a check box next to them. I have managed to display the items but not the prices. I've looked over the code several times but i'm lost on what i should do. Anyway here's the code, i hope someone here can view it and let me know what i'm doing wrong or what i'm not doing. <?php $get_cats = "SELECT * FROM sub_service WHERE industry='$industry'"; $run_get = mysql_query($get_cats) or die(mysql_error()); $tmp = array(); $x=1; while($rw = mysql_fetch_assoc($run_get)){ if (!array_key_exists($rw['service'],$tmp)) { $tmp[$rw['service']] = array(); } $tmp[$rw['service']][] = $rw['sub_service']; } foreach ($tmp as $service => $items) { ?> <div id="industry_wrapper"> <h2><?php echo $service ?></h2> </div> <div id="select_all_holder"> <div id="select_all_input"> <input type="checkbox" class="toggleElement" name="toggle" onchange="toggleStatus()" /> </div> <div id="select_all_txt"> <p>Select All Services - $</p> </div> </div> <?php echo' <div class="service_holder"> <table width="650" cellpadding="0" cellspacing="5"> '; foreach ($items as $cat) { ?> <tr> <td width="28" align="center"><input type="checkbox" /></td> <td width="605"><p><?php echo $cat ?> - $<?php echo $tmp['price']; ?></p></td> </tr> <?php } echo'</table></div>'; } ?> |