$chars = " \t\n\r\0\x0B";
$pattern = '('.implode('|',array_map('preg_quote',array('<p>','</p>','<br />','<br>'))).')'."\b";
$data = trim(preg_replace('~'.$pattern.'$~i','',preg_replace('~^'.$pattern.'~i','',trim($data,$chars))),$chars);
That code is set to remove all <p>,</p>,<br> and <br /> from the beginning and end of a html string. But it is no working. Any ideas?
Hi Everyone! I have a form where I've got three checkboxes like this:
<td>Wireless <input type="checkbox" name="services[]" value="wireless" /></td>
</tr>
<tr>
<td>Cellular <input type="checkbox" name="services[]" value="cellular" /></td>
</tr>
<tr>
<td>Security <input type="checkbox" name="services[]" value="Security" /></td>
<input type="submit" name="submit">
and then I extract($_POST), and have this code
$comServices = implode(",", $services);
but I get an error:
Warning: implode() [function.implode]: Invalid arguments passed in ..
does anyone know why Im getting this error?
Hi all,
I just started with the version 3 of the Kohana Framework.
I have worked a little with the $_has_many etc.
Now I have the table pages. The primary key is pageID. The table has a column called parentPageID. Now I want to make a ORM model who, when accesed like this $page->parent->find() returns the page identified by parentPageID.
I have the following already:
// Settings
protected $_table_name = 'pages';
protected $_primary_key = 'pageID';
protected $_has_one = array(
'parent' => array(
'model' => 'page',
'foreign_key' => 'parentPageID',
),
);
But that does not work, it simply returns the first page from the table. Last query says this:
SELECT `pages`.* FROM `pages` ORDER BY `pages`.`pageID` ASC LIMIT 1
Does somebody know how to solve this?
I know this can: $parent = $page->parent->find($page->parentPageID); but it must be and can be cleaner (I think).
I have stored 6 records in mysql db,when i use this code each of the 6 records getting displayed in seprate drop down box,i want them to be displayed in a single drop down box.Where am i going wrong?
Any help ii be appreciated. Thnx in advance.
http://dpaste.com/hold/180077/
PDO apparently has no means to count the number of rows returned from a select query (mysqli has the num_rows variable).
Is there a way to do this, short of using count($results->fetchAll()) ?
Hi,
I am having problems creating a thumbnail from an uploaded image, my problem is
(i) the quality
(ii) the crop
http://welovethedesign.com.cluster.cwcs.co.uk/phpimages/large.jpg
http://welovethedesign.com.cluster.cwcs.co.uk/phpimages/thumb.jpg
If you look the quality is very poor and the crop is taken from the top and is not a resize of the original image although the dimesions mean it is in proportion.
The original is 1600px wide by 1100px high.
Any help would be appreciated.
$thumb =
$targetPath."Thumbs/".$fileName;
$imgsize =
getimagesize($targetFile); $image =
imagecreatefromjpeg($targetFile);
$width = 200; //New width of image
$height = 138; //This maintains
proportions
$src_w = $imgsize[0]; $src_h =
$imgsize[1];
$thumbWidth = 200; $thumbHeight =
138; // Intended dimension of thumb
// Beyond this point is simply code.
$sourceImage =
imagecreatefromjpeg($targetFile);
$sourceWidth = imagesx($sourceImage);
$sourceHeight = imagesy($sourceImage);
$targetImage =
imagecreate($thumbWidth,$thumbHeight);
imagecopyresized($targetImage,$sourceImage,0,0,0,0,$thumbWidth,$thumbWidth,imagesx($sourceImage),imagesy($sourceImage));
//imagejpeg($targetImage,
"$thumbPath/$thumbName");
imagejpeg($targetImage, $thumb);
chmod($thumb, 0755);
Hi, I have the following code at the moment:
$ip = '195.72.186.157';
$xmlDoc = new DOMDocument();
$xmlDoc->loadXML(file_get_contents('http://www.geoffmeierhans.com/services/geo-locator/locate/?ip='.$ip.'&output=xml'));
foreach($xmlDoc->getElementsByTagName('city') as $link) {
$links = array('text' => $link->nodeValue);
}
$city = $links['text'];
echo $city;
Is there a better way to get the city variable? Since there is only one tag called city a loop isn't really needed but I can't get it to work any other way
I have a form.The user enter the data ,the data will be stored in the data base.
Now,using phpmysql,i need to display the whole data present in db to front end.The user will click a particular thing and make some modifications and if,he press update the data should get into database.
Give me a snippet
http://dpaste.com/hold/178740/
Hay All,
I cant seem to get my head around this dispite the number to examples i read. Basically I have a 2d array and want to insert it into MySQL. The array contains a few strings.
I cant get the following to work...
$value = addslashes(serialize($temp3));//temp3 is my 2d array, do i need to use keys? (i am not at the moment)
$query = "INSERT INTO table sip (id,keyword,data,flags) VALUES(\"$value\")";
mysql_query($query) or die("Failed Query");
Thanks Guys,
Anyone have any idea why shuffle() would only return 1 item?
when using:
$array2 = shuffle($array1);
with the following array($array1):
Array
(
[0] => 1
[1] => 5
[2] => 6
[3] => 7
[4] => 8
[5] => 10
[6] => 11
[7] => 12
[8] => 13
[9] => 14
)
The output of:
print_r($array2);
is simply: 1
Any idea as to why it would not only not shuffle the array, but knock off the remaining 9 items in the array?
thanks!
I need to get previous 30 days from a specific date which is available from database(eg: 2010-05-23 12:36:29).I am try it by using
date('d', strtotime("-30 days"))
Which is getting the currect answer what i looking for but it is not help me to enter date from database.Please help me to solve the issue.
I'm trying to trim some youtube URLs that I am reading in from a playlist. The first 3 work fine and all their URLs either end in caps or numbers but this one that ends in a lower case g is getting trimmed one character shorter than the rest.
for ($z=0; $z <= 3; $z++)
{
$ythref2 = rtrim($tubeArray["feed"]["entry"][$z]["link"][0]["href"], '&feature=youtube_gdata');
The URL is http://www.youtube.com/watch?v=CuE88oVCVjg&feature=youtube_gdata .. and it should get trimmed down to .. http://www.youtube.com/watch?v=CuE88oVCVjg but instead it is coming out as http://www.youtube.com/watch?v=CuE88oVCVj.
I think it may be the ampersand symbol but I am not sure.
I get this error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order (total, addy, cc) VALUES ('798' , '123 sadf' , '12124123')' at line 1
$total = addslashes(($_SESSION['total']));
$addy = addslashes(($_POST['addy']));
$cc = addslashes(($_POST['cc']));
echo "$total";
echo "$addy";
echo "$cc";
mysql_query("INSERT INTO order (total, addy, cc) VALUES ('$total' , '$addy' , '$cc')") or die(mysql_error());
help plz =]
Currently I'm leveraging http://developer.yahoo.com/search/content/V1/termExtraction.html which isn't ideal for performance and quality reasons. Before I embark on spending time on writing a system I wanted to see if there are any other available options that can do the trick.
Hello,
I have array
$list = array('string1', 'string2', 'string3');
Now i want to get the index of the value string2 i.e 1 and 2 for string3
All i want is the position of the strings in the array
string1 in 0
string2 in 1
string3 in 2
positions
How to get this ? i used array_search but it is no use !
please help !
I m using Sharedbook api to generate a memory book, although it's working perfect, but font of the memory book is unchangeable ...means i can't change the font family of that book.
I tried to change the font then it display error.
please suggest me how to change Font of that memory book..
Thank is advance
is_array($src2->crit) is generating an "Undefined property: stdClass::$crit" error.
The line throwing the error is:
if(is_array($src2->crit) && count($src->crit) > 0){
$src2->crit is initialized here.
$src2->crit = array();
$src2->crit[0] = new dataSet();
$src2->crit[0]->tblName = $tbl2;
$src2->crit[0]->colName = "ID";
$src2->crit[0]->val = $elm->editID;
When testing $src2->crit with this code.
print("\$src->crit is a ".$src->crit."<br />");
print_r($src->crit); print("<br />");
This is returned.
$src2->crit is a Array
Array ( [0] => dataSet Object ( [tblName] => sExam [colName] => ID [val] => 10 ) )
What am I not seeing/understanding correctly? If print("\$src2->crit is a ".$src->crit."<br />") returns that it is an array then why is is_array($src2->$crit) generating an error?
Hello
Here is one script with out any errors
$url="http://yahoo.com";
$file1 = fopen($url, "r");
$content = file_get_contents($url);
$t_beg = explode('<title>',$content);
$t_end = explode('</title>',$t_beg[1]);
echo $t_end[0];
And here is the same script using a look to check multiple urls and getting errors
for ($j=1;$j<=$i;$j++) {
if ($x[$j]!=''){
$t_u = "http:".$x[$j];
$file2 = fopen($t_u, "r");
$content2 = file_get_contents($t_u);
$t_beg = explode('<title>',$content);
$t_end = explode('</title>',$t_beg[1]);
echo $t_end[0];
}
}
The error is Warning: fopen() [function.fopen]: php_network_getaddresses: getaddrinfo failed: No such host is known. in g:/
What exactly is wrong here?
Hey guys,
i need a method to capitalize every first letter of a word.
This is what i got so far and it is working for almost every string...but it fails on this one "WELLNESS & RENOMME".
// method in stringModify Class
function capitalizeWords($words, $charList) {
$capitalizeNext = true;
for ($i = 0, $max = strlen($words); $i < $max; $i++) {
if (strpos($charList, $words[$i]) !== false) {
$`capitalizeNext` = true;
} else if ($capitalizeNext) {
$capitalizeNext = false;
$words[$i] = strtoupper($words[$i]);
}
}
return $words;
}
// Calling method
$stringModify->capitalizeWords("WELLNESS & RENOMME", " -&");
I hope someone can help me out...i tried for 1,5 hours now and don't have a clue. Thanks in advance for any tips or hints.
Greetz
Paulie
Hi, I am building a site which will require some very limited content management for a client. There are only a few areas of the site which will require the client to be able to update the content themselves.
Would it be better to create a very simple custom admin page for the client to log in and say add a news story etc or would it be best using a fully fledged CMS like Drupal etc which seems overkill to me.
I want to convert this [email protected] to
hello@domain.com
I have tried:
url_encode($string)
this provides the same string I entered, returned with the @ symbol converted to %40
also tried:
htmlentities($string)
this provides the same string right back.
I am using a UTF8 charset. not sure if this makes a difference....
Hi,
I am trying to implement GZIP compression for my website. I copied the below code in my .htaccess file:
ExpiresActive On
ExpiresDefault A604800
Header append Cache-Control "public"
<IfModule mod_deflate.c>
<FilesMatch "\.(js|css)$">
SetOutputFilter DEFLATE
</FilesMatch>
</IfModule>
what happens is when I type username and password the page reloads but still the login form is displayed but session is set. When I refresh the page using ctrl + R the login form goes and the username is displayed. what will be the problem. wwaiting for ur reply.
i am trying to get get the following working nothing is happen when i use the function i am trying to get it to display images
class ItemRes {
//items DB
var $img="";
}
function ShowItemImage($index,$res_a){
if(sizeof($res_a) > $index){
if($res_a[$index] != NULL) {
$cimg = $res_a[$index]->img;
return "<img src='$cimg' width='70' height='70' style='cursor:pointer'></img>";
}
}else{
return "<center class='whitetxt'><strong>Empty</strong></center>";
}
}
$res_array = array();
$idx=0;
$result21 = mysql_query("SELECT * FROM photos WHERE eid='$eid' ORDER BY id DESC") or die (mysql_error());
while ($row21 = mysql_fetch_array($result21)) {
$img_path = $row21['path'];
$obj = new ItemRes();
$obj->img = $img_path;
$res_array[$idx] = $obj;
$idx++;
}
ShowItemImage(0,$res_array)
ShowItemImage(1,$res_array)