[QUOTE=PhilEaton;1317049]Yeah I saw that and changed it but in my original code it still didn't work. But it's all good now thanks a lot![/QUOTE]
No problem! Glad it's all fixed! :)

Regarding for your original code, the reason why the IP displayed but you couldn't click the link is because you were missing an = between the href and the first quote. Try this:

So is it solved? If not, can you give us a sample of some of the URL's you try? The URL you gave in the first post should work fine and did work fine when I tried it. If it doesn't, have you set your charset to the appropriate one with the meta charset tag?

[QUOTE=ﻼim;1315151]:D yeah, you're really good at samples- no second thought with that PHP man (former PMC man). Ϋ[/QUOTE]
Never gotten that before, but PHP Man works too. I'll have to make note of that somewhere on the new site! :)

You can use [icode] [/icode] as an empty space in any empty table columns and rows. It's HTML's way of representing a space. In case you haven't noticed, a space along usually doesn't work, and multiple spaces (or a new line) do no appear. [icode] [/icode] is the answer to the multiple space (or single space alone) problem.

Yes it will! Php.net also has [URL="http://php.net/manual/en/features.file-upload.php"]a few pages on file uploading[/URL]. You may want to look at them too!

Tizag has [URL="http://www.tizag.com/phpT/fileupload.php"]a great tutorial on getting started with PHP uploads[/URL]. Read over it and post back if you have any questions.
[i]Tip: Be sure to check the file type so users can't upload exe's, dll's or any non-image files.[/i]

ﻼim commented: really good at php. Ϋ +0

[b]EDIT:[/b] To DaniWeb: Please update your posting system so if my token has expired when I post, I don't have to hit the back button and re-type everything.

Alright, take two. The gist of it is that there are two problems. The simpler of the two to fix is the problem regarding the URL. To access the var parameter you should use [icode]$matches[1][/icode] instead.
The second problem involving the style can be fixed in a similar manner as above, but also requires a Regex fix. Here is your revised code:
$this->avatar = $post->find('div[class=shell] td');
foreach($this->avatar as $avatar) {
pregmatch('/url("([a-z0-9-.\/]*\/)?([a-z0-9-_\%.]+)")/i', $avatar->style, $matches); // Thanks "FlashCreations"/"PhpMyCoder"!
$this->avatar = $matches[2];
echo $this->avatar . 'Hello world!';

Hope this fixes everything! :)

Well you'll need to find a way to get the short code SMS to communicate with your PHP script. I have no idea how to do this. When it comes to the PHP, it seems easy enough.
switch(strtolower($_GET['command'])) {
case 'pizza':
$r = mysql_query("SELECT * FROM pizza ORDER BY popularity DESC LIMIT 5");
if(mysql_num_rows($r) != 0) {
while($arr = mysql_fetch_array($r)) { echo $arr['name']; }
} else { echo "No pizzas found. Sry!"; }
This would work assuming you have already connected to your database and your table structure is similar to my little demo. You would also need to have texts to the number routed to your script, assuming the command parameter contains the contents of the text and the stdout is returned to the sender of the text message.

For the first URL, you can retrieve the var parameter by exploding the string returned by parse_url. You can also use a Regex if you want.
$param = explode('&', parse_url($url, PHP_URL_QUERY));
if(is_int($param['var'])) {
//$param['var'] for the var parameter


preg_match("/var=([0-9]+)/i", $url, $matches);
//$matches[1][0] for the var parameter
[b]EDIT:[/b] As a rule, everything is usually faster than a Regex...Keep that in mind :)

The URL from the CSS command can be found with a simple Regex:
pregmatch('/url("([^\/]+\/)*([a-z0-9-\%.]+)")/i', $css, $matches);
//$matches[2][0] contains the file name from the URL

If either Regexes need to be refined or you need clarification, just write back!

Assuming that the downloads are routed through a PHP script, it should be simple enough to record user download data. The devil is in the database and how you store this information. Here's my recommendation:
You only need one table to store download information along with hit counts. I recommend three columns for tracking download numbers: A total downloads column, a weekly downloads column, and a monthly downloads column. When a user requests a file download, simply increment all three fields for that file by one.
You stats are simply a MySQL query away:
//Get total downloads
mysql_query("SELECT downloads FROM files WHERE id='".$id."'");

//Get weekly downloads
mysql_query("SELECT weeklyDownloads FROM files WHERE id='".$id."'");

//Get monthly downloads
mysql_query("SELECT monthlyDownloads FROM files WHERE id='".$id."'");
*Depending on what you name your columns

You will need CRON jobs to run once every Sunday and once at the end of every month. The weekly script should contain something along the lines of:
//Set all the files to a 0 weekly download count for the new week
mysql_query("UPDATE files SET weeklyDownloads=0");

As you can assume the monthly CRON will look something like this:
//Set all the files to a 0 monthly download count for the new month
mysql_query("UPDATE files SET monthlyDownloads=0");

**These all assume that you have already connected to MySQL and a DB, and perform the necessary [icode]mysql_fetch_array()[/icode]'s after if the query requires it.


phplover commented: Fantastic post made in helping me :) +1

Actually funny enough, he does have some sort of security in place. The tag was removed because of it's containing < and > (which generally signifies an HTML tag). What needs to be done though, is not stripslashes or addslahses. It's mysql_real_escape string():

include("contentdb.php"); //Connect to MySQL
include("data.php"); //Declares Variables
//Perform query
if(mysql_query("INSERT INTO $table (code) VALUES ('".mysql_real_escape_string($code)."')")) echo "

Your Code was Added to the Quiz.

Return to the Code List

To really diagnose the problem, we would need to see the data.php file. Can you post it?

Well then try this. And yes it will still work. You just have to do is change the way the data is added to the class. Check the readme file for more (It should be similar though, what does your demo query return?).

Try this with the [b]old query:[/b]

  • PhpMyCoder Paginator *
  • Created By PhpMyCoder *
  • 2010 PhpMyCoder *
  • ------------------------------- *
  • You may use this code as long *
  • as this notice stays intact and *
  • the proper credit is given to *
  • the author. *

class pmcPagination {
private $pageVar = "page"; //$_GET variable to get page # from
private $items = array(); //Array of items to paginate
private $resultsPerPage = 10; //Results to be displayed per page
private $paginated = false; //Has the paginate() function been called?

public function __construct($resultsPerPage="", $pageVar=0, $items=NULL)
    //Set pageVar if arg is valid
    if($this->isValidPageVar($pageVar)) $this->pageVar = $pageVar;

    //Set resultsPerPage if arg is valid
    if($this->isValidResultsPerPage($resultsPerPage)) $this->resultsPerPage = $resultsPerPage;

    //Add items passed

public function add($items)
    //If the item is null, exit function
    if(is_null($items)) return;

    //If arg is not an array, make it one
    if(!is_array($items)) $items = array($items);

    //Cycle through items passed
    foreach($items as $item)
        //Add them to the $items array if they are valid
        if($item instanceof paginationData) $this->items[] = $item; 

public function paginate($resultsPerPage="", $pageVar=0, $items=NULL)
    //Prevent set function form changing values
    $this->paginated = true;

    //Set pageVar if arg is valid
    if($this->isvalidPageVar($pageVar)) $this->pageVar = $pageVar;
    //Set ...

So does the date work now? If so, that's [b]great[/b]! Regarding the events: Did you check and see if they are in the database? Also, did you check their expiration date (I remember something about the expiration date being filtered in MySQL). To test this, you can perform the query you use to get the programs and attempt to find the missing ones. If they aren't their, the problem is with you query (I can help with this). If they are there, it's a slight bug in my code (Which I can also fix!).

Oh no! Well right about now I don't know what to tell you. I've tried the code on my server, and it works fine. I also just ensured that the date formats you gave me from MySQL formats properly into the UNIX Epoch (which it does). Are you running this site on your own dev server (using XAMPP, WAMP, etc), or do you have it setup on a testing server?

whitestream6 commented: Excellent source of help. Much recommended. +2

Inside a complex syntax brackets ([icode]{$var}[/icode]) you can call any function with a return value that can be converted to casted to a string. So using your code that would be:
$message .= "XXXX-XXXX-XXXX-{substr($_GET['cc_number'] , -4, 4)}";

//Or this....
$message .= "XXXX-XXXX-XXXX-".substr($_GET['cc_number'] , -4, 4)."";

//Or even this...
$message .= "XXXX-XXXX-XXXX-";
$message .= substr($_GET['cc_number'] , -4, 4);
$message .= "";
The first or second ones make most sense to me, so I would chose one of them, but it's totally up to you!

drewpark88 commented: Helped me alot! +1

I have updated the script again to fix the notices (Your setup seems to be very picky about $_GET and $_POST variables!). To achieve what you are looking for, you will need some simple css. With the current code, all you need to do is add this style to the top of your page. The only other thing you will need to do is enclose the navigation inside a div with and id of nav like this:



And here's the CSS to include:

nav { font: normal 13px/14px Arial, Helvetica, sans-serif; }
nav a { background: #EEE; border: 1px solid #DDD; color: #000080; padding: 1px 7px; text-decoration: none; }
nav strong { background: #000080; border: 1px solid #DDD; color: #FFF; font-weight: normal; padding: 1px 7px; }


The only thing it doesn't do is apply the box (possibly a grayed out one) to the disabled Next and Previous links. If You wish for this to happen, reply back and I'll make the slight changes that are necessary for this to happen.

I just wrote a pagination script (for another DaniWeb User). Let me find the link to it and I'll show you my code...

Here's the link:

I believe mine does 10 a page, but that is easily fixed. Just read the Readme in the ZIP file and you should find something about changing the items per page. If you can't, you can change the number of results per page by passing the number to the constructor of the pmcPagination class when you create it:
//pmcPagination(resultsPerPage, getVariable, data)
$instance = new pmcPagination(20, "page", new paginationData("test"));

You can also set the results per page by calling the function [icode]setResultsPerPage()[/icode] with the number of results per page as the only parameter.

You can even set this number when calling [icode]paginate()[/icode] the same way as you can when creating the instance of pmcPagination.

Yes, it could be. I would suggest a static color picker (Most users don't know about hex's) or a backend system that checks a color before it is placed in the database. This way you can ensure that a color is always displayed (Because the user could have entered some color followed by a semicolon and some more css. The user could have even inserted javascript with this loose input system. This is a horrible XSS Vulnerability.)

diafol commented: really good point - he needs a 'real colour' dropdown or something +5

Yeah, I was guessing that something like this didn't work. It's a shame too, because multi-language highlighting in a single code block would be pretty cool.

You know I'll try it:

CODE Tag Test


[b]EDIT:[/b] Well it looks like it doesn't work. Oh well! Thanks anyways.

How about including a PHP file which contains the javascript you wish to be able to access the PHP variables. Then in this included file pass the PHP variables to the script. You can not alter a PHP variable from javascript, but this should suffice. Here's an example:

//Set some vars that JS can access
$something = "Hello Javascript!";
$daniweb = "awesome";
$scriptby = "PhpMyCoder";

PHP Vars in JS Example


//Add the javascript vars with the script tag
echo "\n" +
"something = " . $something . ";\n" +
"daniweb = " . $daniweb . ";\n" +
"scriptby = " . $scriptby . ";\n" +

//Now either attach an external JS file
// echo "";
//Or add the Javascript to this file
echo "\n" +
" function phpVars() { alert(something + ' Daniweb is ' + daniweb + '! Script coded by ' + scriptby + '.') }\n" +

You need to connect to a database (Such as MySQL) then perform the queries in your arrays (You also need to unescape the quotes after the "tfr", it will stop the query from working).
Try something like this:
//Why do all three of these have the same name
//Is it your intention to reset them three times?
$qualifiers_array[0] = "SELECT FROM table WHERE trk is not null AND WHERE tfr = '1'";
$qualifiers_array[1] = "SELECT
FROM table WHERE tfr='2'";
$qualifiers_array[2] = "SELECT * FROM table WHERE tfr='3'";


Database Results Filter Name Profit Winners Qualifiers %age
Borderline commented: Thank you! +2

You can check for a search by the employee's name. Then you can check for a space. If there is a space you can split the two names with explode and then perform a query that matches first and last name. If there isn't any spaces only perform a query for the first or last name (Depending on what you want).
if(isset($_POST['searchType'])) //Check first, get values later

switch ($method)
    case 'EmployeeFName': //Switch is not like if...you don't need an expression, just a value will do
        if(empty($_POST['query'])) exit("Please Fill in a name of an employee you want to search. Click <a href=search.php>here</a> to go back.</p>");
            echo"<i>Your search for {$search} had the following results:</i>";
            //Here's the magical splitting of the names
            $arr = explode(" ", $search);
            $search_first = $arr[0];
            $search_last = $arr[1];

            $query = mysql_query("SELECT * FROM Employee WHERE EmpFName = '".$search_first."' AND EmpLName = '".$search_last."'");
            $result = mysql_query($query);
            if(mysql_num_rows($result)==0) echo exit("<font color='red'>No Record Found</font>");
            echo"<table class='full'>";
            echo"<th></th><th>ID</th><th>Employee Name</th><th>Title</th><th>Team</th><th>Department</th></tr>";
            while ($row = mysql_fetch_array($result)) //Ohh! You can only fetch from a result RETURNED by mysql_query, not the actual query
                //No need to setup individual variables...just use the $row array!
                echo"<tr><td class='view'><form action='employee.html' method='post'><div><input type='submit' value='View' class='button' /></div></td><td name='userID' class='id'>".$row["EmployeeID"]."</td></form><td name='userName' class='record'>".$row["EmployeeFName"];." ".$row["EmployeeLName"]."  </td><td name='userTitle' class='record'>".$row["EmployeeTitle"]."</td><td name='userTeam' class='record'>".$row["EmployeeTeam"]."</td><td name='userDept' class='record'>".$row["EmployeeDepart"]."</td></tr>";
    //And on, and on, etc.


function mysqlConnectAndSelect()
mysql_select_db("titans", $con);
There are also lots more problems beyond this one. I'd be glad to fix them ...

[QUOTE=pritaeas;965973]My suggestion stated before the query...

$link = array ();
$result = mysql_query($sql):
while ($row = mysql_fetch_array($res))
Exactly..though it does need one minor fix! (But I'm sure you knew this!):
$link = array();
$result = mysql_query($sql); //<-- Semicolon
while ($row = mysql_fetch_array($res))
$link[] = $row;
Also, I believe the problem was that instead of [icode]$links[/icode], [icode]%links[/icode] as used, but your solution provides a safety if there are no rows returned (Which is a good thing to have!).

You made the same error as Newbi..the correct code is below (Don't worry about it, I've made worse mistakes :D):
while($info = mysql_fetch_array($result))
The reason for this is as Dukane explained...When you perform a query the query string is executed with the [icode]mysql_query()[/icode] function. This function returns a special MySQL Result that you can then pass to [icode]mysql_fetch_array()[/icode] or any other MySQL Result functions.

Dukane commented: OOOPS! I meant to type out what you typed out, but thank you for pointing out my mistake! Good catch! +3

That's great that you got it to work! If you don't have any more questions...would you please mark this thread as solved?

woocha commented: thanks for the help !! +3

You would probably want to use a MySQL table to store the emails. Then all you would have to do is write a php script that you can use to send email (Just make sure to password protect it for security!!).
PHPList is a pre-coded, easily customizable PHP mailing list application. Check it out on [URL="http://www.phplist.com/"]their website[/URL] (Note to Mods: I'm not advertising this product as it's free. I'm simply providing a pre-coded resource that might be easier to understand/use).

Epic Tissue commented: helpful and informative +1

Ok then, try this:

$del="DELETE FROM online WHERE user='$user'";

      echo "<h3>Member Offline</h3>\n";
     echo "<h3>Failed to Logoff</h3>\n";

 //Remove the Session Vars
 $_SESSION = array();
 if (isset($_COOKIE[session_name()])) {
      setcookie(session_name(), '', time()-42000, '/');


include "index.php";

Shanti C commented: Good Helping.... +2