etrader
-
Posts
315 -
Joined
-
Last visited
Never
Posts posted by etrader
-
-
In my php and html code I have lots of whitespace and line breaks between the <tags>. How I can remove all useless whitespace and linebreaks without altering the main text and codes?
-
Thanks for your reply. You mean it is better to query all <div> by individual preg_match as they will work simultaneously? Right?
You mean that getting the body into a string and then analyzing is a step by step process which takes time? OK?
-
I have searched a lot but no information about this aspect. I wonder how much heavy is the process of getting parts of a webpage by preg_match?
But my question is that which of these options are in favor of lighter CPU process:
1. getting each item between specified tags by a preg_match
or
2. First getting the content between <body>, then processing by php tools such as preg_match (again), explode, etc.
Thanks for considering this unusual question
-
Thanks for this. I think my mistake was using $q instead of $_GET['q']
-
Actually, I tried IF ELSE, but it was not successful, probably due to the complicated process. I hope to find a safer way to kill the process upon direct access to search.php; something like die upon direct access for mysql
-
I have search page in the form of search.php?q=query, as the php script calls for other files and a long process. When visiting search.php directly, the value of q is indeed null, and it makes a long loop and use lots of cpu.
How to kill the script or redirect to the main page when visiting search.php?
-
There are different methods to catch links in <a> tag from a webpage. But surprisingly, with none of them I was successful to catch all links from e.g. http://www.amazon.com/Notebooks-Laptop-Computers/b/ref=sa_menu_lapnet6?ie=UTF8&node=565108
All links are captured except a series in the main area; e.g.
-
There is a "PHP ajax cascading dropdown using MySql" at codestips.com/php-ajax-cascading-dropdown-using-mysql/
I want to use this technique but with a XML or array file instead of mysql database, but my knowledge about mysql is very low. How I can modify this code to catch the categories and products from an array, instead of mysql database?
$connect=mysql_connect($server, $db_user, $db_pass) or die ("Mysql connecting error"); echo '<table align="center"><tr><td><center><form method="post" action="">Category:<select name="category" onChange="CategoryGrab('."'".'ajaxcalling.php?idCat='."'".'+this.value);">'; $result = mysql_db_query($database, "SELECT * FROM Categories"); $nr=0; while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $nr++; echo "<option value=".'"'.$row['ID'].'" >'.$row['Name']."</option>"; } echo '</select>'."\n"; echo '<div id="details">Details:<select name="details" width="100" >'; $result = mysql_db_query($database, "SELECT * FROM CategoriesDetails WHERE CategoryID=1"); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "<option value=".$row['ID'].">".$row['Name']."</option>"; } echo '</select></div>'; echo '</form></td></tr></table>'; mysql_close($connect);
ajaxcalling.php is
include("config.php"); $ID=$_REQUEST['idCat']; $connect=mysql_connect($server, $db_user, $db_pass); echo 'Details:<select name="details" width="100">'; $result = mysql_db_query($database, "SELECT * FROM CategoriesDetails WHERE CategoryID=".$ID); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "<option value=".$row['ID'].">".$row['Name']."</option>"; } echo '</select>'; mysql_close($connect);
-
I want to have a multi level dropdown selection tool come out of an array (not database; almost all of available codes on the internet are based on mysql databse). I have an array as each element has this format: "Country | City | ID". Using explode, I want to make a dropdown to choose the country, then choosing the cities of the chosen country. Finally, in a simple search box make action="result.php" to lead to result.php?q=$id
Thanks for your kind attention
-
I have lists of links in different pages. I want to add an option for the visitors to add favorite ones to a list (like add to cart in shopping sites), and finally see the links selected in a page. This is based on the visitor's browser cookies.
What is the simple way to do this (without database). Actually I need a function to save the items in the browser cookies and then retrieve them.
-
I did not see the page. I just found that the server is down (due to 100% CPU usage made by this script), and a huge error page has been created.
-
When I used Amazon API to capture a product details using the well known code (http://www.chipdir.nl/amazon/aws_signed_request.phps), It made this error, and consequently lots of CPU usage which made my server down.
[14-Mar-2011 20:38:01] PHP Warning: simplexml_load_string() [<a href='function.simplexml-load-string'>function.simplexml-load-string</a>]: uestProcessingTime>0.0009990000000000</RequestProcessingTime></OperationRequest> in /home/laptop/public_html/jewelryaccessories.us/amazon.php on line 52
Line 51 - 60 of amazon.php is
// parse XML $pxml = simplexml_load_string($response); if ($pxml === False) { return False; // no xml } else { return $pxml; }
-
This solution is perfect, but is it possible to get the file extension from the downloaded file?
Now we get the extension from the $test string, but if downloading from e.g. file sharing websites, the url may not include the file name. And additionally, if the rar or zip file contains part1 part2, it will be considered as a part of the file name. I think if first downloading the file on the server, we can get the file information, then renaming.
I have explored some codes, but none of them are comparable with your elegantly short idea; this is the reason that I continue this thread.
Thanks
-
wow! works perfectly ... THANKS
-
I have a set of strings come from an array with this structure
New-Name.jpg | http://domain.com/original-name.jpg
How I can download the images from the links to my local machine and rename them (to New-Name.jpg)?
-
I have html files in which, there are lines of urls starting with http:// (simple text, not hyperlink) without a tag. What is the simplest way to extract them?
-
I have html files with this format
..... <!--ImageSection--><div class="image"><!--ImageSection--><div align="top"><b>Image Link</b> <br />http://www.something.com <br />http://www.another_url <br /></div><!--ImageEnd--></div><!--ImageEnd--></div> .....
I tried to get the content of a <div> with this code:
preg_match_all('/<div class=\"image\">\<!--ImageSection-->\<div align=\"top\">([^`]*?)<\/div>/', $html, $imglinks); foreach ($imglinks as $imglink){ echo $imagelink; }
but it returns empty, where did I wrong?
-
I want to select some strings from an array (list of urls) with this code
$pattern = "/books/"; if(preg_match($pattern, $list)) {
I have two questions:
1. When I put "/5" as the pattern (I mean having a term in the url starting with 5), I get this error: Warning: preg_match() [function.preg-match]: No ending delimiter '/' found
2. What if I want to add two if conditions? I mean if the string contains "/books/" and "/5" ?
-
wow excellent solution
-
How to remove the last character of a string if it is "-" ?
In replacing some elements in strings, sometimes "-" remains at the end. How to trim the string by removing "-", if it is at the end of the string?
-
it was my mistake. $filename of the foreach already has "1/files"; so no need to add it
-
I tried to do this with this code
foreach (glob("1/files/*.mp4") as $filename) { $filename1 = str_replace("_", " ", $filename); rename ("1/files/$filename", "1/files/$filename1"); }
but it did not work where did I wrong?
-
Thanks for your kind attention. For example, extracting pdf links from http://www.getfreeebooks.com
Actually, I do not know how to crawl pages throughout a website to catch links
-
Is it possible to extract all links from a website (not a single webpage) by php? I am asking about the general idea, as I wish to customize: e.g. from a specified directory and certain domains only.
Thanks
Removing whitespace from code
in PHP Coding Help
Posted
how to use this code? I have a set of php processes ending to a series of echo for strings.
I put this code at the beginning and at the end of the whole code, but no effect