Jump to content

spec36

Members
  • Posts

    26
  • Joined

  • Last visited

Everything posted by spec36

  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.
  16. I am trying to execute a command line tool, but am having a problem adding a variable to the line. Here is the code $filename = "devices.txt"; $handle = fopen($filename, 'r'); while (!feof($handle)) { $devices = fgets($handle, 4096); $query = 'ipmitool -I lanplus -H 192.168.1.1 -U admin -P adminpass sdr list'; passthru($query); } flcose($handle); On this line I don't want to have the IP manually added like so. $query = 'ipmitool -I lanplus -H 192.168.1.1 -U admin -P adminpass sdr list'; Instead I want to be able to insert the $devices variable which contains the values from the text file so it would look something like this: $query = 'ipmitool -I lanplus -H $devices -U admin -P adminpass sdr list'; Problem is the command line tool does not run this way. How do I properly add the $devices variable so the command line tool ipmitool will run with its value? Thanks,
  17. I changed the line to this and it now works. <tr><td>Username: </td><td><input size="20" type="text" name="username" <?php if ($_POST){ echo "value =" . "\"" . $user . "\"" ;}?>/></td></tr> Thanks
  18. I am building a login script to help myself learn php. I currently have the script posting any registration form errors to the registration page. I am trying to make sure whatever the user has typed into the form will redisplay once they receive the error to prevent them from having to fill out the registration form again. I got it working, but there is an extra character "/" after what was entered by the user. Here is an example: Note: "1234" has been entered into username field on reg form. <tr><td>Username: </td><td><input size="20" type="text" name="username" <?php if ($_POST){ echo "value =" . $_POST['username'] ;}?> /></td></tr> I get this output 1234/ I do not know where the "/" is coming from. It should only be putting "1234" back into the username field. Any help would be great.
  19. Solved this by adding ^ for start off. preg_match("^ab/i", $data)
  20. I have a dns zone file that looks like this ;########AB####### AB1501 IN A 192.168.0.1 AB1502 IN A 192.168.0.1 AB1502 IN A 192.168.0.1 AB1502 IN A 192.168.0.1 I want to be able to cut out just the AB1501, AB1502, etc... as the names will be inserted into a database. I am using this preg_match command in a if statement preg_match("ab/i", $data) $name = substr($data, 0, 4); but my output also includes the ### line, so it looks like this ;### N AB1501 AB1502 AB1503 ;### N I need to not include the ";### N" lines. How can I exclude them in my preg_match statement? Any help would be greatly appreciated. Thanks
  21. Look up LEFT JOIN in the mysql manual that corresponds to your mysql version. I think that will explain what you are trying to do.
  22. Thanks for the info Joel. Your code gave me a clear idea about how to go about this, but turns out the database has two inserts before that html I posted that contains <br>. So two <br>'s are posted to the table and then all the other records follow what I posted.
  23. Thank you so much for the help guys/girls. When I run this code: /* An extension to your code */ $visitor = $visitor->find('td','1')->find('a','1')->innertext . "<br>"; I receive this error message when running the script Fatal error: Call to a member function find() on a non-object in C:\Program Files\EasyPHP-5.3.8.0\www\nhl\index.php on line 42 This error seems to be happening , because of the extra ->find and ->innertext that was added to the statement. I didn't know you could extend the statement like that, it is very cool, but must need to be written differently. Any ideas?
  24. I'm trying to learn writing php scripts with html-simple-dom. I am scrapping my website with html-simple-dom and the below code, but I am running into an issue with inserting the scrapped data into my database. This code scraps the website and grabs the html data I want. $ret = $html->find('table[class=data] tr'); foreach($ret as $visitor){ $visitor = $visitor->find('td','1') . "<br>"; $insert="INSERT INTO $dbtable (visitor) VALUES ('$visitor')"; mysql_query($insert) OR die(mysql_error()); } But this is being inserted into the database "visitor" field. <td colspan="1" rowspan="1" style="text-align: left;"><a style="border-bottom:1px dotted;" onclick="loadTeamSpotlight(jQuery(this));" rel="HEN" href="javascript:void(0);">HENRY</a></td><br> I only want "HENRY" to be extracted out of the html code above and inserted into the database table. Any help would be greatly appreciated, as I have been pulling my hair out trying to figure this out. Do I need to use explode or something? Thanks,
  25. Hi Guys, I have the following link to an image that does not display when I point a <IMG SRC tag to it. <img src="http://website.com/c-sc/sc?r=658974&chart=$BOB:MM.TT,uu[305,a]dacayaci[pb20!b50][dd]"> For some reason html is unable to read the above as a link and display the image. The link was taken from the address bar for the webpage that displays the image/chart properly. If I copy the link and paste it into firefox it loads the chart correctly. For some reason HTML is not understanding that I want the full thing to be the link to the image. Any help would be greatly appreciated. Thanks, Spec36
×
×
  • 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.