vendredi 29 mai 2015

Get Bot Margin to AddPage - FPDF

My PDF file is a table completed with values from a server.
And if the next line created is too large to display on the end of the page, I want to add a new page, then insert my new line.

I guess I must do some maths with $height_of_cell (which I calculate), getY() and margin-bottom but I don't know, and I didn't find how to get this last value.
Does anyone know ? Thank you !

Laravel 4.2 - PHP Error reporting turned off

My Laravel 4.2 application runs happily with undefined variables or array indexes.

I have placed

ini_set('display_errors',1);
error_reporting(E_ALL|E_STRICT);

in many places in my code in an attempt to get this happen.

The php.ini contains

error_reporting = E_ALL

Debugging is true in app.php.

I have grep'd all of the Laravel and vendor code and my code to look for locations where error reporting may have been turned off, but none seems relevant.

Non-Laravel web applications on the same server crash and/or report properly for these kinds of errors.

PHP is 5.6.8 on Fedora and 5.5. on Centos.

connecting to MS access with php when defined password for database

I am trying to connect Ms Access DataBase from php . My codes like this in config.php

 define('DBNAMEACCESS',  '\\'."\\xxx.xxx.xxx.xxx\\test\\test.accdb");
        define('DBACCESSPASSWORD', 'mypassword');
        define('DBACCESSUSERNAME', '');

and in process.php like this:

     include './config.php';
   if (!file_exists(DBNAMEACCESS)) {
            die("Could not find database file.");
        }
 try{
            $dbName=DBNAMEACCESS;
            $username=DBACCESSUSERNAME;
            $password=DBACCESSPASSWORD;
             $dba = odbc_connect("Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=$dbName",$username, $password);

   if ($dba) {
/*......*/
} else
            {
                die("Could not connect to access database");
            }
             }
        catch (Exception $ex) {
//            var_export($ex);
                setmessage($ex) ;
        }

when the password is defined for access file , I get this error on this line: My error: odbc_connect(): SQL error: [Microsoft][ODBC Microsoft Access Driver] Cannot open database '(unknown)'. It may not be a database that your application recognizes, or the file may be corrupt., SQL state S1000 in SQLConnect in this line

         $dba = odbc_connect("Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=$dbName",$username, $password);

and when the password is not defined for access file,My codes execute correctly.

CSS IDs not working when extension is hidden

I developed my site with extensions visible, but when I finished and wanted to make it to production. Now I did a htaccess to hide extensions and add a trailing slash, when people click on a button which redirects/links to #tab1, the url becomes: http://ift.tt/1FHzXSQ

And the CSS ID doesn't open up (the tab).

Is there a way to fix this?

Thanks in advance

zend gdata and google spreadsheet not connecting

ive been using Zend Gdata for a while now, and today im getting an error of

Notice: Undefined offset: ClientLogin.php on line 150

via php, this has been working for a while now, and today without changing anything it stopped working, im guessing some deprecated service on behalf of google with the zend gdata maybe the Zend_Gdata_ClientLogin::getHttpClient( ) method or something, can any one confirm or help me with this issue. the code im using to connect is as follows:

    require_once('Zend/Loader.php');
Zend_Loader::loadClass('Zend_Gdata');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_Docs');
Zend_Loader::loadClass('Zend_Gdata_Spreadsheets');
require_once 'Zend/Gdata.php';
require_once 'Zend/Gdata/AuthSub.php';
require_once 'Zend/Gdata/Spreadsheets.php';
require_once 'Zend/Gdata/Spreadsheets/DocumentQuery.php';
require_once 'Zend/Gdata/Spreadsheets/ListQuery.php';
require_once 'Zend/Loader.php';


$sourceUser = "myemail";
$sourcePass = "mysuperawesomepassword";
$service = Zend_Gdata_Spreadsheets::AUTH_SERVICE_NAME;
$sourceClient = Zend_Gdata_ClientLogin::getHttpClient($sourceUser, $sourcePass, $service);
$connection = new Zend_Gdata_Spreadsheets($sourceClient);

i am using the zend gdata with the google spreadsheets

also the error points specifically to this line

$sourceClient = Zend_Gdata_ClientLogin::getHttpClient($sourceUser, $sourcePass, $service);

as i said, i was using this for a while now, and nothing has changed on my end

foreach loop in json encode array

I am sending preformatted HTMl with AJAX JSON, JSON have below code,

I am trying pull data array from DB and echoing array data, I am not able to put foreach loop in json_encode, because seems my code is wrong at foreach loop,

How can i achieve that?

echo json_encode(array('returnnews' => '<div class="news-item-page">
                                    <h3 class="text-info" style="margin-top:0">'.$latestnews->news_subject.'</h3>
                                    '.$latestnews->news_content.'


                                </div>
                                <div class="row">
                                    <div class="col-md-6">
                                        <ul class="list-inline blog-tags">
                                            <li>
                                                <i class="fa fa-tags"></i>'.
                                                foreach($news_tag_array as $tag){
                                                <a href="javascript:;">
                                                echo $tag </a>
                                               }

                                            </li>
                                        </ul>
                                    </div>
                               </div>'));

Zend Form ->addValidator('Digits') not working

I am trying to add validator to my Text field as i am expecting user to only enter positive integers. But its not working neither showing any error message if we enter value like '-50'. The code is, $AddInventory = new Zend_Form_Element_Text('AddInventory'); $AddInventory->setAttrib('dojoType',"dijit.form.ValidationTextBox");
$AddInventory->setAttrib('maxlength','40') ->setAttrib('style','width:200px') ->setAttrib('required',"false") ->addValidator('NotEmpty') ->addFilter('StripTags') ->addValidator('Digits')
->removeDecorator("DtDdWrapper") ->removeDecorator("Label") ->removeDecorator('HtmlTag');