cereal 1,524 Nearly a Senior Poster Featured Poster

Ok, now I see: the page is not complete. If you check the headers you will see that the server returns status code 500:

HTTP/1.1 500 Internal Server Error
Connection: close
Content-Type: text/html
Date: Tue, 11 Mar 2014 17:16:39 GMT
Server: Apache
Transfer-Encoding: chunked
X-Powered-By: PleskLin

You should check the Apache error log, and also the PHP error log. You could also enable the error reporting by adding:

error_reporting(E_ALL);

to the top of page, by reloading the page you should see eventual errors in the script.

If my code works perfectly before. then is the problem is the php compiler on my webhosting sites? or any chenges from the new PHP version? what do you think. this code also run perfectly on my localhost.

Yes, it could be a problem with the hosting configuration if, for example, your version of PHP loads a module that is missing in the hosting version.

cereal 1,524 Nearly a Senior Poster Featured Poster

But the problem now is. I get the error message: 'Unable to select table.'?

You get that because of:

or die( "<p><span style=\"color: red;\">Unable to select table</span></p>");

To get the real error message use mysql_error() after the query:

$result = mysql_query("INSERT INTO festivals (name, logo, country, city, deadline, date_from, venue, date_to, info_page, web, about, open_for, flag)". "VALUES('NULL','$name', '$logo', '$country', '$city', '$deadline', '$date_from', '$venue',, '$date_to', '$info_page', '$web', '$about', '$open_for', '$flag')") or die(mysql_error());
cereal 1,524 Nearly a Senior Poster Featured Poster
cereal 1,524 Nearly a Senior Poster Featured Poster

No problem. Assign the name attribute to the select tag, for example:

<select name="fruits">

So, when the form is submitted you can check the value of $_POST['fruits']. Now, if you submit something like this:

<select name="fruits">
    <option>---</option>
    <option>Apples</option>
    <option>Oranges</option>
    <option>Cherries</option>
</select>

the value of $_POST['fruits'] will be chosen from the content of the option tag, if you select the second option, the value will be Apples. If, instead, you add the value attribute, then this will be considered instead of the text, for example:

<select name="fruits">
    <option value="">---</option>
    <option value="fujiapple">Apples</option>
    <option value="vanillaorange">Oranges</option>
    <option value="pandoracherry">Cherries</option>
</select>

So, in this case, if we choose the first valid option, the value of $_POST['fruits'] will not be Apples but fujiapple.

Multiple Options

If you want to enable multiple choices, then there are few a small changes to apply: add two square bracktes [] to the value of the name attribute, the meaning is that we are going to collect an array of values and not a single string. Then add the multiple attribute. So:

<select name="fruits[]" multiple>

When you receive the POST request, the values will be served as an array:

[fruits] => Array
    (
        [0] => fujiapple
        [1] => pandoracherry
    )

Instead of the traditional:

[fruits] => orange

Note: when submitting a multiple select, the user can deselect all the options, in this case the fruits index will be missing from the $_POST array, as the checkboxes. When using the single select, instead, an option of the …

diafol commented: For going the extra mile :) +14
cereal 1,524 Nearly a Senior Poster Featured Poster

Hello,

can you explain the issue? Currently I see few errors in the first method, as you are not declaring the variables checked by the IF statement.

Also the second method, i.e. addLeads_duplicate(), seems to be truncated. This in particular:

$result=$res->result_array();enter code here

Will generate an error because enter code here must be commented or removed.

cereal 1,524 Nearly a Senior Poster Featured Poster

The error happens because of:

$query = mysql_query( "SELECT * FROM `users` WHERE `user` = '{$uname}'",$con );

You're using $uname instead of $user and for this reason mysql_query() returns boolean FALSE. When in doubt, you should use mysql_error() right after the query:

$q = mysql_query("...") or die(mysql_error());

Consider also that the mysql_* API functions are going to be deprecated and removed soon from PHP, you should use MySQLi or PDO:

But I want to point you to another problem, this:

array_map( 'stripslashes',$_POST );
array_map( 'mysql_real_escape_string',$_POST );

It must be:

$_POST = array_map( 'stripslashes',$_POST );
$_POST = array_map( 'mysql_real_escape_string',$_POST );

Because the array_map will not overwrite the original array, example:

$a = array("hello", "wor\ld");
array_map('stripslashes', $a);

print_r($a);

# output:
Array
(
    [0] => hello
    [1] => wor\ld
)

$b = array_map('stripslashes', $a);
print_r($b);

# output:
Array
(
    [0] => hello
    [1] => world
)
cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, I'm not sure this is the best solution, but if you open the file jquery.poptrox.js, at line 253 you will find:

_caption
    .on('update', function(e, s) {

        if (!s || s.length == 0)
            s = settings.popupBlankCaptionText;

            _caption.html(s);

    });

Change it to:

_caption
    .on('update', function(e, s) {

        if (!s || s.length == 0)
            s = settings.popupBlankCaptionText;

        if(s.indexOf('|') != -1)
        {
            var part = s.split('|');
            var a = $('<a>', {
                text:$.trim(part[0]),
                href:$.trim(part[1])
            });
        }
        else
        {
            var a = s;
        }

        _caption.html(a);

    });

Then in the title attribute of the image tag set the text and the link separated by the pipe character |, so Title|http://mylink.tld/, example:

<img title="Halloween 2013|https://youtu.be/uci_1MYA2J8" src="image.jpg" />

The above modification will check if there is the pipe | character in the title attribute, if this is matched then it will attemp to create a link, otherwise it will return plain-text.

The $.trim() function will remove extra spaces, in case you want to use them near the pipe:

Halloween 2013 | https://youtu.be/uci_1MYA2J8

Note: for the edit I'm referring to the current version of poptrox.js:

Bye!

JorgeM commented: great job! +12
cereal 1,524 Nearly a Senior Poster Featured Poster

Ok, then check the dpkg log:

sudo less /var/log/dpkg.log

Go to the end of the file, you should find more information about the error. Or try to remove the package directly from the dpkg tool:

sudo dpkg --purge vsftpd

The apt is, in practice, an interface for the dpkg command:

cereal 1,524 Nearly a Senior Poster Featured Poster

A suggestion: this does not solve the problem if the client disables javascript. The suggestion of network18 is correct, in your server side you should check if the index key exists. So instead of:

if($_POST['wdays1']=='')
    echo $wdays1v = 0;
else
    echo $wdays1v = 1;

It should be:

# default
$wdays1v = 0;

# if exists
if(array_key_exists('wdays1', $_POST))
{
    # and if it is not empty
    if( ! empty($_POST['wdays1'])
    {
        $wdays1v = 1;
    }
}
cereal 1,524 Nearly a Senior Poster Featured Poster

So another problem, when the student request on tuesday, the expected date of release is next tuesday. etc.

So, a delay of 4 working days? In MySQL you can create a function based on WEEKDAY() which:

Returns the weekday index for date (0 = Monday, 1 = Tuesday, … 6 = Sunday).

Now, here the code to run in a MySQL client:

drop function if exists releasedate;
delimiter //

CREATE FUNCTION releasedate(date1 DATETIME, ninterval INT UNSIGNED)
RETURNS DATETIME DETERMINISTIC
BEGIN
DECLARE dt DATETIME;
DECLARE i INT UNSIGNED;
DECLARE wd INT UNSIGNED;
SET i = 0;
SET wd = WEEKDAY(date1);
SET dt = date1;
WHILE i < ninterval DO
    SET dt:=DATE_ADD(dt, INTERVAL 1 DAY);
    SET wd:=WEEKDAY(dt);
    CASE WHEN wd in(0,1,2,3) THEN SET i:=i+1;
    ELSE SET i:=i;
    END CASE;
END WHILE;
RETURN dt;
END//

delimiter ;

The WHILE loop will check each date since the starting time and it will add 1 to an internal counter each time the new date is a weekday between 0 and 3. At each loop it will overwrite the dt variable which saves the new date. The loop finishes when the internal counter hits the second argument of the function. The returned value is defined by:

RETURNS DATETIME DETERMINISTIC

And actually returned by:

RETURN dt;

And you can use it like this:

select releasedate(now(), 4) as release_date;
+---------------------+
| release_date        |
+---------------------+
| 2014-03-03 22:03:16 |
+---------------------+
1 row in set (0.04 sec)

Where the first argument is …

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, use the coalesce() function:

select id, coalesce(c1, 0) + coalesce(c2, 0) + coalesce(c3, 0) ...

In practice, if the value of cN is null it will output 0.

Docs:

Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

maybe your problem is related to the recently privacy changes made by Gmail.

They are now caching HTML emails and so, the included images are not pulled directly from your server but from their proxy servers. It seems that only the first request can be tracked because they have to get the images from your server, then the images will be cached on their end for an amount of time and if two users receive the same image there will be only one request from your server, not two as expected so, right now, it seems that the subsequent openings cannot be tracked.

But if you create a dynamic tracking image, which differs for each user at each newsletter, then Google has to request it at least the first time, for everyone.

For more information check these links:

Binoy_1 commented: Thanks. That does clarify some things but my actual question still remains. Do browsers cache scripts and emails? +0
cereal 1,524 Nearly a Senior Poster Featured Poster

You can do a test: load 500 files in a table database, then create a duplicate of this table without the blob field and perform some queries. MySQL provides a tool, the name is mysqlslap, that can give you some information about the performance of the queries:

I created a simple script that reads a directory and saves the images to a table imagedb, if you want to try, below there is the code. Start from the table:

CREATE TABLE `imagedb` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `file` mediumblob NOT NULL,
  `filename` char(32) NOT NULL,
  `extension` varchar(5) NOT NULL,
  `size` mediumint(8) unsigned NOT NULL DEFAULT '0',
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `filename` (`filename`),
  KEY `id` (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

The file column will save the binary data. This is the script:

<?php

# database config
$dbconfig = array(
    'hostname' => 'localhost',
    'database' => 'dbname',
    'username' => 'dbuser',
    'password' => 'dbpass'
);

# config
$filespath = '/path/to/images'; // SET THIS
$exts = array('jpg', 'gif', 'png'); // allowed extensions
$listlimit = 500; // stop at 500 inserts
$sizelimit = 3500000; // soft limit at 3.5MB

if( ! is_dir($filespath)) exit('Directory does not exists!');

try
{
    $pdo = new PDO("mysql:host=$dbconfig[hostname];dbname=$dbconfig[database]", $dbconfig['username'], $dbconfig['password']);
    $pdo->setAttribute(PDO::ATTR_PERSISTENT, TRUE);

    $stmt = $pdo->prepare("INSERT IGNORE INTO imagedb (file, filename, extension, size, created_at, updated_at) values(:file, :filename, :ext, :size, :dt, :dt)");

    # internal counters
    $i = 0;
    $e = 0;

    $dir = dir(rtrim($filespath, '/') . '/'); …
cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

in my opinion, it is better to save the images in directories and the names in a database, mainly because you can serve the images as static content, without involving the PHP engine and the database in this output process.

cereal 1,524 Nearly a Senior Poster Featured Poster

PHP-Nuke 8.3.2 fix some security issues and become compatible with PHP 5.3.

By the way, this is not even completely true, most of their filters are based on the ereg functions, which are deprecated since 5.3 and vulnerable to the null byte attack. For example check their validate mail function at this link:

Now this is the test:

<?php

error_reporting(E_ALL ^ E_DEPRECATED);
$email = $_GET['email'];

function validate_mail($email)
{
    if(strlen($email) < 7 || !eregi("^[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,6}$", $email))
    {
        return 'E-mail error';
    }

    else
    {
        return $email;
    }
}

echo validate_mail($email);

And submit a link like this:

http://localhost/example.php?email=your@email.com

It will print the mail, correctly, but try for example to add a second string, like another mail or a javascript:

# example 1
http://localhost/example.php?email=your@email.tld%00' or email='attacker@mail.tld'

# example 2
http://localhost/example.php?email=your@email.tld%00<script>alert('hello')</script>

If you add the null byte character %00 then: in the first case you can perform a SQL injection, in the second case you can perform an XSS attack. Now, in case of Google Chrome this code does not execute because of their CSP, and if you open the javascript console you will see why:

The XSS Auditor refused to execute a script in '... link ...' because its source code was found within the request. The auditor was enabled as the server sent neither an 'X-XSS-Protection' nor 'Content-Security-Policy' header.

but the other browsers will still execute the javascript.

More information:

cereal 1,524 Nearly a Senior Poster Featured Poster

Yes, you can use the linefeed character \n:

update table1 set color = concat_ws('\n', color, 'lime') where id = XX;

But from a usable point of view, a comma separated list is easier to manipulate, for example in PHP with explode() to get an array or with str_replace() to get a string:

print_r(explode(',' $row['color']);
echo str_replace(',', '<br />', $row['color']);

And you can also use the FIND_IN_SET() function of MySQL:

Consider also JorgeM post, which is a far more flexible solution. Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi!

You can use concat_ws() to add content to a string, for example:

update table1 set color = concat_ws(',', color, 'green') where id = XX;

Full example:

> create table table1 (
    id int unsigned auto_increment primary key not null,
    color varchar(255) not null,
    food varchar(255) not null);

> insert into table1 (id, color, food) values(1, 'red,green','rice');

> select * from table1;
+----+-----------+------+
| id | color     | food |
+----+-----------+------+
|  1 | red,green | rice |
+----+-----------+------+
1 row in set (0.00 sec)

> update table1 set color = concat_ws(',', color, 'blue') where id = 1;

> select * from table1;
+----+----------------+------+
| id | color          | food |
+----+----------------+------+
|  1 | red,green,blue | rice |
+----+----------------+------+
1 row in set (0.00 sec)

Regarding the insert query, this can support a subquery in which you can create the conditional statements, but in this case this is not the correct solution to update an existing value, because it will always add a new row, for example:

> insert into table1 (color) select concat_ws(',', color, 'orange') as color from table1 where id = 1;

> select * from table1;
+----+-----------------------+------+
| id | color                 | food |
+----+-----------------------+------+
|  1 | red,green,blue        | rice |
|  2 | red,green,blue,orange |      |
+----+-----------------------+------+
2 rows in set (0.00 sec)

And since the id column is a primary key, if you remove the auto_increment it will still produce an error for duplicate key.

The alternative …

savedlema commented: Thank you very much. I found help in this one. +2
cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,
you could explode by the spaces between the names:

$names = explode(' ', $row['name']);
echo $names[0];
echo $names[1];

BUT you cannot distinguish between name, middlename and lastname. The correct solution would be to normalize this information during the collection step. Which means:

firstname: <input type="text" name="firstname" /><br />
middlename: <input type="text" name="middlename" /><br />
lastname: <input type="text" name="lastname" /><br />

And then insert it in the appropriated columns:

insert into users (firstname, middlename, lastname) values($fname, $mname, $lname);

More information here:

cereal 1,524 Nearly a Senior Poster Featured Poster

If the undefined index message is related to the $_POST variables it is because when you normally open a page you execute a GET request, when you submit the form, instead, you perform a POST request and only in this case the $_POST array is populated.

So from:

$name = $_POST['name'];

You will get:

Notice: Undefined index: name ...

In order to stop this you can place an IF statement checking if the $_POST array is true:

if($_POST)
{
    $name = $_POST['name'];
    $email = $_POST['email'];
    $message = $_POST['message'];
    $from = 'From: Demo'; 
    $to = 'info@domain.com'; 
    $subject = 'Hello';
    $human = $_POST['human'];
    $body = "From: $name\n E-Mail: $email\n Message:\n $message";
    if ($_POST['submit'] && $human == '4') {                 
        if (mail ($to, $subject, $body, $from)) { 
        echo '<p>Your message has been sent!</p>';
    } else { 
        echo '<p>Something went wrong, go back and try again!</p>'; 
    } 
    } else if ($_POST['submit'] && $human != '4') {
    echo '<p>You answered the anti-spam question incorrectly!</p>';
    }
}
cereal 1,524 Nearly a Senior Poster Featured Poster

The first argument of the anchor() function can accept an array or a string, so:

$segments = array(
    'product',
    'id',
    '1',
    '?version=12&name=mydoc'
);

# with array
echo anchor($segments, 'click me');

# with string
echo anchor('/product/id/1?version=12&name=mydoc', 'click me');

the difference between the two is that the former will output a trailing slash after the $id (with value 1) segment:

# version 1
http://localhost/product/id/1/?version=12&name=mydoc

While the latter no:

# version 2
http://daniweb.ci/product/id/1?version=12&name=mydoc

but, in both cases it should work fine, the point is to include the ? in the segment.

If you want to generate only the second version of the links through an array, then this could be done by extending the url helper, for example by simply exploding the string at the ? character and removing the right slash. In application/helpers create the file MY_url_helper.php and paste this:

<?php

if ( ! function_exists('my_anchor'))
{
    function my_anchor($uri = '', $title = '', $attributes = '')
    {
        $title = (string) $title;

        if ( ! is_array($uri))
        {
            $site_url = ( ! preg_match('!^\w+://! i', $uri)) ? site_url($uri) : $uri;
        }
        else
        {
            $site_url = site_url($uri);
        }

        if ($title == '')
        {
            $title = $site_url;
        }

        if ($attributes != '')
        {
            $attributes = _parse_attributes($attributes);
        }

        # new edit
        $querystring = explode('?', $site_url);
        $querystring[0] = rtrim($querystring[0], '/');
        $site_url = implode('?', $querystring);
        # stop edit

        return '<a href="'.$site_url.'"'.$attributes.'>'.$title.'</a>';
    }
}

Then from the view call the new function my_anchor() as submit the same arguments of the anchor() helper:

$segments …
iamthwee commented: comprehensive answer +0
cereal 1,524 Nearly a Senior Poster Featured Poster

I'm not sure I've understood but you can use both at the same time. For example you have a method like this one:

public function activation($id)
{
    $data = array(
        'id'   => $id,
        'code' => $this->input->get('code', true)
    );

    $this->load->view('signup/activation', $data);
}

And call the url in this format:

http://localhost/signup/activation/1?code=random_string_123

The important is to set to TRUE the allow_get_query in the config file, so that the appended query string will be regularly processed:

$config['allow_get_array'] = TRUE;
iamthwee commented: spot on +14
cereal 1,524 Nearly a Senior Poster Featured Poster

Uhm. I think I cannot help much more, I believe that all these differences happens because, in my case, PDO uses the MySQL Native Driver, while yours is probably using libmysqlclient:

You could try to fetch the results before performing the second query, so:

$result = $pdoStatement->fetchAll();
$countRows = $pdo->query("SELECT FOUND_ROWS()")->fetchColumn();
if ($countRows == 0) {

And then the while loop would become a foreach loop:

foreach($result as $row => $column)
{
    echo $column['title'];
    echo $column['content'];
    echo $column['images'];
}

But if it does not work wait for appropriate help.

davy_yg commented: it works +4
cereal 1,524 Nearly a Senior Poster Featured Poster

You could use getmxrr():

<?php

    $url = 'daniweb.com';
    getmxrr($url, $matches, $weights);

    print_r($matches);
    print_r($weights);

Docs: http://php.net/getmxrr

Regarding dns_get_record() what kind of problem do you experience? Can you show your script?

I need to be able to display the srv record below the textbox, the srv record needs to start with _autodiscover._tcp.

Do you mean you want to filter and get only those with _autodiscover._tcp.? Here you can use strstr() or preg_match() or even preg_match_all() if the record contains more then one matching string.

cereal 1,524 Nearly a Senior Poster Featured Poster

In addition, you could use a PHP array, for example create fruits.php:

<?php

    return array(

        'red' => array(
            'Cherries',
            'Cranberries',
            'Pomegranate',
        ),

        'green' => array(
            'Avocados',
            'Cucumbers',
            'Honeydew',
        ),

        'blue' => array(
            'Blueberries',
            'Fig',
            'Plums'
        )

    );

Then you can include it in your script as a configuration file:

<?php

    $fruits = include 'fruits.php';
    print_r($fruits['red']);

    foreach($fruits['blue'] as $fruit)
    {
        echo $fruit;
    }

With this structure you can create a multidimensional array with all the information about each Country and use it as you like. Bye!

mattyd commented: Thank you! +7
cereal 1,524 Nearly a Senior Poster Featured Poster

Yep: http://talks.php.net/show/phplondon13/

To browse through the slides use the keyboard arrows. Note I suggest Firefox to browse them, Chrome seems to not work fine.

cereal 1,524 Nearly a Senior Poster Featured Poster

Something like this should work:

<!DOCTYPE html>
<html>
    <head>
        <title>Tabless</title>
        <style type="text/css">
            *{margin:0;padding:0;}
            .table { display:table; margin:50px auto; width:960px; position:relative; }
            .tr { display:table-row; margin:10px 0; }
            .td { display:table-cell; height:30px; }
            .strong {font-weight:bold;}
        </style>
    </head>
    <body>

        <div class="table">
            <ul class="tr strong">
                <li class="td">TEXT</li>
                <li class="td">TEXT</li>
                <li class="td">TEXT</li>
            </ul>
            <ul class="tr">
                <li class="td">TEXT</li>
                <li class="td">TEXT</li>
                <li class="td">TEXT</li>
            </ul>
        </div>

    </body>
</html>

Reference: https://developer.mozilla.org/en-US/docs/Web/CSS/display

Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, have you considered the DateTime library?

<?php

    #$dob = $_GET['dob'];
    $dob = '29-06-2009';

    $at_day = '31-03-'.date('Y');
    $dt_dob = new DateTime($dob);
    $dt_now = new DateTime($at_day);

    echo "<pre>";
    print_r($dt_now->diff($dt_dob));
    echo "</pre>";

Outputs:

DateInterval Object
(
    [y] => 4
    [m] => 9
    [d] => 2
    [h] => 0
    [i] => 0
    [s] => 0
    [invert] => 1
    [days] => 1736
)

As second argument you can set the timezone of each date and get the differences. For example:

<?php

    #$dob = $_GET['dob'];
    $dob = '29-06-2009';

    $at_day = '31-03-'.date('Y');
    $dt_dob = new DateTime($dob, new DateTimeZone('America/Los_Angeles'));
    $dt_now = new DateTime($at_day, new DateTimeZone('Europe/Rome'));

    echo "<pre>";
    print_r($dt_now->diff($dt_dob));
    echo "</pre>";

With two different timezones Los Angeles and Rome you get a different result:

DateInterval Object
(
    [y] => 4
    [m] => 9
    [d] => 1
    [h] => 15
    [i] => 0
    [s] => 0
    [invert] => 1
    [days] => 1735
)

Note: you should save everything to UTC and convert it to the local time when needed.

Documentation: http://www.php.net/manual/en/datetime.construct.php

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

this is probably caused by the mysqli_fetch_array() at line 16, it will move the internal pointer to the following row, so the loop will display only the last four items. To include the first one remove line 16, i.e.:

$card_data_result = mysqli_fetch_array($card_data);

Otherwise simply use the variable:

echo $card_data_result['build_name'];

In alternative use data_seek() to reset the pointer:

$card_data_result = mysqli_fetch_array($card_data);
mysqli_data_seek($card_data, 0);
while ($list = mysqli_fetch_array($card_data)){

Docs: http://www.php.net/manual/en/mysqli-result.data-seek.php

cereal 1,524 Nearly a Senior Poster Featured Poster

Set the name attribute to the input field, otherwise the POST array will not receive it and the if statement will fail. This:

<input type="submit" value="Login">

Must be:

<input type="submit" name="submit" value="Login">
cereal 1,524 Nearly a Senior Poster Featured Poster

@toxicandy

With imagettfbbox() you can precalculate the width of the string and add the space that you want to both sides, for example if you want 50px per side you will do:

$font = './arial.ttf';
$fontsize = 14;

$bbox = imagettfbbox($fontsize, 0, $font, 'Powered by PHP ' . phpversion());

If you print $bbox you get:

Array
(
    [0] => 0
    [1] => 4
    [2] => 294
    [3] => 4
    [4] => 294
    [5] => -15
    [6] => 0
    [7] => -15
)

These are the coordinates of the string, we need $bbox[4] because it represents the upper right corner, X position and $bbox[0] because it is the lower left corner, X position. With $bbox[4] we can generate the width of the image:

$imgx = $bbox[4]+100;

where 100 is the number of pixels we want to add (50 per side). With this you can start to create the image:

$imgy = 100;
$im = imagecreatetruecolor($imgx, $imgy);

now to center horizontally the text we have to perform this:

$xpos = $bbox[0] + ($imgx / 2) - ($bbox[4] / 2);

It will output 50, but if instead of $imgx = $bbox[4]+100; you want to double the sizes:

$imgx = $bbox[4]*2;

It will adapt to the new sizes accordingly to the font size. The same procedure can be done to determine the vertical alignment. The final example script looks like this:

<?php

// Path to our font file
$font = './arial.ttf';
$fontsize = 14;
$string = 'Powered by …
cereal 1,524 Nearly a Senior Poster Featured Poster

Try with imagettfbbox() as suggested in this comment:

Also, consider to use mb_strtolower() and mb_convert_case() instead of strtolower() and ucwords() because the latters will not work correctly with special characters. In your case just use:

$name = mb_convert_case($Name, MB_CASE_TITLE, "UTF-8");

Reference: http://php.net/mb_convert_case

Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

You're starting the class in $chimp, not in $MailChimp, so change this:

$chimp = $MailChimp->call('lists/subscribe'

To:

$result = $chimp->call('lists/subscribe'
cereal 1,524 Nearly a Senior Poster Featured Poster

Or is it destined to default down to Arial a majority of the time (provided the user doesn't have Helvetica Neue or Helvetica installed on their machines)?

Correct.

But you can include a font from a remote server, check for example at Google Fonts: http://www.google.com/fonts

cereal 1,524 Nearly a Senior Poster Featured Poster

Use a foreach loop to get the keys and the values:

foreach($array as $key => $value)
{
    echo "$key has variable $value";
}

You can also use array_keys() and array_values(), for example:

$akeys = array_keys($array);
$avalues = array_values($array);

for($i = 0; $i < count($array); $i++)
{
    echo "{$akeys[$i]} has variable {$avalues[$i]}";
}

Another approach with next(), current() and key():

for($i = 0; $i < count($array); $i++)
{
    echo key($array) ." has variable ". current($array) . "<br />";
    next($array);
}

Reference: http://php.net/manual/en/ref.array.php

cereal 1,524 Nearly a Senior Poster Featured Poster

Maybe I got it, add $stmt->store_result(); before num_rows. Looking better at my previous test I was getting your same output, now is:

mysqli_stmt Object
(
    [affected_rows] => 1
    [insert_id] => 0
    [num_rows] => 1
    [param_count] => 1
    [field_count] => 1
    [errno] => 0
    [error] => 
    [sqlstate] => 00000
    [id] => 1
)
diafol commented: Fantastic! Big thanks +0
cereal 1,524 Nearly a Senior Poster Featured Poster

Hi!

It seems to work fine form me, but this:

$stmt->$mysqli->bind_param("s", $dbname);
$stmt->$mysqli->execute();

should be:

$stmt->bind_param("s", $dbname);
$stmt->execute();

My example:

$stmt = $mysqli->prepare("SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = ?");
$stmt->bind_param("s", $dbname);
$stmt->execute();

print_r($stmt);
$result = $stmt->get_result();

while($r = $result->fetch_array(MYSQLI_BOTH))
{
    echo $r[0];
}

And outputs:

mysqli_stmt Object
(
    [affected_rows] => -1
    [insert_id] => 0
    [num_rows] => 0
    [param_count] => 1
    [field_count] => 1
    [errno] => 0
    [error] => 
    [sqlstate] => 00000
    [id] => 1
)

And the dbname.

Consider that if you're using mysqli_stmt::get_result(), this is available only if you using MySQLi through the MySQL Native Driver.

cereal 1,524 Nearly a Senior Poster Featured Poster

Add the fourth parameter and it will cut the word:

wordwrap($string, "80", "<br>", true);
diafol commented: heh, rep for infinite patience +14
cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, you can do it on your own, read this:

It explains all the steps to create your own certificates and CA.

RikTelner commented: Thanks +2
cereal 1,524 Nearly a Senior Poster Featured Poster

Not even because, according to the RFC3696 an email like this one:

test\@mydomain.com@evil.org

is still a valid email address.

Tpojka commented: Helped me with better understanding of mailing services +2
cereal 1,524 Nearly a Senior Poster Featured Poster

It can be done also at query level by using dayofweek(). Differently from PHP the range is 1-7: 1 for sunday, 7 for saturday, for example:

 select * from images where dayofweek(created_at) NOT IN(1,7);

Docs: http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_dayofweek

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

You can use Gparted to create or resize the partitions, but you have to start linux from a liveCD or an USB so you can change the partition without corrupting the operative system.

For more information check these links:

cereal 1,524 Nearly a Senior Poster Featured Poster

Check also HipHop: https://github.com/facebook/hhvm is used to convert PHP to C++ and speed up the execution of the code.

cereal 1,524 Nearly a Senior Poster Featured Poster

It means that you have to compare the date string with the one in the filenames and get the most recent. I suppose you cannot consider ctime/mtime/atime, correct? Because if one of the old files is changed it will prompt ahead.

I'm not good with bash scripts but here's an example that seems to work fine:

#!/bin/bash

cd $REP_DATAS/path

current=$(date -u --date='now' '+%F %H:%M')
file_is_old=3
limit=$file_is_old
result=''

dateQ='20[0-9]{2}(0[1-9]|1[0-2])([0-2][0-9]|3[0-1])_([0-9]{4})'
list='*.tar.Z'

for file in $list
    do
        if [[ $file =~ $dateQ ]]
        then

            match=$BASH_REMATCH

            year=${match:0:4}
            month=${match:4:2}
            day=${match:6:2}
            hour=${match:9:2}
            minute=${match:11:2}

            check=$(date -u --date="$year-$month-$day $hour:$minute" '+%F %H:%M')

            diff ()
            {
                printf '%s' $(($(date -u --date="$current" +%s) - $(date -u --date="$check" +%s)))
            }

            fileage=$(($(diff) / 60 / 60 / 24))

            if [ $fileage -le $limit ]
            then
                let limit=fileage
                export result="$file"
            else
                continue
            fi

            if [ $fileage -ge $file_is_old ]
            then
                result="-en \E[47;31m\033[1m Warning: $file is old \033[0m\n"
                tput sgr0
            else
                result=$file
            fi

        fi
    done

echo $result

I'm sure this can be rewritten a lot better, so before using it wait for other suggestions or, better, check the bash documentation.

Reference:

Good luck! :)

cereal 1,524 Nearly a Senior Poster Featured Poster

Yes. 1-31 is the range, you can use * which, in this case, is the same because cron internally sets the first_dom constant to be always 1 and the last_dom constant to be always 31.

So when you write:

*/4

And:

1-31/4

You get the same result. If you want to perform a task every 4 days of the first 20 days of the month you would write:

1-20/4

In the cron source this is done by this loop in the entry.c file:

/* range. set all elements from num1 to num2, stepping
 * by num3.  (the step is a downward-compatible extension
 * proposed conceptually by bob@acornrc, syntactically
 * designed then implmented by paul vixie).
 */
for (i = num1;  i <= num2;  i += num3)
    if (EOF == set_element(bits, low, high, i))
        return EOF;

In PHP it's like writing this:

<?php

define('FIRST_DOM', 1);
define('LAST_DOM', 31);

# 1-31/4
$dom = '1-31';
$step = '4';
$range = array();

switch(true)
{
    case is_null($step) === FALSE && ctype_digit($step):
        $num3 = $step;
        break;
    default:
        $num3 = LAST_DOM - FIRST_DOM + 1;
        break;
}

switch($dom)
{
    case preg_match('/^(\d{1,2}\-\d{1,2})/', $dom, $match) == 1:
        $nums = explode('-', $match[1]);
        $num1 = $nums[0];
        $num2 = $nums[1];
        break;
    case ctype_digit($dom):
        $num1 = $dom;
        $num2 = LAST_DOM;
        break;
    default:
    case '*':
        $num1 = FIRST_DOM;
        $num2 = LAST_DOM;
        break;
}

for($i = $num1;  $i <= $num2;  $i += $num3)
{
    $range[] = $i;
}

echo implode(',', $range);

But you can also use:

# */4
$dom = '*'; …
cereal 1,524 Nearly a Senior Poster Featured Poster

Please give us more information. If you can login through FTP/SSH then you should be able to edit the config file and you can change the value of WP_SITEURL, that should fix the problem:

define( 'WP_SITEURL', 'http://domain.tld/wordpress' );

Reference:

If you cannot access in any way, then you have to contact the hosting company assistance.

cereal 1,524 Nearly a Senior Poster Featured Poster

It should work minimum once evenif the file is two weeks old. The objective is just to display the date of file, if its not new, it will disply in red message as alert that file is very old.

This is very different from what you were asking in your previouses posts.

To get files with a date in the filename change the pattern to match the numbers, something like:

dateQ='([0-9])'

Or:

dateQ='20[0-9]{2}(0[1-9]|1[0-2])([0-2][0-9]|3[0-1])'

An updated version of the script:

#!/bin/bash
cd $REP_DATAS/path

dateQ='20[0-9]{2}(0[1-9]|1[0-2])([0-2][0-9]|3[0-1])'

list='*.tar.Z'

for file in $list
do
    if [[ $file =~ $dateQ ]]
    then
        echo $file
    fi
done

If you still have problems post your updated script and explain exactly your goals.

cereal 1,524 Nearly a Senior Poster Featured Poster

Regarding your first issue, this is probably caused by nl2br, everytime you print the code to the textarea it will translate the new lines to <br />, but it will not remove the new lines. If you remove strip_tags() from the below script, add few lines to the textarea and start to resubmit the form, you will see how the newlines will multiply.

Regarding your second issue, if those are integers then use trim() and intval() so you remove extraspaces and if the submitted datum is not an integer, it will return 0.

Here's an example:

<?php

    $reg_info = 'Hello World';
    $reg_contact_h = 12;
    $reg_contact_m = 17;

    if($_POST)
    {
        print_r($_POST);

        $reg_info = nl2br(strip_tags($_POST['reg_info']), true);
        $reg_contact_h = intval(trim($_POST['rqst_contact_h']));
        $reg_contact_m = intval(trim($_POST['rqst_contact_m']));
    }

?>
<html>
    <head>
        <title>Eban Bury Test Page</title>
    </head>
    <body>
        <form method="post" action="">
            <textarea name="reg_info" cols="45" rows="5" class="roundedfield" id="reg_info"><?php if (!empty($reg_info)) echo htmlspecialchars($reg_info, ENT_NOQUOTES, 'UTF-8'); ?></textarea>

            <label for="rqst_contact_h"></label>
            <input type="text" name="rqst_contact_h" class="roundedfield" id="rqst_contact_h" value="<?php if (!empty($reg_contact_h)) echo $reg_contact_h; ?>" size="20">

            <label for="rqst_contact_m"></label>
            <input type="text" name="rqst_contact_m" class="roundedfield" id="rqst_contact_m" value="<?php if (!empty($reg_contact_m)) echo $reg_contact_m; ?>" size="20">

            <input type="submit" name="submit" value="send" />
        </form>
    </body>
</html>

Hope it helps, bye! :)

cereal 1,524 Nearly a Senior Poster Featured Poster

You can change the approach: with $dateQ you set also the time segment %H%M, not only the day, so if you search for a file of 20140106 you find it only if you match also the hour and the minute segment, i.e.: 1655.

If you cannot avoid the time segment in filenames, then you can change $dateQ to generate only the date segment, so:

dateQ=`date --date='-3 day' +'%Y%m%d'`

instead of:

dateQ=`date --date='-3 day' +'%Y%m%d_%H%M'`

and use it as a regular expression to match the file:

#!/bin/bash
cd $REP_DATAS/path
u=$(date +%u)

if [ ${u} -eq 1 ] ; then
dateQ=`date --date='-3 day' +'%Y%m%d'`
else
dateQ=`date --date='-1 day' +'%Y%m%d'`
fi

list='*.tar.Z'
for file in $list
do
    if [[ $file =~ $dateQ ]]
    then
        zcat $file | tar xvf -
    fi
done

Where list can also be limited to the last 10 modified files, so the script does not have to loop against all files:

list='ls -t *.tar.Z | head -n 10'

You can change it as you prefer.

Note a part: you were using %H%m which will print hourmonth not hourminutes, so use %M to get the minutes.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

the .htaccess file is used for HTTP connections, not for FTP access. The article in LH talks about HTTP Authentication: when you open an URL it appears a prompt that asks for username and password, those specified in .htpasswd. If Apache is properly configured then the HTTP access will be limited to the DocumentRoot of the server, but an FTP user will have complete access unless you don't jail it to a specific path (i.e. directory).

In order to secure your FTP server follow these instructions:

There is an example that explain how to add users to Filezilla Server, those users will be able to access your server. Disable also anonymous access, i.e. remove the anonymous user.

cereal 1,524 Nearly a Senior Poster Featured Poster

Ok, so the error is file not found or something else? Currently you're not checking if the file is available, try to add a check, and change the extracting command, an example:

file=filename_$dateQ.tar.Z

if [ -f $file] ; then
zcat $file | tar xvf -
else
echo "$file not found"
fi