mschroeder 251 Bestower of Knowledge Team Colleague

can you put var_dump($perm); in your code prior to the case statement and post the output here? I'm going to guess either perm is not being set or is not what you expect it to be.

mschroeder 251 Bestower of Knowledge Team Colleague

Hi,

I am trying to print different messages based on what is selected. The selections are stored in a database as $perm, and the options are low, intermediate and high. I am using switch, however i only get the first case printed:

$low = "Low";
$int = "Intermediate"; 
$high = "High "; 

switch($perm) {
     case $perm == $low: echo "Low perm <br>"; break;
     case $perm == $int: echo "Intermediate perm <br>"; break;
     case $perm == $high: echo "High perm <br>"; break;
     default: echo "No information has been provided. ";
}

I have tried giving the options numerical values, however, when i retrieve the results they are still strings so comparint $perm == 1, 2, or 3 just prints the default message. Any help appreciated.

switch($perm) {
     case 'Low': 
         echo "Low perm <br>"; 
     break;
     case 'Intermediate': 
         echo "Intermediate perm <br>"; 
     break;
     case 'High': 
         echo "High perm <br>"; 
     break;
     default: 
         echo "No information has been provided. ";
}
mschroeder 251 Bestower of Knowledge Team Colleague

For new code, strtotime really should be avoided. While we are a considerable amount of time away from Y2k38 and I really don't think you would run into an issue, if your script would ever need to process a date after 2038, maybe like the end date of a 30yr mortgage or something, strtotime will fail. This has been addressed in the DateTime object built into PHP since 5.2.

Now I hope you're working on a version of php > 5.2 as there really is no reason to be on anything less.

$date = new DateTime("{$startdate} {$starthour}:{$startmin}");
$date->modify("+{$hour} hours +{$minute} minutes");
echo $date->format('Y-m-d H:i:s');
pietpiraat commented: good explanation, great code +1
mschroeder 251 Bestower of Knowledge Team Colleague

Except count() is approximate when used on innodb tables, possibly all transactional table types. Just something to keep in mind.

mschroeder 251 Bestower of Knowledge Team Colleague

Your first example would require returning a potentially massive data set from the database simply for a count so I wouldn't suggest that.

I've seen the second one mentioned when dealing with massive datasets as well. Usually in conjunction with a set of triggers that when an row is inserted automatically increment the count and when a row is removed automatically decrement the count. This would be best stored in a separate table that contained only count values in my opinion.

Your other option would be the COUNT() function. Although with out benchmarking it I don't know if it would be any faster or slower than your first proposal.

mschroeder 251 Bestower of Knowledge Team Colleague

There are a lot of very informative threads on this topic on this very forum. But I'll elaborate on my previous statement.

Hashing is not encryption. SHA1 and MD5 are hashing algorithms. You pass them data and they generate a unique hash from that data. There is no magic function that turns the hashed value back into your data. However, MD5 has proven to be an ineffective hashing algorithm for quite some time, due to collisions e.g. two unique strings that generate the same hash. There have also been breakdowns in the SHA1 algorithm to my understanding. Both of those algorithms should be avoided in my opinion in lieu of better algorithms such as sha-256, sha-512, whirlpool etc.

Salting a hash means to append or prepend (or both) some form of trivial data to make the hash more complex. So lets say our salt is 'a1b2c3d4f5' and our user chooses the password of 'test'. When you hash just the password of 'test' => (a94a8fe5ccb19ba61c4c0873d391e987982fbbd3), you've created a hash that probably exists in a rainbow table (a database of strings and their hashes) because the hashed string is so common. If you append or prepend the salt to it. The string that gets hashed is now: 'a1b2c3d4f5testa1b2c3d4f5' => (c297373704eebdd3154872d23a7eb1a27f751e99). So our 4 character string is now a 24 character string of mostly gibberish. Essentially if your database was compromised the theory is by salting your hash with nonsense you've created a more secure hash that an attacker won't be …

andydeans commented: brilliant +2
mschroeder 251 Bestower of Knowledge Team Colleague

In the short and simple, you don't.

sha1 is a hashing function not encryption. It is designed to only work in one direction. e.g. 'dog' => 'e49512524f47b4138d850c9d9d85972927281da0'

If you require the ability to decrypt an encrypted string then you will need to use an encryption package like openssl or mcrypt.

In your case to send a plain-text password you could store it to a variable prior to hashing it. Then you could send the unhashed string to the user.

mschroeder 251 Bestower of Knowledge Team Colleague

If the value of $day-$month-$year evaluates to a string like 'd-m-Y' or any other combination of php date formats then yes you could.

<?php
$day = 'd';
$month = 'm';
$year = 'Y';

$format = "$day-$month-$year"; // d-m-Y
echo date($format); // 31-08-2010

If the value of $day-$month-$year evaluates to an actual date string like '31-8-2010' then no you can not feed that to the date function.

You would need to use strtotime or the DateTime object. I would suggest the later as it is compatible with dates after 2038, among countless other benefits.

<?php
$day = '31';
$month = '8';
$year = '2010';

$format = "$day-$month-$year"; // 31-8-2010
echo date('d-m-Y', strtotime($format)); // 31-08-2010
echo strtotime($format); // 1283308069 or something
<?php
$day = '31';
$month = '8';
$year = '2010';

$format = "$day-$month-$year"; // 31-8-2010
$date = new DateTime($format);
echo $date->format('d-m-Y'); // 31-8-2010
echo $date->getTimestamp(); //1283308069 or something

Hopefully this helps.

mschroeder 251 Bestower of Knowledge Team Colleague
$row = mysql_fetch_array( $result );

after that line, add:

print_r($row);

this will probably make a mess out of the table layout, but paste the output from that function here. That should indicate whether the problem is in the row array or not.

Output should be something like:

Array
(
    [tradeID] => xxxx
    [Date] => xxxxx
    [teamA] => xxxx
    ....
)
ceeandcee commented: Thank you! +1
mschroeder 251 Bestower of Knowledge Team Colleague

Can you do a print_r($row) and post the output from 1 iteration of the loop?

mschroeder 251 Bestower of Knowledge Team Colleague

Your echo statement is correct.

<?php
$row['teamA'] = 'irish';
echo "<img src='/images/bar_".$row['teamA'].".jpg'>";

yields

<img src='/images/bar_irish.jpg'>

Is it failing to display for all iterations of your loop or is it only on particular ones? I assume you've omitted the loop to simplify the code posted.

mschroeder 251 Bestower of Knowledge Team Colleague

That echo statement works for me without any issue. Can you post what you are getting errors and/or output when you run it?

mschroeder 251 Bestower of Knowledge Team Colleague

how could it display php tags? its a scripting language and when you echo it it automatically executed.
Post your exact output if issue is still not solved.

-vib
That is not true. When you use something like file_get_content() it does not parse/execute what it reads in. If you included the file then yes it would execute any php in that file.

-Gigs
This appears to me like you're trying to use it for some kind of template system? Where your output has a series of echo statements and you've already set some variables that should be replaced.

ob_start();
include ('lol.php');
$content = ob_get_contents();
ob_end_clean();

echo $content;

That code will include lol.php which will execute any php statements within it and then capture the content to a variable which you can then use at a later time. Is this more what you're trying to accomplish?

mschroeder 251 Bestower of Knowledge Team Colleague

Are these account numbers unique to the whole system, or is it acceptable that in each of those 6 tables the AI will start at 1?

mschroeder 251 Bestower of Knowledge Team Colleague

PHP is a server-side language. It could care less what browser you are using.

I'm going to take a total shot in the dark and say if this works in FF and not in IE then it has something to do with how the data is being passed from your form.

I would like to see the generated form HTML and also the php what is being used to set the variable $fileType. I'm assuming $image_array is an array of file types you're checking against as well.

mschroeder 251 Bestower of Knowledge Team Colleague

If you want a truly universally unique identifier (UUID) then check out this post on the php.net site.
http://www.php.net/manual/en/function.uniqid.php#94959

MySQL 5.x also has support for UUID's
http://dev.mysql.com/doc/refman/5.0/en/miscellaneous-functions.html#function_uuid

There is also a UUID pecl extension.
http://pecl.php.net/package/uuid

mschroeder 251 Bestower of Knowledge Team Colleague

-virtual

This is a perfect use of the RecursiveArrayIterator in the PHP5 SPL. You are using PHP5 right?

<?php

$root = array(
		"paa" => array (
			"adi1" => array (
				"cir1" => array (
							"aka",
							"ra", "vinodh","dkido"
							),
															
				"cir2" => array (
						  	"muta",
							"la"
							),
																
				"cir3" => array	(
							"ezut",
							"telAm"
							),
																
				"cir4" => array	(
							"ati"
							)
				),

			"adi2" => array (

				"cir1" => array (
							"paka",
							"vaV"
							),
												
				"cir2" => array (												
							"mutaR",
							"RE"
							),
												
				"cir3" => array	(
							"ula",
							"ku"
							)
				)				
		                )
            );

$rit = new RecursiveIteratorIterator(new RecursiveArrayIterator($root), RecursiveIteratorIterator::SELF_FIRST);

foreach($rit as $key=>$value){
	if( $rit->hasChildren() === TRUE ){
		echo 'inside loop of '.$rit->key().'<br />';
	} else {
		echo $key.'==>'.$value.'<br />';
	}
}
inside loop of paa
inside loop of adi1
inside loop of cir1
0==>aka
1==>ra
2==>vinodh
3==>dkido
inside loop of cir2
0==>muta
1==>la
inside loop of cir3
0==>ezut
1==>telAm
inside loop of cir4
0==>ati
inside loop of adi2
inside loop of cir1
0==>paka
1==>vaV
inside loop of cir2
0==>mutaR
1==>RE
inside loop of cir3
0==>ula
1==>ku

First we create a new RecursiveIteratorIterator object and pass it an instance of RecursiveArrayIterator. We pass $root in this case, your array, to the RecursiveArrayIterator. $rit = new RecursiveIteratorIterator(new RecursiveArrayIterator($root), RecursiveIteratorIterator::SELF_FIRST); The second parameter RecursiveIteratorIterator::SELF_FIRST is one of three possibilities. LEAVES_ONLY, SELF_FIRST, CHILD_FIRST.


  • LEAVES_ONLY will only return leaves and not the containers.
  • SELF_FIRST will list the containers first and then each of their proceeding children.
  • CHILD_FIRST will reverse the way the current results look. Processing …
mschroeder 251 Bestower of Knowledge Team Colleague
if( isset($result) && is_array($result) ){
    foreach($result as $page){
      echo $page;
    }
}

that is doing several things in that IF statement. It is making sure the variable $result exsists. It is also making sure that we actually have an array of results.

Currently there is no statement for it execute in the "else" condition. Add something like:

else {
  echo 'No Results';
}

immediately after the closing } of the if statement.

mschroeder 251 Bestower of Knowledge Team Colleague
<html>
<body>
<?php
$search_text = file("search_text.txt");
$search_string = $_POST['search_string'];
 
foreach($search_text as $key => $val) 
{ 
   $data[$key] = explode("||", $val);
}
 
echo 'Search Results for "'.$search_string.'"';
echo "<br><br>";
 
for($k = 0; $k < sizeof($search_text); $k++){
    if (in_array($search_string,array($data[$k][0],$data[$k][1],$data[$k][2],$data[$k][3]))){
        $result[] = '<a href="'.$data[$k][5].'">'.$data[$k][4].'</a><br><br>';
    }
}

if( isset($result) && is_array($result) ){
    foreach($result as $page){
      echo $page;
    }
}
?>
</body>
</html>
mschroeder 251 Bestower of Knowledge Team Colleague

Again a simple typo. There is a reason my signature says the code may not be tested. Both of these errors were well within your ability to find and correct.

Change $results[] to $result[] on line 17.

mschroeder 251 Bestower of Knowledge Team Colleague

typo on my part. change is_isset($result) to isset($result)

mschroeder 251 Bestower of Knowledge Team Colleague

You have the single quote inside double quotes you do not need to escape it. Right now the function it looking for \' to replace with &rsquo;

$data=str_replace("&rsquo;","'",$data);
mschroeder 251 Bestower of Knowledge Team Colleague

you're missing a [ in $_REQUEST"text"] change it to $_REQUEST["text"]

mschroeder 251 Bestower of Knowledge Team Colleague

** With ardav's suggestion **

if (in_array($search_string,array($data[$k][0],$data[$k][1],$data[$k][2],$data[$k][3])))
{
echo '<a href="'.$data[$k][5].'">'.$data[$k][4].'</a>';
echo '<br><br>';
}
else
{
echo "<br><br><br>";
echo "Your search returned 0 results. Please go back and try again.";
}

Change it to something like this:

if (in_array($search_string,array($data[$k][0],$data[$k][1],$data[$k][2],$data[$k][3])))
{
$results[] = '<a href="'.$data[$k][5].'">'.$data[$k][4].'</a><br><br>';
}

After the for loop:

if( is_isset($result) && is_array($result) ){
  foreach($result as $page){
    echo $page;
  }
}

resulting in:

<html>
<body>
<?php
$search_text = file("search_text.txt");
$search_string = $_POST['search_string'];
 
foreach($search_text as $key => $val) 
{ 
   $data[$key] = explode("||", $val);
}
 
echo 'Search Results for "'.$search_string.'"';
echo "<br><br>";
 
for($k = 0; $k < sizeof($search_text); $k++){
    if (in_array($search_string,array($data[$k][0],$data[$k][1],$data[$k][2],$data[$k][3]))){
        $results[] = '<a href="'.$data[$k][5].'">'.$data[$k][4].'</a><br><br>';
    }
}

if( is_isset($result) && is_array($result) ){
    foreach($result as $page){
      echo $page;
    }
}
?>
</body>
</html>
mschroeder 251 Bestower of Knowledge Team Colleague

Your problem is in the IF/ELSE conditional.

Because it is doing a search for each line in the file, it is generating output for each line in the file. Instead of outputting the result or failure in the for loop, assign the result to an array like: $result[] = 'link and title'; Then eliminate the ELSE part of the conditional all together.

after the for loop add a conditional check like

if(isset($result) && is_array($result)){
  echo implode('<br />', $result);
} else {
  echo 'Search returned 0 results';
}
mschroeder 251 Bestower of Knowledge Team Colleague

Does the server you have uploaded your files to have mod_rewrite enabled for apache?

mschroeder 251 Bestower of Knowledge Team Colleague

This is not an IE issue.
Get yourself Firebug for Firefox and the IE Developer Toolbar for IE7 -- maybe 6 and 8?

When I run through the example on firefox it is not removing the li tags from the list when i deselect a tag, just the input and the label.

Firefox is leaving the empty li tags and not displaying them or hiding them or something I assume it is your css. On IE7 the EXACT same behavior is occurring except IE7 is leaving the li's in their default state (expanded/not hidden?).

Both browsers show like this once i have removed items that i previously selected.

<ul class="selected">
<li> </li>
<li> </li>
</ul>
pritaeas commented: Useful comment, confirms my suspicion +4
mschroeder 251 Bestower of Knowledge Team Colleague

if you're making the form submit to itself then you need to make the index action in the index controller look for post data so it knows it needs to validate the form.

<?php

class IndexController extends Zend_Controller_Action
{
  public function indexAction()
  {
    $form = new Default_Form_Index();
    $request = $this->getRequest();

    //Check if we have post data
    if( $request->isPost() )
    {
      //If the form is NOT valid redisplay it with errors
      if( !$form->isValid($request->getPost() ) )
      {
        $this->view->form = $form;				           		
        return;
      }

      //Form passes validation and filtering
      //Do something with the data.
      $data = $form->getValues();

      //Maybe a redirect or change what view is getting rendered?

      //Just to stop execution after processing the form return;
      //return; 
    }

    //If no post data assume we're just displaying the form to the user
    $this->view->form = $form;
  }
}
mschroeder 251 Bestower of Knowledge Team Colleague

The problem you're having is $_FILES is an actual filename. your destination is a directory without a file name. its trying to create a file named "uploads", which is a valid filename on a linux system, in your dw folder. Try actually giving the file a filename in the destination path.

Example:

<?php
$uploads_dir = '/uploads';
foreach ($_FILES["pictures"]["error"] as $key => $error) {
    if ($error == UPLOAD_ERR_OK) {
        $tmp_name = $_FILES["pictures"]["tmp_name"][$key];
        $name = $_FILES["pictures"]["name"][$key];
        move_uploaded_file($tmp_name, "$uploads_dir/$name");
    }
}
?>

Source: php.net (move_uploaded_file)

Notice how in that code the destination is /uploads/[name of the actual file]. Should solve your problem.

mschroeder 251 Bestower of Knowledge Team Colleague

@essential

I may be wrong, but wouldn't the onblur event mean the field needs to lose focus?

If its auto-submitting the form then it should probably wait for a delay indicating the user has finished typing. Something like the solution posted in the comments on this site: http://www.openjs.com/scripts/events/check_after_typing.php works very elegantly for this.

I didnt see anything in your code like this, so i apologize if i missed it.

mschroeder 251 Bestower of Knowledge Team Colleague

Google for Wildcard DNS

mschroeder 251 Bestower of Knowledge Team Colleague

They are two different technologies:

php is server-side and will be executed on the server with the results being displayed to the user.

jquery is client-side and will be executed in the user's browser.
the only code it can modify is the html code that is delivered by the server. plus being client-side all a user needs to do is view your source and navigate to your javascript files to see whatever it is you are doing with your code. there is not much if anything secure about it.

mschroeder 251 Bestower of Knowledge Team Colleague

Actually in a purely PHP file, the closing tag ?> should be excluded.

It is necessary when you are jumping in an out of php control structures that are mixed with html or some other kind of output.

mschroeder 251 Bestower of Knowledge Team Colleague

There are some fine Ajax/Javascript libraries that exists:

http://jquery.com/
http://www.prototypejs.org

Are two very prominent ones, but there are countless others.
They all have Ajax examples and simplify working with the DOM etc.

mschroeder 251 Bestower of Knowledge Team Colleague

^ What they said.

mschroeder 251 Bestower of Knowledge Team Colleague

Well you're definitely right. regex is definitely slower when compared to str_replace especially as the length of the string increases. Although return str_replace(' ', '', $str); is not the same as return preg_replace('/\s*/m', ' ', $str); as the regex covers ALL whitespace, newlines tabs etc etc. When i ran your benchmarks on 5.3b1 str_replace did not replace tabs and new lines in the output.

However adding those to an array of replacements in str_replace still drastically spanked the regular expression replacement.

I feel kinda stupid for overlooking to most obvious solution to a few year old thread haha.

mschroeder 251 Bestower of Knowledge Team Colleague

Thanks. Very elegant solution. Wish you were around when this question was originally posted.

Oh, and btw, please forgive my ignorance. Like all people who reinvent the so-called wheel, I didn't know it existed. Thanks for the enlightenment.

If it solves your problem how you need it to solve your problem then its a solution. There is always more than one way to skin a cat.

mschroeder 251 Bestower of Knowledge Team Colleague

That is because your column type is set to datetime or timestamp not certain which one actually produces that as I don't use the mysql datetime or timestamp data type.

To store a unix timestamp you just need an INT(10)

mschroeder 251 Bestower of Knowledge Team Colleague

or UNIX_TIMESTAMP()

mschroeder 251 Bestower of Knowledge Team Colleague

Store a UNIX Timestamp in that mysql column.

<?php
$iCurrentTime = time();

$iCurrentTime would result in an integer like: 1236884436
Which is the number of seconds since the Unix Epoch.

You can pass that integer into the php date() function and format it any way you want, and you can also calculate against it simply using basic math.

The only drawback is that it can not store dates after 01/2038 because it will exceed the size of a 32bit integer or Before 01/1970. By 2038 I imagine 64bit hardware or greater will pretty much be the norm.

mschroeder 251 Bestower of Knowledge Team Colleague

GAH! Just realized how old this thread is, how did it get resurrected?!:-O

mschroeder 251 Bestower of Knowledge Team Colleague

In my previous post, you need to add a line to initialize $newstr. Corrected code should be as follows:

function StripExtraSpace($s)
{
$newstr = "";

for($i = 0; $i < strlen($s); $i++)
{
$newstr = $newstr . substr($s, $i, 1);
if(substr($s, $i, 1) == ' ')
while(substr($s, $i + 1, 1) == ' ')
$i++;
}

return $newstr;
}

For starters, functions in loops should be avoided whenever possible. e.g. for($i = 0; $i < strlen($s); $i++) also, you're doing a lot of extra work here.

I would suggest something like this:

<?php

$sTestString = 'This  is a stringwith    lots of 	odd spaces and tabs		
and some newlines too

lets see if this works.';

$sPattern = '/\s*/m'; 
$sReplace = '';

echo $sTestString . '<br />';
echo preg_replace( $sPattern, $sReplace, $sTestString );

Regular Expression removes ALL whitespace ( spaces, tabs, newlines) 0 or more times and also traverses multiple lines.

Put that in a file and run it in your browser, view the source and you'll see exactly what it has done.

No need to reinvent the wheel.

mschroeder 251 Bestower of Knowledge Team Colleague

But the notices are important, I always like to develop with error_reporting( E_ALL | E_STRICT ); In a production environment I NEVER leave error reporting enabled.

The problem with the notices the OP was experiencing were just that, he didn't have variables initialized. But was testing for them in his scripts. Using some of the default php functions (e.g. isset and empty) we can circumvent that issue.

Obviously the best solution would be setting default values, and check types etc. But, one step at a time.

mschroeder 251 Bestower of Knowledge Team Colleague

It's the escaping in your html in this area

if ( empty( $_POST ) )
	{
		echo "<table border=\"0\" cellspacing=\"3\" cellpadding=\"3\">\n";
		echo "<form method=\"post\" action=\"./login.php\">\n";
		echo "<tr><td>Username</td><td><input type=\"text\" name=\"username\"></td><\tr>\n";
		echo "<tr><td>Password</td><td><input type=\"password\"name=\"password\"></td><\tr>\n";
		echo "<tr><td colspan=\"2\" align=\"center\"><input type=\"submit\" name=\"submit\" value=\"Login\"></td></tr>\n";
		echo "</form></table>\n";
	}
mschroeder 251 Bestower of Knowledge Team Colleague

Try this. I made several changes, including moving an IF/ELSE statement up into the prior control structure. I also revised your sql statements slightly.

See if this does the trick and if you have any questions i'll try to answer.

<?php
session_start();
include "./global.php";

echo "<title>Login</title>\n";

if( isset( $_SESSION['uid'] ) )
{
	echo "You are already logged in, if you wish to log out, please <a href=\"./logout.php\">click here</a>!\n";
} 
else
{
	if ( empty( $_POST ) )
	{
		echo "<table border=\"0\" cellspacing=\"3\" cellpadding=\"3\">\n";
		echo "<form method=\"post\" action=\"./login.php\">\n";
		echo "<tr><td>Username</td><td><input type=\"text\" name=\"username\"></td><\tr>\n";
		echo "<tr><td>Password</td><td><input type=\"password\"name=\"password\"></td><\tr>\n";
		echo "<tr><td colspan=\"2\" align=\"center\"><input type=\"submit\" name=\"submit\" value=\"Login\"></td></tr>\n";
		echo "</form></table>\n";
	}
	else 
	{
	
		$user = mss( $_POST['username'] );
		$pass = $_POST['password'];
		
		if( $user && $pass )
		{
			$sql = 'SELECT id FROM users WHERE username = "' . $user . '"';
			$res = mysql_query( $sql ) or die( mysql_error() );
			if( mysql_num_rows( $res ) > 0)
			{
				$sql2 = 'SELECT id FROM users WHERE username = "' . $user . '" AND password = "' . md5( $pass ) . '"';
				$res2 = mysql_query( $sql2 ) or die( mysql_error() );
				
				if(mysql_num_rows($res2) > 0)
				{
					$row = mysql_fetch_assoc($res2);
					$_SESSION['uid'] = $row['id'];
					
					echo "You have successfully logged in as " .$user;
				}
				else 
				{
				  echo "Username and password combination are incorrect!\n";
				}
		   }
		   else 
		   {
				echo "The username you supplied does not exist!\n";
		   }
		}
		else 
		{
			echo "You must supply both the username and password field!\n";  
		}
	}
}
mschroeder 251 Bestower of Knowledge Team Colleague

That is a Notice not an error, what it is telling you, is that your code is checking the value of $_SESSION even though the array key 'uid' does not exist in the $_SESSION array.

replace:

if($_SESSION['uid']){

with

if( isset( $_SESSION['uid'] )  ){

However, Notices should not affect your code, the only thing they make cause problems with is using the header() function as they can be unexpected output. So if the page is not displaying the login or register links something else is wrong.

mschroeder 251 Bestower of Knowledge Team Colleague

What is the actual error message you are getting, and what is the value of $_SESSION in this part of your code?

if($_SESSION['uid']){
      /** Add the following line **/
     echo $_SESSION['uid'];

     $sql = "SELECT id,username FROM 'users' WHERE 'id'='".$_SESSION['uid']."'";

     $res = mysql_query($sql) or die(mysql_error());
     if(mysql_num_rows($res) == 0){
          session_destroy();
          /** Displays login link **/
     }else {
          $row = mysql_fetch_assoc($res);
          /** displays logout link and info **/
     } 
}

Also, I don't believe your sql is correct.

$sql = "SELECT id,username FROM 'users' WHERE 'id'='".$_SESSION['uid']."'";

users is not a reserved word therefore does not need to be quoted.
Also id is not a reserved word and does not need to be quoted.
Finally, the value of $_SESSION is suppose to be an integer so again that does not need quoted.

MySQL Reserved Words

/** Type casting assumes you are using PHP5 **/
$sql = 'SELECT id, username FROM users WHERE id = '. (int) $_SESSION['uid'];

Hopefully my suggestions will solve your problem, but without the ACTUAL error message it is hard to say what exactly is causing the problem.

mschroeder 251 Bestower of Knowledge Team Colleague

If the information that you want is available in an rss feed, then i think that is the way to go. If the info you want to scrape is not available to you in the rss feed(s) then you will have to grab the source and extract the parts you want.

I think what you're describing as pages, is better described as pagination, which would follow the general concept of:

On page 1 display the last 10 updates. If the number of updates exceeds 10, then divide the total number of updates by ten and round up (floor()) that number is the total number of pages. You would do some basic math and determine what page the user is on and what records to retrieve in the query, first 10, second 10 etc, using LIMIT. There are lots of great tutorials on how pagination works and its intricacies.

This can be done with php and some logic without the need to automate it to generate static files.

mschroeder 251 Bestower of Knowledge Team Colleague

Are they both database driven, and do you have access to both databases?

mschroeder 251 Bestower of Knowledge Team Colleague