cereal 1,524 Nearly a Senior Poster Featured Poster

Also, are these values encoded? For example hello%20

In this case you can run:

update table_name set field_name = trim(BOTH '%' FROM field_name);

This will remove just % if you have other codes, as example an encoded empty space %20, you have to change it to:

update table_name set field_name = trim(BOTH '%20' FROM field_name);
cereal 1,524 Nearly a Senior Poster Featured Poster

Show the query that you use to select.

Also, to remove white space use trim(). This function exists in PHP and MySQL, so when you insert from PHP you can just do something like this:

$var = trim($var);

if you want to fix the rows in your table, you can run an update query:

update table_name set field_name = trim(field_name);

This will remove leading and trailing spaces: http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_trim

cereal 1,524 Nearly a Senior Poster Featured Poster

Add mysql_error() to your execution:

mysql_query($query) or die(mysql_query())

This will output the error, it should help you to solve the problem.

cereal 1,524 Nearly a Senior Poster Featured Poster

Intended font is supposed to be 16px at 100% so I think it's something on your end??

Confirmed, the problem was on my end, I was using Google Chrome 17.* on Ubuntu 12.04, my system gave me this as stable version, by adding another source I was able to upgrade to version 28, now it's all nice and shiny.

Solution steps:

  1. add new source:

    wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
    
  2. add the key:

    sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'
    
  3. update:

    sudo apt-get update
    

After the update the system will prompt for the installation of the latest stable version. Otherwise search it by typing: apt-cache search google-chrome

As note: Chrome 23.* and higher displays fine.

Thank you for your time Dani! :)

cereal 1,524 Nearly a Senior Poster Featured Poster

cereal, are you using any third party extensions or plugins of any kind??

yup, but I switched them off two hours ago and nothing changed.

I think the problem is given by the size of the fonts, if I click on CTRL+- (i.e. reduce) everything goes in place and looks fine, when I click on CTRL+0 (back to normal) the problem appears, but if I reload the page, it doesn't happen anymore, very strange.

The issue happens also in forum and profile pages, here are few screenshots:

c752533a227d9730a7c417fa1f1d6821

5405c74f561508cef8eb82a4b353b629

Default zoom is 100%. Default font size is medium (16px), maybe depends on this. I will try with another linux box as soon as I can, maybe it's just my setup. I will let you know.

cereal 1,524 Nearly a Senior Poster Featured Poster

Ok, my issue is still valid: yesterday after cleaning the cache it disappeared but, now, I'm experiencing it again. Now it's totally random.

Also in related topics (right box) I get articles from restricted areas, as this link which is in Moderators forum:

http://www.daniweb.com/community-center/daniweb-community-feedback/moderators-place/threads/423718/new-mods-thread

cereal 1,524 Nearly a Senior Poster Featured Poster

I think my problem depended on browser cache, after choosing to clear it completely seems to work fine. Thanks for your attention :)

cereal 1,524 Nearly a Senior Poster Featured Poster

Hello there!

I'm occasionally experiencing some problems with the new layout:

Primarly the text of the post overflows outside the right border, and if I use inline code the previous word is covered. I'm attaching an image with the different problems. In the case of the inline code the word under the label is using.

This happens when I open a thread for the first time, reloading it fixes the layout, but if I quit the page and go back I experience the same problem.

6e4d4007844cd9634bcc73e0a80bf580

Reference thread for above screenshot:

http://www.daniweb.com/web-development/php/threads/460877/accessing-data-outside-of-this-request-data-using-the-cakephp-way

Current UserAgent:

Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.78 Safari/535.11

Works fine on Mozilla Firefox 23.0

cereal 1,524 Nearly a Senior Poster Featured Poster

It means "return only the first row of the result set", it's like using limit 1 in a query. If you open the link that I pasted above, you can access the documentation of this method.

cereal 1,524 Nearly a Senior Poster Featured Poster

Have you tried the Model::find() method? As example:

$row = $this->Test->find('first', array(
    'conditions' => array('Test.username' => 'jimmorrison')
));

print_r($row);

More info: http://book.cakephp.org/2.0/en/models/retrieving-your-data.html

cereal 1,524 Nearly a Senior Poster Featured Poster

Works fine for me. Probably it depends by your DNS, try to run this from a terminal:

dig www.kovaidonbosco.com

and then:

dig @8.8.8.8 www.kovaidonbosco.com

and:

dig www.kovaidonbosco.com.cdn.cloudflare.net

In the first two cases, if cloudflare is off, you should get your server IP. For more information check: https://support.cloudflare.com/entries/22066298-Hosting-Partner-Troubleshooting

cereal 1,524 Nearly a Senior Poster Featured Poster

That means you are using FastCGI, you can also use echo PHP_SAPI;

cereal 1,524 Nearly a Senior Poster Featured Poster

No problem. For example because this will make the property (variable) available inside the extended classes:

class Mailer extends Action
{        
    public function send_mail()
    {
        $emailTo = $this->userinfo['email'];

        # ... other code here ...
    }
}

It will be more easy to deal with data between classes. Check these links for more information:

cereal 1,524 Nearly a Senior Poster Featured Poster

First, remove global $userInfo; from line 33, and set it as public/protected/private variable at the top of the class:

class Action
{
    public $userInfo;

So, at line 47 you can write:

$this->userInfo = $stmt->fetch_array(MYSQLI_ASSOC);
cereal 1,524 Nearly a Senior Poster Featured Poster

Not:

`autod.mark`

But:

`autod`.`mark`

Also at line 29 there is no space between mudel.id and $where values, so it will generate:

... INNER JOIN mudel ON autod.mudel = mudel.idWHERE`autod.mark`=7;

Which is wrong. To see the error in the query change this:

if(!$cmd){
    $response['err'] = "Tekkis viga andmete küsimisel!";
    $response['success'] = false;
}

to:

if ( ! $cmd) {
    printf("Error message: %s\n", $connect->error);
    die(); # stop this test execution here.

    $response['err'] = "Tekkis viga andmete küsimisel!";
    $response['success'] = false;
}

# optional, but useful to avoid wrong executions
else
{
    # execute the query
}

If you're still using ajax then use the response array, but the lack of the ELSE statement, in case of wrong input/setting, will continue to execute the script generating errors like previous.

Reference: http://www.php.net/manual/en/mysqli.error.php

cereal 1,524 Nearly a Senior Poster Featured Poster

Not tested, but if I'm not wrong this $cmd->bind_param("s", $where); will insert the value of $where as a string, so:

'autod.mark=7'

instead of:

`autod`.`mark`=7

If you try to display the error of the query you should get something like:

 Warning | 1292 | Truncated incorrect INTEGER value: 'autod.mark=7' 
cereal 1,524 Nearly a Senior Poster Featured Poster

Yes. The RFC cited in PHP documentation explains that the semicolon is used to separate groups of mails, for example:

To: list-a: abc@localhost.tld, cba@localhost.tld;, list-b: admin@localhost.tld, info@localhost.tld;
cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, the config seems fine, so it can be a permission issue or the mime-type (each CGI needs the mime-type declaration at the top of the script), check this link for more information: http://httpd.apache.org/docs/2.2/howto/cgi.html#writing

Also, check Apache error logs to get more details about the issue. Hope it helps.

cereal 1,524 Nearly a Senior Poster Featured Poster

Do you get the same effect with different browsers? I can think to an autofill issue here, if you're using HTML5 you can avoid it by adding autocomplete="off" to the input fields.

cereal 1,524 Nearly a Senior Poster Featured Poster

Can you explain better the problem? I've created a test with ajaxForm and it's working fine, here's the code:

The Controller
<?php

class Test extends CI_Controller {

    protected $data;

    public function __construct()
    {
        parent::__construct();
    }

    public function index()
    {
        $this->load->helper('form');
        $this->load->library('form_validation');
        $this->form_validation->set_rules('name', 'name', 'trim|required|prep_for_form|xss_clean');
        $this->form_validation->set_rules('comment', 'comment', 'trim|required|prep_for_form|xss_clean');
        $this->data['last_comment'] = FALSE;

        if($this->input->server('REQUEST_METHOD') == 'POST')
        {
            if($this->form_validation->run() === FALSE)
            {
                $this->data['error'] = 'Ops!';
            }
            else
            {
                $this->data['error'] = 'POST Requests';
                $this->data['last_comment'] = array(
                    'name'      => $this->input->post('name'),
                    'comment'   => $this->input->post('comment')
                    );

                # empty the values retrieved by set_value()
                $this->form_validation->resetpostdata();
            }
        }
        else
        {
            $this->data['error'] = 'GET Request';
        }
        $this->load->view('test/test', $this->data);
    }

}
The View
<!DOCTYPE html>
<html lang="en">
<head> 

    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
    <script src="http://malsup.github.com/jquery.form.js"></script>
    <script type="text/javascript" src="/js/bootstrap.min.js"></script>

    <link href="/css/bootstrap.min.css" rel='stylesheet' type='text/css' />

    <style type="text/css">
        body { padding:50px; }
    </style>

    <script>
        $(document).ready(function() { 
            var options = { target: '#commentAjax' };
            $('#commentForm').ajaxForm(options); 
        }); 
    </script> 
</head>
<body>
<?php

$data = array(
            array(
                'name'  => 'name',
                'id'    => 'name',
                'class' => 'input-xlarge',
                'value' => set_value('name', 'your name'),
            ),
            array(
                'name'  => 'comment',
                'id'    => 'comment',
                'class' => 'input-xlarge',
                'value' => set_value('comment', 'your comment'),
            ),
            array(
                'value' => 'Submit',
                'type'  => 'submit'
            )
        );

echo '<div id="commentAjax">';
echo "<h3>$error</h3>";
echo form_open('/test/index', array('id' => 'commentForm'));
echo '<label for="name">Name</label>'.form_input($data[0]);
echo '<label for="comment">Comment</label>'.form_textarea($data[1]).'<br />';
echo form_submit($data[2]);
echo form_close();
if($last_comment !== false)
{
    echo '<h4>'.$last_comment['name'].'<h4>';
    echo '<p>'.$last_comment['comment'].'</p>';
}
?>
</div>
</body>
</html>
Update of MY_Form_validation.php
public function resetpostdata($reset = false)
{

    if($reset === true)
    {
        $_POST = array();
    }

    $obj =& _get_validation_object();

    foreach($obj->_field_data as $key)
    { …
cereal 1,524 Nearly a Senior Poster Featured Poster

You're welcome, if we are done, please mark it solved, it will be useful to others :)

cereal 1,524 Nearly a Senior Poster Featured Poster

Ok, the problem is that set_value() doesn't consider if the validation runs true or false, usually you redirect() and so the POST array is resetted automatically, here we can force this action by extending /system/libraries/Form_validation.php, create /application/libraries/MY_Form_validation.php and paste this:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class My_Form_validation extends CI_Form_validation {

    public function __construct()
    {
        parent::__construct();
    }

    public function resetpostdata()
    {
        $obj =& _get_validation_object();
        foreach($obj->_field_data as $key)
        {
            $this->_field_data[$key['field']]['postdata'] = NULL;
        }
        return true;
    }

}
?>

After the validation runs true, call the method, as in this example:

if($this->form_validation->run() === FALSE)
{
    # . . .
}
else
{
    $this->form_validation->resetpostdata();

    # load view & other stuff
}

It should work fine, bye.

cereal 1,524 Nearly a Senior Poster Featured Poster

What it does $this->data['new_comment'] = $this->blog_comment_m->get_new(); ? I see it's used in two cases:

  1. GET request, no form submit;
  2. and when validation is true, rewriting a previous setting of $this->data['new_comment'].

In the first case the objects should return null/false, so that the default value for set_value('name', $default) is empty.

cereal 1,524 Nearly a Senior Poster Featured Poster

Maybe it's a connection problem? I don't see any evident issues, unless your server IP is banned or there is a DNS problem. If you have access to a terminal in your server, try to run this:

curl --head https://twitter.com/

It should return something like:

HTTP/1.1 200 OK
cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0
content-type: text/html; charset=utf-8
date: Sat, 13 Jul 2013 19:34:13 GMT
expires: Tue, 31 Mar 1981 05:00:00 GMT
last-modified: Sat, 13 Jul 2013 19:34:13 GMT
pragma: no-cache
server: tfe
...

Try also the dig command, to verify if this is a DNS issue, first run:

dig twitter.com

And then:

dig @8.8.8.8 twitter.com

The first will use default DNS settings, the second will query the DNS of Google.

cereal 1,524 Nearly a Senior Poster Featured Poster

Try this:

<?php

$url = 'https://twitter.com/darknille/status/355651101657280512';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_VERBOSE, FALSE);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_NOBODY, true);

curl_exec($ch);


if(!curl_errno($ch))
{
    $info = curl_getinfo($ch);

    echo $intReturnCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);

    curl_close($ch);

    switch($intReturnCode)
    {
        case 200:
        case 302:
        case 304:
            echo "true";
            break;
        default:
            echo "false";
            break;
    }
}

?>

The problem with your first function is the callback.

cereal 1,524 Nearly a Senior Poster Featured Poster

I think you have to change 3900 to 3300, and change the second statment to compare cases between red and orange limits, here's an example:

<?php

date_default_timezone_set('Asia/Manila');

$current_time = "17:05";
$serving_time = "18:00";


echo "result: \t";
if(
    strtotime($current_time) <= (strtotime($serving_time) - 3600)
)
{
    echo 'red';
}
elseif(
    strtotime($current_time) <= (strtotime($serving_time) - 3300)
    &&
    strtotime($current_time) >= (strtotime($serving_time) - 3600)
)
{
    echo 'orange';
}
else
{
    echo 'blue';
}

echo PHP_EOL;
echo 'red limit: '."\t". date('G:i:s', strtotime($serving_time) - 3600) . PHP_EOL;
echo 'orange limit: '."\t". date('G:i:s', strtotime($serving_time) - 3300) . PHP_EOL;
echo PHP_EOL;

Then switch $current_time between:

$current_time = "17:00"; # red
$current_time = "17:05"; # orange
$current_time = "17:06"; # default
cereal 1,524 Nearly a Senior Poster Featured Poster

If you add an equal sign it will work, but at 18.06 will change to default again. Is this the expected behaviour?

else if (strtotime($current_time) >= (strtotime($serving_time) - 3900 ))
cereal 1,524 Nearly a Senior Poster Featured Poster

You're welcome! In case of problems, post the error codes, we will try to help, bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

I see that the values are set by your form:

$path_name = $_POST['selectloc'];
$file_name = $_POST['selectname'];

Are you sure the path of the file is correct? Consider that in linux paths are case sensitive, so Uploads and uploads are different for the system. You can verify the paths with file_exists().

Also remove ; from line 226.

cereal 1,524 Nearly a Senior Poster Featured Poster

Line 222. Full block in your code starts at line 200:

$message = Swift_Message::newInstance()
  ->setContentType("text/html")
    // Give the message a subject
  ->setSubject($subject)
    // Give it a body
  ->setBody($body)
    // Set the From address with an associative array
  ->setFrom($gmail_id)
    // Set the Sender address with an associative array
  ->setSender($gmail_id)
    // Set the To addresses with an associative array
  ->setTo($to)
    // Set the cc addresses with an associative array
  ->setcc($cc)
    // Set the Bcc addresses with an associative array
  ->setBcc($bcc);

foreach($attachment as $attach)
{
    $message->attach($attach); // end Message create  
}

If this doesn't help, please, post the errors codes, it will be easier for us to help you.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hello! I checked rapidly your code, I didn't tested but it seems fine, just few notes:

At line 78 you wrote:

$file = "Swift_Attachment::fromPath('" . $path . "')->setFilename=('" . $name . "', 'application/pdf'),";

fromPath() method supports two arguments (path and mime and the second is optional), while setFilename() supports only one argument, so the above needs to be changed to:

$file = "Swift_Attachment::fromPath('" . $path . "', 'application/pdf')->setFilename('" . $name . "')";

Note also that I've removed = character from setFilename and the comma at the end of the string. The main problem is that you're sending this as string but you have to feed the output, to the attach() method, not the command to execute, so remove the double quotes from the line:

$file = Swift_Attachment::fromPath('" . $path . "', 'application/pdf')->setFilename('" . $name . "');

This can also be rewritten as:

$file = Swift_Attachment::fromPath($path, 'application/pdf')->setFilename($name);

You can avoid array_push and use directly this solution:

$attachment[] = Swift_Attachment::fromPath($path, 'application/pdf')->setFilename($name);

Last note, the attach method doesn't seem to support arrays as arguments, so you should loop the above array as:

foreach($attachment as $attach)
{
    $message->attach($attach);
}

Hope it helps.

cereal 1,524 Nearly a Senior Poster Featured Poster

It's about the tag </table> being in between the PHP code tags (<?php and ?>).

@pritaeas, ardav & Squidge: totally right, for some reason I confused the previouses lines of code, my apologies.

cereal 1,524 Nearly a Senior Poster Featured Poster

Replace <? with <?php from line 44 to 47.
Note also that short tags are enabled by your php.ini config - http://php.net/manual/en/language.basic-syntax.phptags.php

cereal 1,524 Nearly a Senior Poster Featured Poster

Change last line to:

echo ${$mystring}[0];

And it will work, otherwise it will refer to the name of the string myarray.

cereal 1,524 Nearly a Senior Poster Featured Poster

You can do that throught the attach() method: http://swiftmailer.org/docs/messages.html#attaching-files
If you still don't solve the problem post an example of the code here, bye.

cereal 1,524 Nearly a Senior Poster Featured Poster

First argument of where() method is a string, at the moment it seems to be a constant, so change them to:

$this->db->where('Interior_house_id', $Interior_house_id);
$this->db->where('Interior_room_id', $Interior_room_id);
cereal 1,524 Nearly a Senior Poster Featured Poster

$txt2 is considered a string, so you have to use quotes:

"SELECT * FROM table FIND_IN_SET('$txt2', field)"

And it should work.

cereal 1,524 Nearly a Senior Poster Featured Poster

To me it seems to work fine:

$v0 = 3;
$v1 = 5;
$v2 = 7;

echo min( max(($v0 - $v1), 0), $v2);

$v0 - $v1 = -2 so max() between -2 and 0 is 0, min() result will be 0, inverting $v0 and $v1 will output 2 as expected. Or am I wrong?

cereal 1,524 Nearly a Senior Poster Featured Poster

Replace the quotes that surrounds the field name 'town' with back ticks, so this:

$rs=mysql_query("select CommercialEnterprise_Email from commercialenterprise WHERE 'town' = 'Killkee'");

Becomes:

$rs=mysql_query("select CommercialEnterprise_Email from commercialenterprise WHERE `town` = 'Killkee'");

If you still get errors add mysql_error(): http://php.net/manual/en/function.mysql-error.php

cereal 1,524 Nearly a Senior Poster Featured Poster

Regarding the date try:

date('d-m-Y', mktime(0, 0, 0, date("m"), date("d") + $_POST['exdays'], date("Y")));

Concerning the second question, you can use json_encode() to convert the array to a string and so, you can save it as varchar or text type, otherwise you need a blob type.

Edit
Sorry Webville, I just saw your reply, bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

If you have access to the mail directory you can use Plancake library: https://github.com/plancake/official-library-php-email-parser

It will parse the files into an object, from there you can store it into the database. If you don't have direct access, you may want to add IMAP library to get the messages: http://www.php.net/manual/en/ref.imap.php

cereal 1,524 Nearly a Senior Poster Featured Poster

Move these:

$image_value = array();
$description_value = array();

outside the while statement, otherwise the array resets after each loop. Also you can avoid the use of array_push() by writing:

while($row = mysql_fetch_array($result))
{
    $image_value[] = $row['image_id'];
    $description_value[] = $row['description'];
}
cereal 1,524 Nearly a Senior Poster Featured Poster
cereal 1,524 Nearly a Senior Poster Featured Poster

Use reload:

sudo service apache reload

in practice Apache will perform a graceful restart, it is the same of running:

apachectl -k graceful

it means that will finish to serve the current requests before restarting.
For more information and options check: http://httpd.apache.org/docs/2.2/en/stopping.html

cereal 1,524 Nearly a Senior Poster Featured Poster

The difference is that if bar is null isset() will return FALSE, while array_key_exists() will still return TRUE:

$foo['bar'] = NULL;

echo isset($foo['bar']) ? 'true':'false';
echo array_key_exists('bar',$foo) ? 'true':'false';

So it depends on your intentions.

diafol commented: never knew that +14
cereal 1,524 Nearly a Senior Poster Featured Poster

Line 32:

<option value="<?php echo $ho('interior_house_id');?>"><?php echo $ho['interior_house_desc'];?></option>

Change $ho('interior_house_id') to $ho['interior_house_id'] and it should work. Also I suggest you to use $this->input->post() instead of $_POST since it sanitized by the framework (if $config['global_xss_filtering'] = TRUE;). Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

You could move CodeIgniter to a subdirectory:

/index.html
/backend/index.php
/backend/system/
/backend/application/

Create an .htaccess file inside backend and change the rewrite rule to match the directory:

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /backend/index.php/$1 [L]

A part from this solution, keep in mind that you can create simple Controllers and Views to run the frontend.

cereal 1,524 Nearly a Senior Poster Featured Poster

Let say the databases are on ServerB and ServerC and the main website with the search function is on ServerA, if the servers are in the same network you can use bind-address directive:

bind-address = 192.168.0.100 # local network IP address

Otherwise you have to comment this directive #bind-address and setup a firewall rule to allow connections to MySQL only from ServerA IP address. Once this is done you can directly access remote databases or you can choose to use federated tables: http://dev.mysql.com/doc/refman/5.0/en/federated-storage-engine.html which let you access remote databases by using your local server.

Consider also to setup SSL connections between the servers: http://dev.mysql.com/doc/refman/5.0/en/ssl-connections.html otherwise the data can be captured very easily.

cereal 1,524 Nearly a Senior Poster Featured Poster

Yes, you can edit your answers for 30 minutes. But you could flag your own post as Flag Bad Post and motivate the deletion request.

cereal 1,524 Nearly a Senior Poster Featured Poster

It all depends on what you want to do. The two items are x and y? What have you tried? A simple $_GET['width'][1] it's not enough?