Jump to content

spec36

Members
  • Posts

    26
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

spec36's Achievements

Member

Member (2/5)

0

Reputation

  1. One thing I think about often with PHP is that code in general must get re-written a lot. Is there any platform out there that allows you to take already written, proven, open source code and apply it to a web development project. For example,if I need a login script. Can I just call one in, configure as needed, instead of writing the entire thing from the ground up? Does anyone know of something like this, something that can streamline coding/web projects to speed the process up and prevent making mistakes that others have already fixed /hardened in there code? What is recommend for this? Your help is greatly appreciated. Thanks,
  2. Thanks for your time Barand that did the trick.
  3. I have the following xml file called -> test.xml <?xml version="1.0"?> <OrderCollection xmlns:xsd="http://www.org/2009/XMLSchema" xmlns:xsi="http://www.w3.org/2009/XMLSchema-instance"> <Orders> <Order Id="130" Model=" Optimized" CampaignName="Promo" OrderName="1074" CreationDate="2013-05-29T16:30:03.41" StartDate="2013-06-03T04:00:00" EndDate="2014-04-22T03:59:59.997" OrderStatus="Active"> <Client Id="5" ExternalId="5" Name="CNL" /> <Lines> <Line Id="699" Status="Canceled" EstimatedReach="0" Desired="1000" Actual="370" MaxViewings="0" Separation="0"> <Line Id="700" Status="Canceled" EstimatedReach="10830" Desired="1000" Actual="0" MaxViewings="0" Separation="0"> <Line Id="701" Status="Canceled" EstimatedReach="0" Desired="1000" Actual="0" MaxViewings="0" Separation="0"> <Line Id="714" Status="Canceled" EstimatedReach="10830" Desired="1000" Actual="1478410" MaxViewings="0" Separation="0"> <Line Id="908" Status="Active" EstimatedReach="0" Desired="1000" Actual="1520" MaxViewings="0" Separation="0"> <Line Id="916" Status="Canceled" EstimatedReach="0" Desired="1000" Actuals="5260" MaxViewings="0" Separation="0"> </Lines> </Order> </Orders> </OrderCollection> For each <Line> node with a entry that has a status attribute of (Status="Active") I need to list The corresponding ID number. So from the XML above I need to pull out only Line Id="908", since it is the only one with a Status equal to Active. I have so far wrote this PHP code to attempt to accomplish this task. <?php $url = 'test.xml'; $xml = simplexml_load_file($url); foreach ($xml->xpath("//Line/@Status") as $t) { echo $t . PHP_EOL; } ?> The above code will print out all the "Status" attribute values properly from each xml LINE node, but I do not know how to put in a check on the xpath command to see if the @Status is set to active and then echo out, only the corresponding Id attribute (i.e 908 in this case) Any help would be greatly appreciated. Thanks,
  4. Thanks for the responses guys and gals. I figured it out. I had the command in a function, the $year variable was outside the function. Hence, my wacky results. I did not give the function the $year variable as input. Smack me for not posting all the code. Works like a charm now. Thanks, --spec36
  5. I changed the syntax, because I am trying to make it work. I want what is in the variable to be part of the grep command. If you are referring to the change from file.txt to data.txt that was an error, but it doesn't matter what the file name is anyways for the sake of the example.
  6. Thanks for the response Christian. I have tried to concatenate the variable, but it does not work example: $cmd = shell_exec('cat data.txt | grep -i'.$year.' -B 1 -A 25');
  7. I am playing around with shell_exec and trying to insert a variable into a shell_exec grep, but it is not working. Here is the code that works without the variable $cmd = shell_exec('cat file.txt | grep -i "/11" -B 1 -A 25'); I am trying to do something like this. I have tried multiple different concatenation attempts, but all to no avail. $cmd = shell_exec('cat file.txt | grep -i "/$variable" -B 1 -A 25'); Any help on the proper concatenation or method to make this work is greatly appreciated. Thanks. --spec36
  8. Ok I resolved this by changing my code to the below: $query="SELECT * FROM $dbtable_auctions ORDER BY percent_complete DESC LIMIT 4";
  9. Do you know what I can use instead of group by so the duplicate records will be shown?
  10. Hey I had this issue on my server yesterday, but it was SNMPd that showed locked up. This is what I did to resolve it. 1. cd /var/lock/subsys 2. delete snmp or mysql in your case 3. service snmpd start Looks like this happens when the current running process somehow gets corrupt and then someone tries to restart it, but the PID is already in use by the original process and that is why you get the subsys locked message. Hope this helps.
  11. I am running the following query in my php code. $query="SELECT *, MAX(percent_complete) FROM $dbtable GROUP BY percent_complete DESC LIMIT 4 OFFSET 8"; In the database percent_complete has the following rows. 1. 100 2. 80 3. 50 4. 30 5. 30 6. 30 The query above lists the percent complete values in a table, but for some reason it is not including the 3x 30 (#4,5,6 above) it only shows the first one. I want to be able to show all 3x30's in the table. Examples: I want it to show like this in the table: |100|80|50|30|30|30 But for some reason it is like this: |100|80|50|30 Anyone have any idea as to why the other two 30% records on not showing in the results? Note: Please don't get confused with the LIMIT 4 OFFSET 8 in the query and the example I used. The database has enough records after the 8th record to show 4 in the row. This row should technically be showing |30|30|30|30 on my actual test site. But it just shows |30|. Help would be greatly appreciated. Thanks, Spec36
  12. Thanks Adam. I was using trim before the for loop and it was not working. I added trim directly to the concatenated variable in the for loop and it now works. Thanks for the help everyone.
  13. Thanks for the help. I now have the device name inserting properly into the command, but the command will not run on the server. When I run this code: $lines = file ("/path/to/myfile/devices.txt"); foreach ($lines as $line) { $ipmi_query = 'ipmitool -I lanplus -H ' . $line . '-U username -P password sdr list'; passthru($ipmi_query); } I get an error that says: sh: line 1: -U: command not found Now I know -U is a valid parameter for the ipmitool. When I echo the command ($impi_query) to the screen it shows like this: ipmitool -I lanplus -H device01-name -U username -P password sdr list Notice the line break in the command. I believe this is why the output is saying that "-U command not found". Does anyone know how I can keep that command so it runs on the server as one line instead of two? I don't know why the command is being broken into two line. Thanks for the help,
  14. What is in line # 109 of seller-list-test.php?
  15. I tried to concatenate the string with what you suggested, but it still does not insert the device name from the text file. Example: Putting this code in and concatenating $query = 'ipmitool -I lanplus -H '.$devices.' -U admin -P adminpass sdr list'; If I echo the value of $query below it outputs this using the above structure on the command. ipmitool -I lanplus -H -U admin -P adminpass sdr list Notice the variable should have inserted the value next to the -H, but instead it is just missing from the command? Also, if I echo the output of $devices I do see the proper names listed. So I know the problem is not with reading the file or with the loop, but something with the way the command is being sent to the shell I guess. Any other ideas? Thanks.
×
×
  • 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.