cereal 1,524 Nearly a Senior Poster Featured Poster

There is also the zip command:

zip my_archive -r directory_to_zip/

will create my_archive.zip

cereal 1,524 Nearly a Senior Poster Featured Poster

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!

mehnihma commented: Thanks, overlooked your post +2
cereal 1,524 Nearly a Senior Poster Featured Poster

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());
cereal 1,524 Nearly a Senior Poster Featured Poster

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!

cereal 1,524 Nearly a Senior Poster Featured Poster

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?

cereal 1,524 Nearly a Senior Poster Featured Poster

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
)

http://www.php.net/manual/en/function.asort.php
bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

@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.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hmm, maybe I'm not understanding your question, can you please post your code and spot the problem?

cereal 1,524 Nearly a Senior Poster Featured Poster

This function sorts an array. Elements will be arranged from lowest to highest when this function has completed.

source: http://php.net/manual/en/function.sort.php

cereal 1,524 Nearly a Senior Poster Featured Poster

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.

cereal 1,524 Nearly a Senior Poster Featured Poster

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!

cereal 1,524 Nearly a Senior Poster Featured Poster

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!

cereal 1,524 Nearly a Senior Poster Featured Poster

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);
cereal 1,524 Nearly a Senior Poster Featured Poster

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!

cereal 1,524 Nearly a Senior Poster Featured Poster

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/

cereal 1,524 Nearly a Senior Poster Featured Poster
cereal 1,524 Nearly a Senior Poster Featured Poster

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!

cereal 1,524 Nearly a Senior Poster Featured Poster

Same problem here. By the way, I don't know if this was already the behave: it seems Business Exchange requires log in.

cereal 1,524 Nearly a Senior Poster Featured Poster
cereal 1,524 Nearly a Senior Poster Featured Poster

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.

cereal 1,524 Nearly a Senior Poster Featured Poster

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.

cereal 1,524 Nearly a Senior Poster Featured Poster

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.

cereal 1,524 Nearly a Senior Poster Featured Poster

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
        )

)

http://www.php.net/manual/en/function.end.php
bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

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!

cereal 1,524 Nearly a Senior Poster Featured Poster

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!

cereal 1,524 Nearly a Senior Poster Featured Poster

Use pathinfo(): http://php.net/manual/en/function.pathinfo.php

$file = 'test.jpg';
echo pathinfo($file,PATHINFO_FILENAME);
cereal 1,524 Nearly a Senior Poster Featured Poster
cereal 1,524 Nearly a Senior Poster Featured Poster

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.

cereal 1,524 Nearly a Senior Poster Featured Poster

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.

cereal 1,524 Nearly a Senior Poster Featured Poster

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!

cereal 1,524 Nearly a Senior Poster Featured Poster

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

cereal 1,524 Nearly a Senior Poster Featured Poster

Try this:

$list = array();
while($ids = mysql_fetch_array($sql)){
    $list[] = $ids['id'];
}

print_r($list);

bye!

mmcdonald commented: good shout +1
cereal 1,524 Nearly a Senior Poster Featured Poster

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.

cereal 1,524 Nearly a Senior Poster Featured Poster

You're welcome, if we have finished here mark the thread as solved. Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

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.

source: http://www.php.net/manual/en/image.requirements.php

LastMitch commented: Thanks for explanation! +5
cereal 1,524 Nearly a Senior Poster Featured Poster

Consider also HJ-Split, it's free and cross-platform and works fine.

cereal 1,524 Nearly a Senior Poster Featured Poster

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.

cereal 1,524 Nearly a Senior Poster Featured Poster

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.

cereal 1,524 Nearly a Senior Poster Featured Poster

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'); 
cereal 1,524 Nearly a Senior Poster Featured Poster

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
?>
cereal 1,524 Nearly a Senior Poster Featured Poster

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.

cereal 1,524 Nearly a Senior Poster Featured Poster

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

cereal 1,524 Nearly a Senior Poster Featured Poster

@Garret85 to check if PHP is installed type php -v in the terminal, you will get the version. Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

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!

cereal 1,524 Nearly a Senior Poster Featured Poster

Line 52 you forgot ; at the end of the value: $ans = "Real Glo"; // Answer to image.

Djmann1013 commented: Thanks! It really helped! +2
cereal 1,524 Nearly a Senior Poster Featured Poster

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

cereal 1,524 Nearly a Senior Poster Featured Poster

Ok, you can also add trim() to $name1: ${"name" . $i} = trim($array[$z]); and you can do the same with $val1.

cereal 1,524 Nearly a Senior Poster Featured Poster

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"
cereal 1,524 Nearly a Senior Poster Featured Poster

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

cereal 1,524 Nearly a Senior Poster Featured Poster

Change $array[1] = Hello World; to $array[1] = 'Hello World'; and then it will work, bye :)