There is also the zip command:
zip my_archive -r directory_to_zip/
will create my_archive.zip
There is also the zip command:
zip my_archive -r directory_to_zip/
will create my_archive.zip
Add CURLOPT_RETURNTRANSFER
:
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
And try simplexml_load_string
here:
$xml = simplexml_load_file(utf8_encode($xml_url), 'SimpleXMLElement', LIBXML_NOCDATA);
bye!
Try to change quotes with backticks in the field names of the INSERT statement, as here:
$req = "INSERT INTO $tablename(`$tablecol`) VALUES ('$tablecoldat')";
Also, to catch an error use mysql_error()
at least in this stage:
mysql_query($req, $connection) or die(mysql_error());
Change this:
<?PHP
$username = $_POST['username'];
print($username);
?>
to:
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
$username = $_POST['username'];
print($username);
}
?>
and it should work, bye!
A foreach loop will work:
foreach($ab as $k => $v)
{
echo "$k - $v \n";
}
If you wan to group them in different arrays then use:
$keys = array();
$values = array();
foreach($ab as $k => $v)
{
$keys[] = $k;
$values[] = $v;
}
print_r($keys);
print_r($values);
Or better use array_keys() and array_values():
$ab = array('0'=>'10','1'=>'5','2'=>'8');
$ba = $ab;
asort($ba);
print_r(array_keys($ba));
print_r(array_values($ba));
Ok?
For that you need asort()
:
$ab = array('0'=>'10','1'=>'5','2'=>'8');
$ba = $ab;
asort($ba);
print_r($ba);
And you get:
Array
(
[1] => 5
[2] => 8
[0] => 10
)
@lixamaga it's not safe because a user can disable javascript and submit malicious data, a server side filter, as blocblue suggested, is a necessary requirement.
Hmm, maybe I'm not understanding your question, can you please post your code and spot the problem?
This function sorts an array. Elements will be arranged from lowest to highest when this function has completed.
Yup, it's pretty simple:
<?php
function gravatar($email,$size = 75)
{
$avatar = md5(strtolower(trim($email)));
return '<img class="avatar" src="http://www.gravatar.com/avatar/' .$avatar.'.jpg?d=identicon&s='.$size.'" alt="avatar" />';
}
echo gravatar('random@mail.tld');
?>
It returns an image even if there's no registration there.
Also, since you are querying a specific mID
and then grouping by the same field, it's correct to get just a row. So try to change the GROUP BY
clause. Bye!
Try:
$andy->load_Array(array("andy","bill"));
right now you are sending two arguments, otherwise use func_get_args(): http://php.net/manual/en/function.func-get-args.php
Also instead of var $element
use private|protected|public:
public $element;
bye!
Here there's the example of PHP manual: http://php.net/manual/en/curl.examples-basic.php
<?php
$ch = curl_init("http://www.example.com/");
$fp = fopen("example_homepage.txt", "w");
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);
?>
but you can do the same with file_get_contents() and file_put_contents():
$url = 'http://www.example.com/';
$page = file_get_contents($page);
file_put_contents('example_homepage.txt',$page);
You can use cryptsetup: http://code.google.com/p/cryptsetup/
Here there is a tutorial for external drives:
https://help.ubuntu.com/community/EncryptedFilesystemsOnRemovableStorage
bye!
Hello,
I still didn't tested Laravel but it seems interesting. While searching I've found this blogpost which is enough explanatory, at least in comparison to CI:
http://philsturgeon.co.uk/blog/2012/12/5-things-codeigniter-cannot-do-without-a-rewrite
A good point is the support for composer packages: http://getcomposer.org/
First this is wrong:
if ($sql = $s){
here you are assignin a value, not comparing, to compare use ==
or for boolean ===
, so rewrite it to:
if ($sql == $s){
Second, I don't see $sql
declared anywhere, you will get an error here.
Third, you have to extract the filename from the query:
if(mysql_num_rows($t) > 0)
{
# loop results
while($row = mysql_fetch_object($t))
{
unlink('/path/'.$row->filename); # and extension if this is saved a part
}
header('Location: lee_remove.php');
}
bye!
Same problem here. By the way, I don't know if this was already the behave: it seems Business Exchange requires log in.
Also consider you can get some collisions with rand() and overwrite previously existing files. Add a check for existing files and, in that case, rename the new one again.
You have to add the ServerName directive into the lh-test_site file:
ServerName testsite
DocumentRoot /var/www/test_site
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/test_site/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
then inside /etc/hosts
add:
127.0.0.1 testsite
and run a2ensite as before, it should work.
You can use mod_perl: http://perl.apache.org/
Or CGI: http://httpd.apache.org/docs/2.2/howto/cgi.html
For the second solution edit line 771:
AddHandler cgi-script .cgi .pl
i.e. remove the comment sign # and add .pl
to the handler, then you have to add Options +ExecCGI
inside the block <Directory "C:/Apache Group/Apache2/htdocs">
at line 253.
But these changes can be done at .htaccess level, just check the second link.
Try this:
<?php
$arr = array(
array(
'7'=>'repsol kawasaki honda ktm',
'8'=>'kawasaki honda ktm bmw',
'9'=>'honda ktm bmw ducati',
'10'=>'ktm bmw ducati yamaha'
),
array(
'23'=>'lamborghi ferarri mercedes hyundai',
'24'=>'ferarri mercedes hyundai toyota',
'25'=>'mercedes hyundai toyota nissan',
'26'=>'hyundai toyota nissan renault'
),
);
$z = array();
foreach($arr as $k1 => $v1)
{
$i = 0;
foreach($v1 as $k2 => $v2)
{
if($i == 0)
{
$z[$k1][$k2] = $v2;
}
else
{
$r = explode(' ',$v2);
$z[$k1][$k2] = end($r); # use end() to get last element in array
}
$i++;
}
}
print_r($z);
?>
It will output as requested:
Array
(
[0] => Array
(
[7] => repsol kawasaki honda ktm
[8] => bmw
[9] => ducati
[10] => yamaha
)
[1] => Array
(
[23] => lamborghi ferarri mercedes hyundai
[24] => toyota
[25] => nissan
[26] => renault
)
)
I think $pos_op should go before the statement, because it still doesn't exists and so this will give a boolean FALSE value when you try to send it to mysqli, so try to change the order:
$pos = $_GET['pos'];
$pos_op = $pos + 1;
$adjust = "UPDATE modul_galleri SET pos = pos - 1 WHERE pos = ?";
$ADJUST_PREP = mysqli_stmt_prepare($connection, $adjust);
$ADJUST_STMT_PREP = mysqli_stmt_bind_param($ADJUST_PREP, "i", $pos_op);
bye!
Check the manual: http://www.php.net/manual/en/reference.pcre.pattern.syntax.php
~ is a delimiter, from the manual:
Often used delimiters are forward slashes (/), hash signs (#) and tildes (~)
(.*?) it's a loop to match the contents of href attribute, bye!
Use pathinfo(): http://php.net/manual/en/function.pathinfo.php
$file = 'test.jpg';
echo pathinfo($file,PATHINFO_FILENAME);
You can use xcopy:
xcopy c:\folder d:\ /e
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/xcopy.mspx?mfr=true
bye!
You can boot on recovery mode, you will get a root shell, from which you can use passwd command to assign a new password to the root account. You will not need the old one, from there you can change the other accounts passwords and regain access.
Be aware that there is more then a php.ini file, one for cli, one for apache2. If you have the conf.d directory place the loader there, because this is a directory shared between the two versions. I don't have other ideas, sorry.
Add:
extension=mysql.so
to php.ini or check if there is a mysql.ini file in /etc/php5/apache2/conf.d
and place this directive there, then reload the server:
sudo service apache2 reload
bye!
This is in server side, it depends on php.ini directive upload_tmp_dir or if this is not set, on system configuration. Usually on linux servers this is /tmp
: http://www.php.net/manual/en/ini.core.php#ini.upload-tmp-dir
Try this:
$list = array();
while($ids = mysql_fetch_array($sql)){
$list[] = $ids['id'];
}
print_r($list);
bye!
Create a new group, for example www, change the group of /var/www
directory and add your username, for example garrett, to this group:
sudo groupadd www
sudo usermod -a -G www garrett
sudo chgrp -R www /var/www
from this moment you will have write permissions inside /var/www
.
You're welcome, if we have finished here mark the thread as solved. Bye!
I think he is referring to the PHP graphic library, if so there is no direct relation between JQuery and GD. If you're using a debian based distro then use: sudo apt-get install php5-gd
to install the library, but it should be already included in your PHP installation:
Since PHP 4.3 there is a bundled version of the GD lib. This bundled version has some additional features like alpha blending, and should be used in preference to the external library since its codebase is better maintained and more stable.
Consider also HJ-Split, it's free and cross-platform and works fine.
The only problem I see here is in the raw output of the default code block (double-click on the first block of code), I'm not sure if this is a daniweb bug or if it was already like this, maybe an IDE auto-correction. I'm referring to lines 5 and 9 where I see:
<Directory ></Directory>
and
<Directory /var/www></Directory>
change them with:
<Directory />
<Directory /var/www/>
and it should work. But anyway: the directory in which you have to place the files is /var/www
not /usr/share/apache2/default-site
. So move phpinfo.php to /var/www
as stated in the configuration file.
Check my previous post about Apache config: http://www.daniweb.com/hardware-and-software/linux-and-unix/threads/434267/installing-php#post1864192
Or post what you've done and your configuration file settings. A part that, just place this code inside the script:
<?php
phpinfo();
?>
this function will generate all the layout needed to display the PHP configuration.
The url is requesting for user and password, if this is not your domain maybe it's a counter measure for hotlinking issues. If it's yours domain then just use server path, for example:
$image = imagecreatefromjpeg('/var/www/dev/media/images/nohomepic.jpg');
If you deny direct access then you need a script to display file names and to provide a download option. For example:
<?php
$files = glob('./upload/*.*');
print_r($files); # print array
?>
If you are using Apache web server then use an .htaccess file, with this directive:
order allow,deny
deny from all
put this inside upload directory.
Ok and what happens if you run sudo apt-get update
? If it doesn't work then edit the sources.list file, some information here: http://forums.linuxmint.com/viewtopic.php?p=562087
@Garret85 to check if PHP is installed type php -v
in the terminal, you will get the version. Bye!
Try:
name.strip().isalpha();
.strip()
will remove spaces above and at the end of the string, .isalpha()
will return true/false, you will get false if there is a space in the middle, to avoid that you can add .replace
:
name.strip().replace(' ','',1).isalpha();
bye!
Line 52 you forgot ;
at the end of the value: $ans = "Real Glo"; // Answer to image.
You can use get_browser() function or $_SERVER['HTTP_USER_AGENT'] to read the user agent of the clients and if there is a match with Google bots you will not run the query, something like:
<?php
$browser = $_SERVER['HTTP_USER_AGENT'];
if(!preg_match('/Google[bot]/i',$browser))
{
# insert query here
}
else
{
echo 'bot';
}
?>
the else statement is optional. Here's the list of Google bots user-agents: https://developers.google.com/webmasters/control-crawl-index/docs/crawlers
Ok, you can also add trim() to $name1: ${"name" . $i} = trim($array[$z]);
and you can do the same with $val1.
It works for me, try to use var_dump on $name1: var_dump($name1);
if Hello World is the first of the array, then the problem is this line ${"name" . $i} = $array[1];
because the array starts from 0, using $array[1] in my example $name1 will print How Are You?, so try to change it to ${"name" . $i} = $array[0];
. If you are going to loop then just switch $i to 0.
This is what I've done, raw_data.txt example:
Hello World(.)How Are You?(.)Bless this mess!
script:
<?php
$filename = dirname(__FILE__) . "/raw_data.txt";
$fp = @fopen("$filename", 'a+');
if ($fp){
$array = explode("(.)", fread($fp, filesize($filename)));
}
var_dump($array);
$i = 1;
${"name" . $i} = $array[0];
$val1 = "Hello World";
if ($name1 == $val1){
echo 'yes' . "\n";
}
else{
echo 'no' . "\n";
}
//second try
if ($name1 === $val1){
echo 'yes' . "\n";
}
else{
echo 'no' . "\n";
}
//3'rd attempt
if((string)$name1 === $val1){
echo 'yes' . "\n";
}
else{
echo 'no' . "\n";
}
var_dump($name1);
?>
will output:
array(3) {
[0]=>
string(11) "Hello World"
[1]=>
string(12) "How Are You?"
[2]=>
string(16) "Bless this mess!"
}
yes
yes
yes
string(11) "Hello World"
How the file is read? Can you paste that code? If you use file() function then you get an array of strings: http://php.net/manual/en/function.file.php
Change $array[1] = Hello World;
to $array[1] = 'Hello World';
and then it will work, bye :)