php

Error using PHP cURL with SSL certificates

I'm trying to write a PHP script using cURL that can authorize a user through a page that uses an SSL certificate, in addition to username and password, and I can't seem to get past the SSL cert stage. In this case, curl_setopt($handle, CURLOPT_VERIFYPEER, 0) unfortunately isn't an option. The certificate is a required part of authenti...

LGPL for PHP applications

I have a discussion with a friend regarding the Lesser GNU General Public License, LGPL, for server side code - in this case a PHP library. He argues that since the PHP application is not distributed to the user - it is merely running on the server - he doesn't have to re-distribute the library sources after he modified it. This is basic...

Need some suggestion for a database schema design

I'm designing a very simple (in terms of functionality) but difficult (in terms of scalability) system where users can message each other. Think of it as a very simple chatting service. A user can insert a message through a php page. The message is short and has a recipient name. On another php page, the user can view all the messages ...

strange javascript form behaviour.

I am generating the following html form with this php: echo "<form name=\"userForm\"> Username: <input type=\"text\" name=\"username\" /> <br /> First name: <input type=\"text\" name=\"firstname\" /> <br /> Last name: <input type=\"text\" name=\"lastname\" /> <br /> <input name=\"Submit\" type=\"submit\" value=\"Update\" onclick=\"submi...

PHP vs template engine

I'm currently having a discussion about the choice between php as a template engine versus a template engine on top of php. What is your choice, and why? I say, why another template engine, if php is an template engine itself. ...

displaying the contents of a mysql query, only first field works

I am using a mysqli prepard query with php, the code is: $retreiveQuery = 'SELECT username, firstname, lastname FROM USERS WHERE username = ?'; if ($getRecords = $con->prepare($retreiveQuery)) { $getRecords->bind_param("s", $username); $getRecords->execute(); $getRecords->bind_result($username, $firstname, $lastnam...

How to show 'Save as' dialog box using PHP for text files

How can I show the 'Save as' dialog box using PHP which will ask the user to download a string as a text file? Basically I will retrieve some values from the database, and want then to be able to download a .txt file which contains this data. ...

Migrating to a newer version of PHP

I notice that a couple of weeks ago PHP 5.3 reached release candidate stage (woo!), but then seeing the list of already-deprecated functions finally being removed, that got me thinking about whether it would break any of my old code. Short of doing a suck-it-and-see test (installing on a test server and trying it out), are there any sor...

Image in a PHP File

I have a text link in a php file, but I want to make it an image link. The current code is. $link="<a target='_blank' href='/stuff/morestuff/?url=".rawurlencode($url)."'>".t("Add")."</a>"; Now instead word "Add" I want to have an image in there. My current syntax to do that isn't working though, my error is Parse error: syntax error,...

Updating PHP.ini on a GoDaddy Hosted site.

I am pretty new to PHP programming so I apologize if I am missing the obvious. I have a site hosted at GoDaddy (Windows, PHP5, MySQL 5). I read this article: GoDaddy FAQ and created a php5.ini file in the root folder but when I try to connect to the database, I get the following error: Fatal error: Call to undefined function mysq...

Screenscraping the ugliest HTML you've ever seen in your life

I'm using PHP and libtidy to attempt to screen scrape what might possibly be the most horrendous and malformed use of HTML tables in history. The site closes few table, tr, td, font, or bold tags and consistently nests many different layers of tables within tables. Example snippet: <center> <table border="1" bordercolor="#000000" cells...

Why is using a mysql prepared statement more secure than using the common escape functions?

There's a comment in another question that says the following: "When it comes to database queries, always try and use prepared parameterised queries. The mysqli and PDO libraries support this. This is infinitely safer than using escaping functions such as mysql_real_escape_string." Source So, what i want to ask is: Why...

Parsing multiple XML feeds with PHP into one sorted array

I want to create a sortable list that looks something like $VAR1[0], $VAR2[0]... $VAR1[1], $VAR2[1]... The data comes from multiple same structured xml files: $xmlfile=" <Level1> <Level2> <Level2Item VAR1="1" VAR2="2" ... /> <Level2Item VAR1="4" VAR2="5" ... /> <Level2Item VAR1="7" VAR2="8" ... /> </Level2> </Level1>"; //Ex...

PHP - exec() vs system() vs passthru()

What are difference? Is there a specific situation or reason for each function? If yes, can you please give some examples of those situations? PHP.net says that they are used to execute external program. From examples I see, I don't see any obvious difference. If I were to simply run a script (bash or python), which function do you rec...

Mysql stored procedure : cant run from PHP code

I have below stored procedure to check the user name availability DELIMITER $$; DROP PROCEDURE IF EXISTS tv_check_email$$ CREATE PROCEDURE tv_check_email (IN username varchar(50)) BEGIN select USER_ID from tv_user_master where EMAIL=username; END$$ DELIMITER ;$$ when i run this from my mysql front end tool, it is working fine cal...

PHP: what's an alternative to empty(), where string "0" is not treated as empty?

In PHP, empty() is a great shortcut because it allows you to check whether a variable is defined AND not empty at the same time. What would you use when you don't want "0" (as a string) to be considered empty, but you still want false, null, 0 and "" treated as empty? That is, I'm just wondering if you have your own shortcut for this: ...

mysql doesn't start from the control panel

hi i recently installed xampp 1.7.0 , but when i try to start the mysql from the control panel it gives error: Busy.... ERROR: Mysql service not started [-1] and when i start from the mysql_start.bat it starts !! why is this happening why mysql is not starting from xampp control pannel? ...

Is it bad to put a MySQL query in a PHP loop?

I often have large arrays, or large amounts of dynamic data in PHP that I need to run MySQL queries to handle. Is there a better way to run many processes like INSERT or UPDATE without looping through the information to be INSERT-ed or UPDATE-ed? Example (I didn't use prepared statement for brevity sake): $myArray = array('apple','or...

Zend Framework: Some email users get errors when trying to open PDF attachments?

I'm having a strange problem and not sure how to troubleshoot it. I have created a script in one of my Zend Framework controllers that allows an administrator to log in, upload a PDF, and send as an attachment to everyone subscribed to the mailing list. The problem is that some users report that they are unable to open the PDF attachment...

Converting HTML to PDF using PHP?

Is it possible to convert a HTML page to PDF using PHP, and if so, how can it be done? Specifically, the page is an invoice generated dynamically. So I would like it loaded using: http://site.com/invoices/3333 And the HTML output would have to be converted to PDF. Any good libraries that do this will be fine. ...