Error generating SVG with phpqrcode - php

I am trying to execute following code from the SVG basic output example from the docs.
<?php
include('vendors/phpqrcode/qrlib.php');
$svgCode = QRcode::svg('PHP QR Code :)');
echo $svgCode;
All I get is the error:
Fatal error: Call to undefined method QRcode::svg()
/path/to/php/file/index.php on line 1337
The strange thing is that the simple PNG output example works fine without any errors, so the include must be correct.
<?php
include('vendors/phpqrcode/qrlib.php');
QRcode::png('PHP QR Code :)');
Do you guys have an idea what I might have forgot to check? Maybe the error is obvious for you.

As noticed in another thread and I experienced myself, the latest version is at https://github.com/t0k4rt/phpqrcode. With the version there, SVG is implemented and working.

Related

Salt using openssl_random_pseudo_bytes

I'm working on a basic PHP login for the very first time using a udemy online course.
I'm really struggling already as my code, which is in the tutorial, gives an error when I open the page!
All I have, saved in a file called salt.php is:
<?php
$salt = openssl_random_pseudo_bytes(1024);
var_dump($salt);
?>
Seems pretty basic, and I'm running this with WAMP. But I just get an error message instead of outputting the random characters.
Fatal error: Call to undefined function openssl_random_pseudo_bytes() in C:\wamp\www\login-register\salt.php on line 3

Requesting assistance with 1 line of code regarding xajax

I am attempting to build a PHPMailer based email system for a basic website.
This is the line of code that is giving me trouble:
$xajax->printJavascript('xajax/');
Now, this is the tutorial I am using.
Regarding the above line of code, the tutorial says this:
How to use the code inside a webpage?
Place the form (variable), the function (and the includes) before of all html code. Next we need to include some JavaScript file in the documents HTML header (place also php tags):
$xajax->printJavascript('xajax/');
When I run all of the code (including: PHPMailer script; Ajax script), I get this error, on the aforementioned line of code.
Fatal error: Call to a member function on a non-object
So, my question is, do I need to in someway customize this code or make it run to a filepath of some ajax core file or something?
I would be willing to be $xajax is not defined. Try adding this after including the libraries but before including the call to that method:
$xajax = new xajax();
There may be some additional setup required by xajax. A more complete code example could help troubleshoot.

PHP Parts Property

I'm working on some code written by another developer and it is written in PHP. There is a line of code that is causing an error. I'm thinking that it is something you have to enable for PHP because it works just fine in another environment but doesn't work on the new environment and I haven't changed the code yet. The line is:
$structure->parts
$structure is a variable I've passed in but from a search online parts is a property. The error I'm getting says:
Undefined property: stdClass::$parts
Thanks for any help or ideas anyone might have.
Looks like parts doesn't exist there. Try running var_dump($structure) to get a better picture of what you're really dealing with.

PHP script stops without error message (Which error type?)

a PHP script stops without an error message, if I change the signature of a method of a class, which implements a intereface, e.g.:
interface A
{
public function somefunction();
}
class B implements A
{
public function somefunction(XY $xy);
{
...
}
}
This is an error of course, but there is no error message shown.
What is the name of this error type? (I already searched a lot, but with the wrong phrases obviously)
How can I log or output this error?
I'm using PHP 5.3.1 (with XAMPP for Windows 1.7.3)
(I used Zend Debugger with PHP < 5.3 earlier, where those erros were shown in the Eclipse console, but now I'm using XDebug.)
Thanks in advance for any hint!
put at the top of file and then try,
<?php
ini_set('display_errors',1);
error_reporting(E_ALL);
?>
If you still getting no output, please check your error_log.
RESOLVED
#ontrack Thanks, your hint directed me to the right direction:
I'm using an autoload function to load required classes (by using spl_autoload_register()). My implemention of my autoloader restrains all error messages... I did not know, that this causes such 'deeper' errors not to show up.
This was at least kind of stupid from my side, but I'm more happy, that I found the reason for this problem and I have learned something :-)
Many thanks to all your contributions! And sorry again, that I cannot edit my initial question anymore.
#outis Thanks, please read my comment
Put the following at the top of your script:
error_reporting(E_ALL);
It should report an error.
Something must be up with your configuration. When I try the sample code under PHP 5.3.2+XDebug 2.1.0, PHP complains:
Fatal error: Declaration of B::somefunction() must be compatible with that of A::somefunction()
The type of error is a substitution violation, since a B can't be substituted for an A in all situations.

Convert HTML to PDF with HTML_ToPDF class (PHP)

In my project, I'm using HTML_ToPDF PHP class, which uses html2ps script to convert from HTML to PDF file.
Recently I upgraded my production server to Debian 5 (Lenny) and, after that, HTML_ToPDF is no longer working:
convert() method from HTML_ToPDF class is returning this error:
Error: there was a problem running the html2ps command. Error code returned: 127. setDebug() for more information.
And, the output from html2ps call is:
/usr/bin/perl: symbol lookup error: /usr/lib/perl5/auto/Compress/Zlib/Zlib.so: undefined symbol: Perl_Tstack_sp_ptr
Any help would be appreciated, thanks!
[Edited]
After some tests, I've found that the problem happens only with HTML containing images ( tags). When html2ps founds the first image it crashes. Converting HTML without images works fine. Any idea? Thanks!
Try this
apt-get install perl=5.8.8-7etch6 perl-base=5.8.8-7etch6 perl-modules=5.8.8-7etch6 debconf-i18n=1.5.11etch2 liblocale-gettext-perl=1.05-1 libtext-iconv-perl=1.4-3 libtext-wrapi18n-perl=0.06-5 libtext-charwidth-perl=0.04-4 html2ps=1.0b5-2 libapache2-mod-perl2=2.0.2-2.4 libcompress-zlib-perl=1.42-2 libfuse-perl=0.07-2+b2 libhtml-parser-perl=3.55-1 libhtml-tree-perl=3.19.01-2 libio-zlib-perl=1.04-1 libwww-perl=5.805-1 perlmagick=7:6.2.4.5.dfsg1-0.14 snmpd=5.2.3-7etch4 xhtml2ps mysql-client=5.0.32-7etch8 mysql-client-5.0=5.0.32-7etch8 libdbd-mysql-perl=3.0008-1 libdbi-perl=1.53-1etch1
http://www.deberias.com
This is an issue with the initial conversion from HTML to PS. Usually due to poorly written HTML.
Can you show some examples of what you are trying to convert?
To be honest I've found wkhtmltopdf to be far better than html2ps, even though it's at a fairly early stage of development.
I wrote a blog about it, but if you don't want to read that basically it uses KHTML/Webkit's rendering engine to render the page which is a bit more sensible than the usual approach of writing a complete HTML renderer.
The distributed binary worked just fine on my Debian server, and frankly the results are excellent.

Categories