CSS: having a popup appear on graphic mouse over

You have a graphic that if the user mouseovers you want a popup.

How the heck do you do that?

your original code looks like this:

<img align="center" src="img/dracko120.jpg">

You need to declare a div with a lable for the image file and what you want to do

assign a dumy href command (that goes nowhere)
put what you want to do between the span labels.

so my code now looks like this:

<div id="searchpop">
<a href="#">
<img align="center" src="img/dracko120.jpg" />
<span>
<?php $dracko->dsp_search_form(); ?>
</span>
</a>
</div>

Now I have to lay out the css

the first entry in the css is the div id, the a in <a href="#">, the span (this says don’t display)
the second entry tells it what to do on mouse over

#searchpop a span {display: none;}

#searchpop a:hover span {display: block;

position: absolute; top: 200px; left: 0; width: 125px;

padding: 5px; margin: 10px; z-index: 100;

color: #AAA; background: black;

font: 10px Verdana, sans-serif; text-align: center;

}

—have fun
john

How to get a file extension using php

Question : How to get file extension using php
I want to extract the file extentions from a file name. How do i do that from php?

Answer
There are several ways to do that. First is using the combination of strrpos() and substr() function like this :

$ext = substr($fileName, strrpos($fileName, ‘.’) + 1);

For example, if $fileName is my-new-house.jpg then strrpos($fileName, ‘.’) will return the last location a dot character in $fileName which is 15. So substr($fileName, strrpos($fileName, ‘.’) + 1) equals to substr($fileName, 16) which return ‘jpg’

The second is using strrchr() and substr() :

$ext = substr(strrchr($fileName, ‘.’), 1);

strrchr($fileName) returns ‘.jpg’ so substr(strrchr($fileName, ‘.’), 1) equals to substr(‘.jpg’, 1) which returns ‘jpg’

PHP Forms and User Input

PHP Forms and User Input

The PHP $_GET and $_POST variables are used to retrieve information from forms, like user input.
PHP Form Handling

The most important thing to notice when dealing with HTML forms and PHP is that any form element in an HTML page will automatically be available to your PHP scripts.

Form example:

<html>
<body>

<form action=\"welcome.php\" method=\"post\">
Name: <input type=\"text\" name=\"name\" />
Age: <input type=\"text\" name=\"age\" />
<input type=\"submit\" />
</form>

</body>
</html>

The example HTML page above contains two input fields and a submit button. When the user fills in this form and click on the submit button, the form data is sent to the \"welcome.php\" file.

The \"welcome.php\" file looks like this:

<html>
<body>

Welcome <?php echo $_POST[\"name\"]; ?>.<br />
You are <?php echo $_POST[\"age\"]; ?> years old.

</body>
</html>

A sample output of the above script may be:

Welcome John.
You are 28 years old.

The PHP $_GET and $_POST variables will be explained in the next chapters.
Form Validation

User input should be validated whenever possible. Client side validation is faster, and will reduce server load.

However, any site that gets enough traffic to worry about server resources, may also need to worry about site security. You should always use server side validation if the form accesses a database.

A good way to validate a form on the server is to post the form to itself, instead of jumping to a different page. The user will then get the error messages on the same page as the form. This

Solve PHP Fatal error: Allowed memory size of 8388608 bytes exhausted

This error message can spring up in a previously functional PHP script when the memory requirements exceed the default 8MB limit. Don’t fret, though, because this is an easy problem to overcome.

To change the memory limit for one specific script by including a line such as this at the top of the script:

ini_set("memory_limit","12M");

The 12M sets the limit to 12 megabytes (12582912 bytes). If this doesn’t work, keep increasing the memory limit until your script fits or your server squeals for mercy.

You can also make this change permanently for all PHP scripts running on the server by adding a line like this to the server’s php.ini file:

memory_limit = 12M

Keep in mind that a huge memory limit is a poor substitute for good coding. A poorly written script may inefficiently squander memory which can cause severe problems for frequently executed scripts. However, some applications are run infrequently and require lots of memory like importing and processing a big data file.

how to make a comment/discussion board in PHP

Comment Board
This is a tutorial that shows you how to make a comment/discussion board like those on this site using PHP and mySQL. there are three files: comments.php, which displays the comments, commentadd.php, which processes the comment, and commentform.html which is simply a form that can be placed in any page manually or per SSI (server side includes). I realize that it is possible to have all three components in one file, but we are using this multifile method for tutorial functionality

Sponsors – Spoono Host
The Database
First, you need to create a database called "comments"
Then, use this code to create the table:

CREATE TABLE `comtbl` (
`postID` INT NOT NULL AUTO_INCREMENT ,
`postTITLE` TEXT NOT NULL ,
`posterNAME` TEXT NOT NULL ,
`posterEMAIL` TEXT NOT NULL ,
`postTIME` TIMESTAMP NOT NULL ,
`postTXT` TEXT NOT NULL ,
PRIMARY KEY ( `postID` )
);

The Comment Viewing Page COMMENTS.PHP
First we need to connect to the database/table, where username/password correspond to your username and password: r

$dbcnx = mysql_connect("localhost", "username", "password");
mysql_select_db("comments");

Next, we need to query the table, and sort it by ID Descending:

$result = mysql_query("SELECT * FROM comtbl ORDER BY postID DESC");
if (!$result) {
echo("Error performing query: " . mysql_error() . "");
exit();
}

Now we have fields to send into variables; and because we want it to show posts, we need a while loop (which repeats the query until the table completely read):

while ($row = mysql_fetch_array($result) ) {
$msgTxt = $row["postTXT"];
$msgId = $row["postID"];
$SigName = $row["posterNAME"];
$SigDate = $row["postTIME"];
$msgTitle = $row["postTITLE"];
$url = $row["posterEMAIL"];

Ok. now here’s the hard part: because i decided to use MySQL’s TIMESTAMP fuction (which automatically enters the time of an addition to a table), i need to split up the postTIME string using the php substr() function (where $yr will give the year, $mo the month, etc):

$yr = substr($SigDate, 2, 2);
$mo = substr($SigDate, 4, 2);
$da = substr($SigDate, 6, 2);
$hr = substr($SigDate, 8, 2);
$min = substr($SigDate, 10, 2);

Now since not everyone is familiar with military time, we have to replace hours like 15 and 22 with more user-friendly noes like 3 and 10, but at the same time add PM if its past noon, and add AM if its not:

if ($hr > "11") {
$x = "12";
$timetype = "PM";
$hr = $hr – 12;
}else{
$timetype = "AM";
}

Heres the last bit before we actually display the data. If the user decides to leave the Email field blank, we’ll insert a ‘#’ into the link on his name. If he filled it out, then we’ll insert the ‘mailto:’ in front of the email address:

if (!$url) {
$url = "#";
}else{
$stat = $url;
$url = "mailto:" . $url . "";
}

FINALLY, we get to display the row of data, and close out the loop, thus finishing the php. Here the code is followed by an example of how it will be printed (please realize that you can change how it looks at any time just by moving the variables within the echo statement)

echo("

$msgTitle $msgTxt

$hr:$min $timetype | $mo/$da/$yr | $msgId, $SigName

");
}

Message Title Text within the message, blah blah

Hour:Minute AM/PM | Month/Day/Year | Message ID, Name with email link

Form Processing: COMMENTADD.PHP
Whew! Ok this file does the actual processing (adding) of the comments. First we’ll set the variables passed through HTTP Post into a variable, then insert it into the database. Please remember to change the username and password.

$assume = $_POST[‘assume’];
$posterEMAIL = $_POST[‘postemail’];
$postTXT = $_POST[‘posttxt’];
$posterNAME = $_POST[‘poster’];
$postTITLE = $_POST[‘posttitle’];

if ($assume == "true") {

$dbcnx = mysql_connect("localhost", "username", "password");
mysql_select_db("comments");

$sql = "INSERT INTO comtbl SET posterNAME=’$posterNAME’, posterEMAIL=’$posterEMAIL’,
postTXT=’$postTXT’, postTITLE=’$postTITLE’";

if (mysql_query($sql)) {
echo("

Your comment has been added

");
} else {
echo("

Error adding entry: " . mysql_error() . "

");
}
}

OK, thats it for PHP, now all we need is some javascript to make it go right back to the comments page or to any other page you want (remember to close ur php tags!):

OK! Heres for the form! COMMENTFORM.HTML This is basically just a form that sends all the data into commentadd.php to be processed.