How can I sort this array by city or by id in descending order?
if ($num > 0 ) {
$i=0;
while ($i < $num) {
$city = mysql_result($result,$i,"city");
$state = mysql_result($result,$i,"state");
$id = mysql_result($result,$i,"id");
echo "$city";
echo "$state";
++$i; } } else { echo "No results."; } ?>
open_basedir restriction in effect. File(/var/www/vhosts/domain.com) is not within the allowed path(s): (/var/www/vhosts/domain.com/httpdocs:/tmp)
How do I securely fix this? This is preventing me from listing and creating directories outside of the current directory. What I mean by securely is that I don't want to remove a piece of code from a configuration file and potentially make it easier for hackers to do whatever.
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 have a problem with the curl. I watched an old post Remote Login not Working With Curl, but it not work. I followed baba's advice but the code enter in the if statement. Sorry for my bad english. Can anyone help me?
This is the code:
$url="http://hipfile.com/";
$urllog="http://hipfile.com/login.html";
$postdata = "login=bnnoor&password=########&op=login";
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");
curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_REFERER, $urllog);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt ($ch, CURLOPT_POST, 1);
$result = curl_exec ($ch);
if (!$result) {
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch); // make sure we closeany current curl sessions
die($http_code.' Unable to connect to server. Please come back later.');
}
echo $result;
curl_close($ch);
class Crypt_Data {
protected $_mcrypt=null;
protected $_iv=null;
protected $_key=null;
public function __construct() {
$this->_mcrypt = mcrypt_module_open('rijndael_256', '', 'cbc', '');
$key_size = mcrypt_enc_get_key_size($this->_mcrypt);
for($i=0;$i<$key_size;$i++) $test_key .= "0";
$this->_iv = $test_key;
$this->_key = $test_key;
mcrypt_generic_init($this->_mcrypt,$this->_key,$this->_iv);
}
public function dataEncrypt($data) {
return base64_encode(mcrypt_generic($this->_mcrypt, $data));
}
public function dataDecrypt($data) {
return mdecrypt_generic($this->_mcrypt, base64_decode($data));
}
}
$crypt = new Crypt_Data();
$string = "encrypt me";
$encrypted = $crypt->dataEncrypt($string);
echo $encrypted."<BR>";
$decrypted = $crypt->dataDecrypt($encrypted);
echo $decrypted."<BR>";
output:
JJKfKxZckkqwfZ5QWeyVR+3PkMQAsP0Gr1hWaygV20I=
qÌÌi_ÖZí(®`iÜ¥wÝÿ ô0€Í6Ÿhf[%ër
No idea why this isn't working, everything seems to be fine on my end.. i tried decrypting it with mcrypt_cbc(); and it decrypted it properly.. so it has something to do with my mdecrypt_generic.. any ideas?
I'd like to "grab" a few hundred urls from a few hundred html pages.
Pattern:
<h2><a href="http://www.the.url.might.be.long/urls.asp?urlid=1" target="_blank">The Website</a></h2>
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)
Hey everybody,
I'm currently re-writing a class which handles xml files.
Depending on the xml file and it's structure I sometimes need to merge objects.
Lets say once I have this:
<page name="a title"/>
And another time I have this:
<page name="a title">
<permission>administrator</permission>
</page>
Before, I needed only the attributes from the "page" element. That's why a lot of my code expects an object containing only the attributes ($loadedXml-attributes()).
Now there are xml files in which the
<permission>
element is required.
I did manage to merge the objects (though not as I wanted) but I can't get to access one of them (most probably it's something I'm missing).
To merge my objects I used this code:
(object) array_merge(
(array) $loadedXml->attributes(),
(array) $loadedXml->children()
);
This is what I get from print_r():
stdClass Object (
[@attributes] => Array ( [name] => a title )
[permission] => Array ( [0] => administrator )
)
So now my question is how to access the @attributes method ?
Thanks in advance,
The Devil
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.
Is it possible to send a complexType to a SOAP web service by creating the complexType locally, i.e. create the type by creating a class and then sending the instance of that class back to the service? Admittedly this is only possible if I can get the definition of the type from the service provider.
I'm looking to send a complexType back to a web service. So if this approach wont work please suggest an alternative...
hi, i have wrote a script to produce an array of data but now want to display in order of score. The array outputs as follows;
[display_name] => Array
(
[0] => ACT_Web_Designs
[1] => user1_design
[2] => user2_design
)
[proffesion] => Array
(
[0] => Web Developer
[1] => web developer
[2] => Web Developer
)
[score] => Array
(
[0] => 15
[1] => 6
[2] => 15
)
[img] => Array
(
[0] => ./?0000=gif&0001=3fadb8c362ff39f3322909899ff14760&0002=prof_pic
[1] =>
[2] =>
)
so in a nutshell I am wanting it to be converted as follows;
[display_name] => Array
(
[0] => ACT_Web_Designs
[1] => user2_design
[2] => user1_design
)
[proffesion] => Array
(
[0] => Web Developer
[1] => web developer
[2] => Web Developer
)
[score] => Array
(
[0] => 15
[1] => 15
[2] => 6
)
[img] => Array
(
[0] => ./?0000=gif&0001=3fadb8c362ff39f3322909899ff14760&0002=prof_pic
[1] =>
[2] =>
)
I have been looking at asort() but cant get anything to work. any help would be much appreciated.
Hello
I`ve been wondering how to implement methods in a class.
Could someone explain me what means if one does OOP in procedural style?
Here is an example:
class Fld extends Model {
private $file;
private $properties = array();
public function init($file) {
$this->file = $file;
$this->parseFile();
}
private function parseFile() {
// parses the file
foreach($this->file as $line)......
..................
$this->properties = $result;
}
}
I mean is it a good thing to have methods like these that do operations for the class properties like that. Or should I pass the class property as method parameter...
I mean this would cause error if the file property wouldnt be declared.
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
Hi all,
I am trying to save data into the same table several times from the same $_POST array. You see, on my registration form a family is allowed to specify the names, gender and age of all members they wish to bring along.
This data is being stored in a database table called aditional_member. Based on family size, I am dynamically generating html table rows where each row has the number of input fields required.
<tr id="additionalmember_3">
<td><input type="text" name="first_name1" maxlength="50" value="" /></td>
<td><input type="text" name="last_name1" maxlength="50" value="" /></td>
td><select name="gender1" value="" ><option value='Male'>Male</option><option value='Female'>Female</option></select></td>
<td><select name="age_group"value="" ><option value='18 to 30'>18 to 30</option><option value='31 to 60'>31 to 60</option></select></td>
</tr>
When I POST, let us say I have three sets of input(3 table rows as above), Is there a simple way to insert into the addional_member table the data from row one, then row two, and so on. I tried looping the insert statement, which failed. I am basically open to suggestions, I do not need to use a table.
Any ideas,
Thank you.
I have the string like this,
$inp1 = "3 doses at 0[0,0], 1-2 and 6 Month[6,1] [3,2])";
in this internally, going to take the values of square bracket. How can i take this values in the square bracket? any function is there to return the string like this
[0,0] [6,1] [3,2]
Thanks in advance for help.
Hi all
I want to create an upload form to upload large files. Thats pretty much easy, however, the upload process itself taks long and basically looks like nothing is happening for a few minutes. So now I'd like to insert a progress bar to show the user that something is happening and they should just sit tight. I've read of numerous methods like APC and certian flash plugins, but my site is hosted on a shared server and I cant install any new applications on it.
I'm thinking, maybe if it is possible to read the size of the temp file it creates via an ajax page. By polling the size every few seconds I should be able to get the progress of the upload. Now the question I pose is...where is the temp file situated?
This is a really weird one. I have some code that is happily working on version 2.1.1RC1 of the php5-imagick module. It's basically just a class I wrote that extends the Imagick class and manages images stored in a database.
Since upgrading to version 3.0.0RC1 (thankfully only on my dev box) things have gone to hell. It seems that object members are writeable but are NOT readable. Take the following sample code:
class db_image extends IMagick {
private $data;
function __construct( $id = null ){
parent::__construct();
$this->data = 'some plain text';
echo $this->data;
}
This will output absolutely NOTHING. My debugger indicates that the contents of $this-data are the correct string value, but I am unable to read the value back out of the member variable.
Seriously. WTF? Does anyone know what is causing this or has seen it before? I don't even know how to replicate this behaviour in my own classes.
Let's say I have a class table. In the class table, there are many students with their pictures. In the first registration, I've registered the class and students with pictures. The pictures were put into a directory like classid_classname. Then, I change the class name. Now, I'm adding the student's picture. Now, the new picture can't be recognized because the class name has changed. The pic url will be set as classid_class(new)name. How can I match the first letter of the directory? This is my update code :
$classID= $_POST["classID"];
$className= $_POST["className"];
$p1 = $_FILES['p1']['name'];
$p2 = $_FILES['p2']['name'];
$p3 = $_FILES['p3']['name'];
$direct = $_POST["className"];
$direct = strtolower($direct);
$direct = str_replace(' ', '_', $direct);
$tfish = $classID."_".$direct; //the directory variable will have new name
because it can't be fetched if the directory has been changed many times//
$file = "slider_imagesClass/".$tfish."/";
$url = "/".$tfish."/";
How can I make the variable to match the first letter of the directory because the classID will not change? Thank you. Really appreciate your help :D
Hi all,
I am creating a news archive for my site and want to create an overview page from the following DB table
id - Unique identifier
newsDate - in a format XXXX-XX-XX
title - News Item title
details - News item
photo - News Item Photo
caption - News Item Photo caption
update - Timestamp for record
The news on the site is current but I hope to add some data from years gone by over the next few months and years.
What I want to do is create a new line for each year and highlight the month which corresponds to a record in the DB table, similar to that below.
2002 JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC
2004 JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC
2005 JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC
2008 JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC
Any help or advice would be much appreciated
Cheers
I'm dying here, any help would be great.
I've got an array that I can sort a-z on the value of a specific key but cannot sort in reverse z-a.
sample of my array which i'd like to sort by ProjectName (z-a):
Array
(
[0] => Array
(
[count] => 1
[ProjectName] => bbcjob
[Postcode] => 53.471922,-2.2996078
[Sector] => Public
)
[1] => Array
(
[count] => 1
[ProjectName] => commercial enterprise zone
[Postcode] => 53.3742081,-1.4926439
[Sector] => Public
)
[2] => Array
(
[count] => 1
[ProjectName] => Monkeys eat chips
[Postcode] => 51.5141492,-0.2271227
[Sector] => Private
the desired results would be to maintain the entire array key - value structure but with the order:
Monkeys eat chips
Commericial enterprise zone
bbcjob
I hope this makes sense