Create PDF file using PHP

I have used TCPDF with much success to generate PDF files programatically using PHP. And to generate word documents: http://www.phpdocx.com/ (this is a paid solution).

Call to undefined function curl_init().?

If you’re on Windows: Go to your php.ini file and remove the ; mark from the beginning of the following line: After you have saved the file you must restart your HTTP server software (e.g. Apache) before this can take effect. For Ubuntu 13.0 and above, simply use the debundled package. In a terminal type the following to install … Read more

How do I make a simple crawler in PHP?

Meh. Don’t parse HTML with regexes. Here’s a DOM version inspired by Tatu’s: Edit: I fixed some bugs from Tatu’s version (works with relative URLs now). Edit: I added a new bit of functionality that prevents it from following the same URL twice. Edit: echoing output to STDOUT now so you can redirect it to whatever file you want … Read more

Print array to a file

Either var_export or set print_r to return the output instead of printing it. Example from PHP manual You can then save $results with file_put_contents. Or return it directly when writing to file:

Fatal error: Call to a member function bind_param() on boolean [duplicate]

The problem lies in: The prepare() method can return false and you should check for that. As for why it returns false, perhaps the table name or column names (in SELECT or WHERE clause) are not correct? Also, consider use of something like $this->db->conn->error_list to examine errors that occurred parsing the SQL. (I’ll occasionally echo the actual SQL statement strings and paste into phpMyAdmin to test, … Read more

How can I do ‘insert if not exists’ in MySQL?

Use INSERT IGNORE INTO table. There’s also INSERT … ON DUPLICATE KEY UPDATE syntax, and you can find explanations in 13.2.6.2 INSERT … ON DUPLICATE KEY UPDATE Statement. Post from bogdan.org.ua according to Google’s webcache: 18th October 2007 To start: as of the latest MySQL, syntax presented in the title is not possible. But there are several very easy ways to accomplish … Read more

How do I pass JavaScript variables to PHP?

You cannot pass variable values from the current page JavaScript code to the current page PHP code… PHP code runs at the server side, and it doesn’t know anything about what is going on on the client side. You need to pass variables to PHP code from the HTML form using another mechanism, such as … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)