Showing entries 11 to 20 of 30
« 10 Newer Entries | 10 Older Entries »
Displaying posts with tag: PHP/MySQL (reset)
PHP Free Chat - Joining Chat Email Notification

I recently upgraded an install of PHP Free Chat to that latest version of 1.0 Final. However it was still lacking a feature to notify individual(s) that someone has joined the chat if they were not already in the chat application to begin with. I came across a posting explaining how to achieve this in PHP Free Chat at PHP Free Chat Forum. After a little reading and discussion I was able to implement the feature.

Here’s my modified version for the solution based on the forum posting. The pfcmail() function can be made to be way more versatile for any use, however for my use it was made to be simple and produce properly formated email messages.

Solution

  1. Create a new PHP file called pfcmail.php with the following lines of code.
[Read more]
Default Timezone in PHP, Not Working?

Since I started using PHP 5.x.x I started to experience incorrect time reported back through PHP using for example date(). I checked phpinfo() and found out that the default timezone was detected as America/Chicago. This was not the case as the server was configured for Canada/Saskatchewan (CST). I found out that I ended up having to directly set my timezone in php.ini file. I put the following in my php.ini file, then restarted Apache and the problem was resolved.

date.timezone = “Canada/Saskatchewan”

I’m not sure if this is a bug in PHP not detecting the timezone correctly. I tried searching through known …

[Read more]
Common Mistake - Echoing an Array

I’m sure most would agree when one does a programming mistake they are a lot of times trivial mistakes. However when one stares at the code for long periods of time we seem to go blind and then in the process of frustration loose all logically thinking as to what could be causing the problem. Here is one such problem with arrays.

Problem The value of the Array is not rendering. Instead you see array[0]. Solution Remove your single or double quotes around the variable representing the array. When one places single or double quotes around the array you are causing it to be treated as literal.

ShareThis

PHP - Populate HTML Select Element

There is many ways to populate vales into a HTML select element. Here is one example I’ve come up with.

PHP Code Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
      <select size="1" name="szFooBar[]" multiple="multiple">
< ?php
$i=0;
while($obResults = mysql_fetch_row($saResults))
{
    if ($_POST['szFooBar'] == $obResults[0])
    { $szSelectedValue[$i] = " selected=\"selected\""; }
    else { $szSelectedValue[$i] = ""; }
 
    printf("<option value=\"%s\"%s>%s\n",$obResults[0], $szSelectedValue[$i], $obResults[1]);
    $i++;
}
?>                                                   
</select>

[Read more]
PHP/MySQL Query Example

A basic MySQL query using PHP with commenting marked with //.

// SQL statement that will be sent to the MySQL database server.
$szQry = “SELECT column1, column2 FROM foo”;

// MySQL database login credentilas; host (127.0.0.1), username and password.
$szDBConn = mysql_connect(”host”,”username”,”password”);

// Select database using the login credentials provided above.
mysql_select_db(”database_name”, $szDBConn);

// Send SQL statement to database.
$saResults = mysql_query($szQry, $szDBConn);

// Fetch results retured back from the SQL statement.
$obResults = mysql_fetch_row($saResults);

[Read more]
MySQL Lost connection to MySQL server during query

For more than 3 hours I’ve been trying to find a solution to the error I kept receiving when doing a basic query to MySQL through PHP. It kept returning back to me “Lost connection to MySQL server during query”. Right away I went to my PHP, MySQL and Apache logs to find more information. I came back with nothing more than the error message I already received. So as I usually do off I went to Google and IRC for some help. Neither were leading into any direction to a solution. Even after finding the MySQL …

[Read more]
PHP/MySQL Query Example

A basic MySQL query using PHP with commenting marked with //.

// SQL statement that will be sent to the MySQL database server.
$szQry = “SELECT column1, column2 FROM foo”;

// MySQL database login credentilas; host (127.0.0.1), username and password.
$szDBConn = mysql_connect(”host”,”username”,”password”);

// Select database using the login credentials provided above.
mysql_select_db(”database_name”, $szDBConn);

// Send SQL statement to database.
$saResults = mysql_query($szQry, $szDBConn);

// Fetch results retured back from the SQL statement.
$obResults = mysql_fetch_row($saResults);

MySQL Lost connection to MySQL server during query

For more than 3 hours I’ve been trying to find a solution to the error I kept receiving when doing a basic query to MySQL through PHP. It kept returning back to me “Lost connection to MySQL server during query”. Right away I went to my PHP, MySQL and Apache logs to find more information. I came back with nothing more than the error message I already received. So as I usually do off I went to Google and IRC for some help. Neither were leading into any direction to a solution. Even after finding the MySQL …

[Read more]
How to Install PHP from Source

This installation example for Unix/Linux installs dependency support for Midgard CMS. Make sure Expat, zlib (comes with OpenBSD) and iconv are installed before proceeding. I have added additional configuration for MySQL (so the correct MySQL libraries are used), Microsoft SQL Server, apxs, XML, exif, dba and mbstring. Refer to the PHP configurator for details (# ./configure –help).

# ./configure –with-mysql=/usr/local –with-mssql=/usr/local –with-apxs –with-xml –with-zlib-dir=/usr/lib –with-expat –with-config-file-path=/var/www/conf –with-iconv=/usr/local/bin/iconv -–with-exif –-with-dba –-with-mbstring
# make
# make install
# make clean
# cp php.ini-recommended /var/www/conf/php.ini

Review/edit /var/www/conf/php.ini (path may vary) file to match your requirements. To meet the requirements of Midgard CMS you will require to do the following.

Add …

[Read more]
Midgard/PHP CLI Segmentation Fault

Midgard CMS will crash PHP CLI if its loaded in the global php.ini. Add PHP settings to your Apache HTTP Server configuration file /var/www/conf/httpd.conf (path may vary). Put the below PHP settings into your httpd.conf file. This may also go into your Midgard httpd.conf if you want. Make sure to restart your Apache HTTP Server so configuration changes take affect.

php_value extension midgard.so
php_value register_globals 1

ShareThis

[Read more]
Showing entries 11 to 20 of 30
« 10 Newer Entries | 10 Older Entries »