mschroeder 251 Bestower of Knowledge Team Colleague
$query_birthdate = "SELECT day(user_birthday) as Day FROM users WHERE username='kkjay'";
$birthdate = mysql_query($query_birthdate, $connections) or die(mysql_error());
$row_birthdate = mysql_fetch_assoc($birthdate)

echo $row_birthdate['Day'];

Always use the mysql functions in your queries when you can, as you have done, the database server has that functionality for a reason. No reason to reinvent the wheel.

This only works because you're returning 1 row in the query. If you were returning multiple rows, you would have to loop over the $result to get each row's value.

Finally, if you're working with mysql 4.1 or greater you should NOT be using the mysql extension and really should be using the mysqli or PDO extensions to access the database. These allow access to the newer features provided by the mysql database server.

mschroeder 251 Bestower of Knowledge Team Colleague

In my opinion the best way to do this would be to name your fields using an array index.

<input name="field[]" type="text" size="20" maxlength="40" />
<input name="field[]" type="text" size="20" maxlength="40" />
<input name="field[]" type="text" size="20" maxlength="40" />

Then when you process the fields with PHP it is as simple as:

<?php
foreach( $_POST['field'] as $field ){
  //Do something with the value of $field.
}

No counter needed, will scale to an infinite size, and $_POST will be a numerically indexed array of values that were submitted so you can iterate over it with any of the array functions etc.

epicrevolt commented: Defninitely a new method. I need to look more into arrays for my projects. +1
mschroeder 251 Bestower of Knowledge Team Colleague

Performance wise, you should avoid loading an entire file into memory when possible.
The following code relies on the SPL (standard php library) which is mostly > php 5.1
Although this can also be done using the file functions in php.

<?php
$email = 'user@domain.com';

$file = new SplFileObject('filename.txt');
$file->setFlags(SplFileObject::DROP_NEW_LINES);

$match = false;
foreach($file as $line){
	if( false !== stripos( $line, $email ) ){
		$match = true;
		break;
	}
}

if( true === $match ){
	//we found a match
} else {
	//No Match
}

This reads through a file while only having a single line in memory at a time.
If/when it finds a match, it sets $match = true, you could implement this however you would like, but then breaks out of the foreach loop to stop from having to check the rest of the file.

If you're using a version of php that supports the SplFileObject you should really check it out. http://php.net/manual/en/class.splfileobject.php

Shankye commented: Thank you for help +1
mschroeder 251 Bestower of Knowledge Team Colleague

If your input is always going to be HTML/XML this would be ridiculously easy using SimpleXML and an xpath query:

<?php

$string = <<<XML
<body>  
<img src="page.jpg" border="0" usemap="#fghf"  />
<map name="fghf" id="fghf">
<area shape="rect" coords="10,71,258,236" href="#" alt="some_alt" title="some_title" />
<area shape="rect" coords="258,72,506,237" href="#" alt="some_alt" title="some_title" />
<area shape="rect" coords="155,79,150,200" href="#" alt="some_alt" title="some_title" />
<area shape="rect" coords="88,22,400,217" href="#" alt="some_alt" title="some_title" />
</map> 
</body>
XML;

$xml = new SimpleXMLElement( $string );
$results = $xml->xpath('//area/@coords');

foreach($results as $coords){
	echo $coords.PHP_EOL;
}

You can supply the html/xml as a string any way you wish. Then using an xpath query, we find the coords attribute (@coords) of all area elements in the document.

diafol commented: ridiculously easy! +7
mschroeder 251 Bestower of Knowledge Team Colleague

The following code uses the SplFileObject [http://www.php.net/manual/en/class.splfileobject.php] from the SPL library. This ensures we never read the entire file into memory, only one line at a time. For small files it is okay to read it into an array, but it is best to get in the habit of working with files line by line unless absolutely necessary to read the whole thing.

Also SplFileObject allows us to parse CSV (Comma Separated Value) files in a single pass. In your case it appears your username and password are separated by a comma so this can be considered a CSV file.

The logic is the same the implementation is different. Also in my example there is a break; statement that stops execution of the foreach loop once a user has been found. This stops us from having to iterate over the n lines that might still exist in the file.

<?php

$user = $_POST['user'];
$pass = $_POST['pass'];

//Use an SplFileObject so we only ever work with 1 line of the file in memory at a time
$file = new SplFileObject( 'fileone.txt' );

//Set flag bitmask for DROP_NEWLINE, SKIP_EMPTY, READ_CSV
$file->setFlags( 15 );

//Because of the READ_CSV flag, $line is already an array of fields field[0], field[1] etc.
foreach( $file as $line ){
    //If we find the user in the line, validate the password
    if( $user == $line[0]){
        if( $pass == $line[1] ){
            echo 'Welcome '.$user.'!';
        } else {
            echo 'Incorrect Name and Password Combination.';
        }
        //This ends …
mschroeder 251 Bestower of Knowledge Team Colleague

What is there not to get? Did you even read the rest of the thread? The op already stated clearly his number is supposedly in bytes. The problem isn't doing simple math the problem is doing simple math with ridiculous numbers.

mschroeder 251 Bestower of Knowledge Team Colleague

The more I look at this, the more I have to wonder if your number is wrong.
1.797693134862316e+308 bytes would be 1.487016909281302219479708e+284 yottabytes.
1 bytes = 8.27180613 × 10-25 yottabyte

According to wikipedia the combined storage space of all harddrives in the world does not amount to 1 yottabyte.

mschroeder 251 Bestower of Knowledge Team Colleague
<?php

//Start with the base string plus 15 decimal places
$str = '1797693134862316';

//Add 293 0's to the string e.g. (308 - 15)
for( $i=0; $i<293; $i++ ){
	$str = $str . '0';
}

//Use bcmath to divide it by 1048576
var_dump( bcdiv( $str, '1048576', 2 ) );

and the result....
17144137714980278015136718750000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000.00

Assuming that really is in KB, although I would take a guess it is really in bits or something.

mschroeder 251 Bestower of Knowledge Team Colleague

Using php 5.2.2+ this is a piece of cake.

<?php
$date1 = new DateTime('2010-12-07');
$date2 = new DateTime('2010-12-07');

if( $date1 == $date2 ){
  echo 'Dates are equal.';
}

http://www.php.net/manual/en/datetime.diff.php scroll down to example #2 for some examples.

mschroeder 251 Bestower of Knowledge Team Colleague
<html>

<form action="get.php" method="GET">
<input type="text" name="myname"><br>
<input type="submit" value="click here">
</form>
</html>
<?php

$name = $_GET["myname"];
echo "Hello, $name";
?>

'myname' is not an index in the $_GET array prior to the form being submitted.

<html>

<form action="get.php" method="GET">
<input type="text" name="myname"><br>
<input type="submit" value="click here">
</form>
</html>
<?php
if( isset( $_GET["myname"] ) ){
    $name = $_GET["myname"];
    echo "Hello, $name";
}
?>

This simple if statement looks for $_GET to be defined before it tries to execute the code that displays the array item.

mschroeder 251 Bestower of Knowledge Team Colleague

Just a general observation, feel free to ignore the following.

In your table you're using a surrogate primary key, the auto-incrementing column. When you clearly have a natural and practical composite primary key in (book, chapter, verse) as they are always provided and the combination of three digits may not ever repeat.

The glaring issue I see with using a surrogate key in this scenario is that a record can be mistakenly added with duplicate information.

e.g.
ID, Book, Chapter, Verse, Scripture
1, 1, 1, 1, ...
2, 1, 1, 2, ...
3, 1, 1, 1, ...

By eliminating the ID column it becomes impossible to insert the third record with the duplicate information as the composite pk fails.

Book, Chapter, Verse, Scripture
1, 1, 1, ...
1, 1, 2, ...
1, 1, 1, ...

mschroeder 251 Bestower of Knowledge Team Colleague

@Full Spectrum
Its not an untyped language it is a loosely typed language. You can cast values to a particular type and do type comparisons if you want/need too.

@benjaminFowl87
Unit testing is a very powerful mechanism for development, but in my experience it is a different mindset than just sitting down and writing code. Generally you see unit testing talked about with TDD (Test Driven Development). In other words, you design your functionality, write a failing test, write code to pass the test and finally refactor the code to a certain standard level.

Unit testing really shines when you have a system that is heavily tested and then you are tasked with making changes to already existing classes/functions throughout the existing system. Because your tests all pass to start, you write new failing tests and then implement the code necessary to pass those tests. As long as your original tests still pass and your new tests pass, then you have added your additional functionality without breaking any existing code.

Where as without testing, its next to impossible to know for sure that everywhere that piece of code is used is still functional until a bug or issue is found.

Just my $0.02 hope it helps.

mschroeder 251 Bestower of Knowledge Team Colleague

@ardav
It just screamed trigger to me...its Friday, I'm pulling out all the stops haha.

@CEVGames
Like I said that is not tested but it looks mostly correct as I typed it out. Hope it works out for you. If not plenty of other ways to skin a cat.

mschroeder 251 Bestower of Knowledge Team Colleague

This to me sounds like something best handled by the database using a trigger.

Questions (Table):

QuestionId   int
  Question     varchar
  Answer       varchar
  DateActive   datetime
  Value        tinyint    default 100

QuestionUserAnswers (Table):

QuestionId   int
  UserId       int
  Answer       varchar
  Score        tinyint  (min 50, max 100)

With your trigger being something like this:

CREATE TRIGGER Trig_QuestionScore AFTER INSERT ON Questions
  FOR EACH ROW BEGIN
	IF Questions.`Value` > 50 THEN 
		UPDATE Questions SET Questions.`Value` = Questions.`Value` - 5;
	END IF
  END;

**This is NOT tested so use it just for the general concept.
But what you would do is when the user gets the question right, you would insert a record into the QuestionUserAnswers table. AFTER that insert occurs the trigger would fire automatically and look at the Questions table and subtract 5 from the Questions value unless the value was already at 50.

This only works on mysql > 5.0.2
http://dev.mysql.com/doc/refman/5.0/en/create-trigger.html
http://dev.mysql.com/doc/refman/5.0/en/trigger-syntax.html
http://dev.mysql.com/doc/refman/5.0/en/stored-program-restrictions.html

diafol commented: show off! +7
mschroeder 251 Bestower of Knowledge Team Colleague

BaSk,

I have done just this. But, I use a command line tool called PDFTK (http://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/)

Essentially, I take a fillable pdf that has been designed. Collect information from the user via a web interface and create xfdf from it (http://partners.adobe.com/public/developer/en/xml/xfdf_2.0_draft.pdf). Once I have the generated xfdf I execute a command line call with php to pdftk that merges the fillable pdf with the xfdf resulting in a finished flattened pdf that contains the user's information.

PDFTK is free, but it has to be installed on the server to work. It also has a ton of other features that are really useful to be able to call from the command line.

mschroeder 251 Bestower of Knowledge Team Colleague

I think this is going to depend more on how your array is actually structured. Post up and example of the array your iterating and a more detailed example of the result.

mschroeder 251 Bestower of Knowledge Team Colleague

It sounds like you're trying to read through a file line by line and then use the value of that line to perform a query.

Personally I prefer the SplFileObject assuming you're using php > 5.1.0

<?php
//Create SplFileObject instance of $filename
$file = new SplFileObject($filename);

//Set the drop new line flag so returned line value does not include \n etc.
$file->setFlags(SplFileObject::DROP_NEW_LINE);

//Foreach line in the file execute a query
foreach ($file as $line) {
    mysql_query($line);
}
mschroeder 251 Bestower of Knowledge Team Colleague

Can you please describe your use case a little more so we have a better idea of what you are trying to accomplish?

You can read through a file line by line using fgets, but if you are trying to detect if a character is an end of line character, which varies (\n \r\n etc.), you would use something like fseek to progress the file pointer 1 character at a time and fread to capture the next byte and test it for being an EOL character.

vedro-compota commented: +++++++++++ +1
mschroeder 251 Bestower of Knowledge Team Colleague

In my opinion there are several reasons to use thumbnails over full sized images.

For starters the web is fast and your connection might be fast but there are still plenty of people who do not have fast connections.

Second, since in a default state browsers only allow you to load a few requests in parallel. So unless you're serving your images from multiple sub-domains one long loading image can holdup the entire page load.

Third, if you're loading a bunch of large images you're consuming bandwidth for each page load. Potentially a lot of bandwidth for each page load when a user may only look at a page of thumbnails and close it.

Fourth, even for thousands of images it takes minutes to create thumbnails, there are desktop apps, command line tools, and even php that can automate the process.

Just my $0.02

mschroeder 251 Bestower of Knowledge Team Colleague

Edit: The problem is that you don't have the img tag wrapped with an a tag.

echo '<td><a class="mylink" href="http://',$row['website'],'">',$row['website'],'</a></td>';
echo '<td><a class="mylink" href="http://',$row['website'],'"><img width="75" src="',$row['url'],'"/></a></td>';
Kniggles commented: thanks. +1
mschroeder 251 Bestower of Knowledge Team Colleague
echo "<td><a class=\"mylink\" 'http://' href=\"http://" . $row['website'] . "\">" . $row['website'] . "</a></td>";
 
echo "<td><img width = '75' src=". $row['url'] . " /></td>";

For starters if you're going to be echoing HTML, single quotes will make your life much easier. You also have an unnecessary 'http://' in between your class and href attributes.

echo '<td><a class="mylink" href="http://',$row['website'],'">',$row['website'],'</a></td>';
echo '<td><img width="75" src="',$row['url'],'"/></td>';

Also unless you absolutely NEED to append the strings together, passing multiple strings and delimiting them with a comma will speed things up. This only works with echo and not print.

diafol commented: I didn't know the comma trick. Thanks +7
mschroeder 251 Bestower of Knowledge Team Colleague

with the exception that http:// could be repeated multiple times within the url. in which case that would fail. It all depends on the use case. $url = 'http://www.site.com/url.php?url=http://www.google.com'; You would also probably want to use str_ireplace as the user supplied url could very well be Http:// HTTP:// hTtP:// etc.

diafol commented: good points +7
mschroeder 251 Bestower of Knowledge Team Colleague

Not sure what the environment limitations are, but SQLite3 has fulltext searching capabilities, but they are not enabled by default. Very Similar to mysql syntax it appears.

http://www.sqlite.org/fts3.html

mschroeder 251 Bestower of Knowledge Team Colleague

Assuming your table is a MyISAM and the particular column has a full-text index on it:

SELECT * FROM table WHERE MATCH (col1, col2, col3) AGAINST ('+Goa' IN BOOLEAN MODE);

http://dev.mysql.com/doc/refman/5.1/en/fulltext-boolean.html

***Apparently this does not REQUIRE a fulltext index, but will take a major performance hit

mschroeder 251 Bestower of Knowledge Team Colleague

There are a lot of different ways to attack this: http://refactormycode.com/codes/598-remove-http-from-url-string has a whole variety of them. Some are good some are bad, my suggestion is to avoid regular expressions unless they're absolutely necessary.

<?php
/*
E.g:
$s = 'http://google.com';
echo remove_http($s);
output: google.com
*/

function remove_http($url = '')
{
    array('http://', 'https://');
    foreach ($list as $word)
        if (strncasecmp($url, $word, strlen($word)) == 0)
            return substr($url, strlen($word));
    return $url;
}

Would probably be my choice from that link for how to do this accurately.
Your images are not clickable because there are no links around them.
They would need to be something like:

echo "<td><a href="someurl.com"><img width = '75' src='http://". $row['url'] . "' /></a></td>";
Kniggles commented: wow nice link :) thanks. +1
mschroeder 251 Bestower of Knowledge Team Colleague
<?php

<form action="ScoreCardAlpha.php" method="post">

A: <input type="text" name="$X" />

B: <input type="text" name="$Z" />

C: <input type="text" name="$W" />

// read input data on $W , $X or $Z has http// if so save after //

if(!filter_has_var(INPUT_post, "$X"))
 {
// if true
	**** deleate all char upto and including // then post to "$X"  ****
 echo("Input has been adapted and saved");
 }
else
 {
// if false
	**** post to "$X" ****
 echo("Input did not need adapting and has been saved");
 }

<input type="submit" />
?>

Maybe I am missing something, but I don't see how the code you provided can even execute. You should get a parse error as soon as it gets to the "<" in <form action="ScoreCardAlpha.php" method="post">

mschroeder 251 Bestower of Knowledge Team Colleague

the printf based functions essentially cast values to a particular type and work with them in their respective ways. They also let you control things like precision, padding, etc etc. Look at the link i posted above, it has a lot of examples of what can be done with them.

They're really not the best way to prevent sql injection though. Prepared statements in my opinion are the best way to avoid sql injection, combined with the concept of "Filter Input, Escape Output"

mschroeder 251 Bestower of Knowledge Team Colleague

it is used in context with sprintf and printf etc? http://php.net/manual/en/function.sprintf.php

mschroeder 251 Bestower of Knowledge Team Colleague

What is the data type of your t_stamp column? I assume it is TIMESTAMP?

mschroeder 251 Bestower of Knowledge Team Colleague

Depends on the mysql extension you are using in php. mysql_affected_rows(), mysqli->affected_rows()

mschroeder 251 Bestower of Knowledge Team Colleague

just add another condition to the query then.

UPDATE table SET column = 'finish' WHERE STR_TO_DATE( date, '%m/%d/%Y' )= CUR_DATE() AND column = 'approve'
aizel commented: nicely done +1
mschroeder 251 Bestower of Knowledge Team Colleague

Is the date still stored as a string or is using a DATE column type in mysql?

UPDATE table SET column = 'finish' WHERE STR_TO_DATE( date, '%m/%d/%Y' )= CUR_DATE()

Something like that would probably work for you, assuming your structure is similar to what it was previously.

mschroeder 251 Bestower of Knowledge Team Colleague

The solution was provided in my previous post

instead of == 21 it should be == '21'

There is no value to me just giving you the solution and you just copying and pasting it into your code. By providing you the information I did, you can attempt to learn why you're having a problem and how to address it in the future.

You're still going to have a problems with the additional code you posted too:

else if ($pg=="21;n='.$get_numbers.'") { echo 'Numbers...'; }
else if ($pg=="21;l='.$get_letters.'") { echo 'Letters...'; }

$pg=="21;n='.$get_numbers.'" and pg=="21;l='.$get_letters.'" are not going to match "21;n=0" or "21;l=0". You have mixed concatenation, single quotes and double quotes together. Those conditions are going to try to match on the string "21;n='.0.'" which is not being passed in your url.

else if ($pg=="21;n='.$get_numbers.'") { echo 'Numbers...'; }

should be revised to

else if ($pg=="21;n=$get_numbers") { echo 'Numbers...'; }

In double quoted strings php will parse variables. If you use single quotes you need to concatenate your variable. e.g. else if ($pg=='21;n='.$get_numbers) { echo 'Numbers...'; } Both of these statements will yield the same result and should both work correctly.

mschroeder 251 Bestower of Knowledge Team Colleague

PHP is a loosely typed language.
$pg is always a string result from the url e.g. '21', '21;n=0', '21;l=0'

When you do a comparison against an integer value if($pg == 21) { echo 'Regular...';} $pg is cast to an integer value. So var_dump( (int) '21;n=0' ); will yield int 21.

Since you're doing a string comparison across the whole thing, instead of == 21 it should be == '21' OR you should split those up into individual variables and test the parameters individually like I was trying to suggest before...

mschroeder 251 Bestower of Knowledge Team Colleague

In your code $get_numbers and $get_letters are variables.
In the urls in the link you are building you are using the value of those variables in the url.

So, <a href="index.php?page=21;l='.$get_letters.'" would become <a href="index.php?page=21;l=1" in your html. If the value of $get_letters was 1. This would mean the value of $_GET would be '21;l=1' sans the quotes.

In your urls you are also concatenating the variables together with a semi-colon. If these are two different values they need to be passed with an ampersand. <a href="index.php?page=21&l='.$get_letters.'" In your code you can then test for these as separate values. $_GET and $_GET.

$page = (int) $_GET['page'];
$letter = $_GET['l'];
$numbers = $_GET['n'];
mschroeder 251 Bestower of Knowledge Team Colleague

When I view your site, I see two different content-type meta tags:

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <title>Морайра Инвест - недвижимость в испании - Buy, Sell, Resa</title>
  <meta http-equiv="content-type" content="text/html;charset=utf-8">
  <meta http-equiv="content-language" content="ru">
  ...
</head>

You should only have 1 and you probably want to be using UTF-8 as this should contain the character sets you want to be working with.

http://www.phpwact.org/php/i18n/charsets
http://www.phpwact.org/php/i18n/utf-8
The first covers a great overview of the implications of characters sets in php and the second has a very detailed breakdown of many string functions and their risk level in terms of UTF-8 corruption.

This boils down to your outputted html needs to have a proper content-type meta tag and your application needs to send a proper content-type header and they should match.

Beyond what the articles mentions, your database connection needs to be set to the proper character set.
-MySQL Extension
http://www.php.net/manual/en/function.mysql-set-charset.php

-MySQLi Extension
http://php.net/manual/en/mysqli.set-charset.php

-PDO Extension
http://www.galengrover.com/web-development/setting-the-connection-charset-with-php-mysql/

Within your database you also need to set the proper character set and collation
http://dev.mysql.com/doc/refman/5.0/en/charset-database.html
Your tables will also have similar settings.

Hopefully this helps and gets you pointed in the right direction. Iñtërnâtiônàlizætiøn in php can be a real pain.

mschroeder 251 Bestower of Knowledge Team Colleague

-nevvermind
Singletons are almost always an indication of poor code design. They're extremely difficult to mock and test. Essentially the problem with singletons is you place the responsibility for determining the objects life cycle in the wrong place.

More beneficial to have a factory class that handles initialization and returns a single instance of a particular class if necessary.

-kroche
Looking at your code it looks like your domain objects are all extending the database class to provide database access. This will also become troublesome if you ever have to test your code independently. Something to consider would be to make your database class external and keep your domain objects isolated. If a domain object needs database object, then pass the database instance into the domain object when created. This opens the doors for utilizing the factory pattern and/or dependency injection to create domain objects and handle initializing any dependencies a domain object may have.

mschroeder 251 Bestower of Knowledge Team Colleague

You need an extension that is built for 5.3 and VC6 and is thread safe version

http://downloads.php.net/pierre/php_printer-svn20100319-5.3-vc6-x86.zip

mschroeder 251 Bestower of Knowledge Team Colleague

It is nice to see someone who is actually doing some reading and looking on their own.

I read up on the "array_map()", can you elaborate a little on that please? Not quite grasping it yet.

array_map, simply executes the trim() function on every item in an array. In my example its running trim() on every item returned by the explode statement. This just cleans up any extra whitespace left around those strings.

As for the code you posted, it looks like a good start but, it appears like it is mixing the logic for listing events as well as deleting them.

When you list them, you just need to get the content of the file, explode the contents and iterate over the returned results. In the link you will also need something identify which event it is you want to delete from the file. Looking back I see each event is prefixed with "###-". So I will use that to break down the file in a special way.

function getEvents( $path )
{
	$events = array();
	
	//Make sure the file exists and we can read it
	if( is_readable( $path ) {
		//Read entire file in.
		$content = file_get_contents( $path );
		//Explode by =>
		$dirtyEvents = explode( '=>', $content );
		//Iterate over each $dirtyEvent and look for its identifier
		//Split it into a key and value pair that is unique to the event.
		foreach( $dirtyEvents as $event ){
			//Get the position of the first dash
			$dashPos = …
mschroeder 251 Bestower of Knowledge Team Colleague

Assuming everything is on a single line.

My initial thought on this, is to change the format of the file you're creating so each event is on its own line. This would eliminate the need for a separation character, new line, new event. This would also make it possible to work with the entire file line by line instead of having to load the entire file into memory.

With the current format, the process for parsing this would be to load the entire file (1 line assumed) into memory (file_get_contents() etc.) and then explode that line with the '=> ' separator. Unset the event item to delete. Put the string back together and write it back to the file.

$line = file_get_contents( 'somefile.txt' );

//Explode the line and trim each of the items in the array.
$events = array_map('trim', explode( '=> ', $line ));

//Delete the event from the events array
unset( $events[0] );

//Put the remaining lines back together into one line.
$line = implode( '=> ', $events );

//Write it back to the file
...

This should work well for small files, but if your files would ever grow to a large size, this will become very inefficient as it has to load the entire file into memory. A few hundred lines, no big deal, a few hundred thousand lines and you'll quickly see performance hits.

This isn't tested, but you should get the idea and be able to adapt it as needed.

mschroeder 251 Bestower of Knowledge Team Colleague

Can you post a sample of the produced text files as well? That should be enough to get an understanding of how to process them out.

mschroeder 251 Bestower of Knowledge Team Colleague

Can you post an example of the format of the text files you're trying to work with?

mschroeder 251 Bestower of Knowledge Team Colleague

Line 27:

list($file,$extension) = explode('.', basename($path));

explode is not returning 2 array pieces. So that means $path does not contain what you think it does from somewhere higher up. My guess is $path = $uriparts['path']; is not returning a filename but rather a path.

$fileParts = explode('.', $basename($path));
$file = isset($fileParts[0]) ? $fileParts[0] : '';
$extension = isset($fileParts[1]) ? $fileParts[1] : '';

Line 35:

list($key,$val) = preg_split('/=/',$b);

Again preg_split is not returning an array with two items.
It looks like your trying to parse the query string into variable = value pieces.
Look at parse_str in the manual, it does just this.
Also when splitting by something as simple as an '=' avoid regular expressions they're very slow compared to straight string manipulations.

$query = isset( $uriparts['query'] ) ? $uriparts['query'] : '';
  $anchor = isset( $uriparts['anchor'] ) ? $uriparts['anchor'] : '';
  if ($a = explode('&',$query)){
    foreach ($a as $b) {
	  list($key,$val) = preg_split('/=/',$b);
	  switch ($key) {

TO

$query = isset( $uriparts['query'] ) ? $uriparts['query'] : '';
$anchor = isset( $uriparts['anchor'] ) ? $uriparts['anchor'] : '';
$a = array();
//parse the string and put into the array $a
parse_str($query, $a);
if( !empty($a) ){
  foreach($a as $key => $value ){
     switch( $key ) {

    //Do rest of code or skip if $a has no key value pairs
}

Line 45:

$result .= $cat_name['categories_name'];

This last one is easy.

function transform_uri($param) {
  //Define the result variable
  $result = '';
  ....

As far as using the @ operator to suppress errors. …

mschroeder 251 Bestower of Knowledge Team Colleague

Short tags can definitely be disabled, however they are enabled by default.

If they are disabled, there are ways to use a stream wrapper to replace <?= to <?php echo on the the fly, but its merely a workaround.

RTM

mschroeder 251 Bestower of Knowledge Team Colleague
[form]
[input type='text' name='username' value='<?=$value?>']


[/form]

The little php snippet inside the form input value.

Are you getting the idea??
:)

Unless php short tags are disabled.
Some good discussion on the topic: http://stackoverflow.com/questions/200640/are-php-short-tags-acceptable-to-use

mschroeder 251 Bestower of Knowledge Team Colleague

Unless you're familiar with configuring php and apache skip all of the trouble and download WAMP or XAMPP

There are others like this as well. They will install everything you need to get a fully functional php, apache and mysql environment in windows.

WAMP seems to have gone stale lately, but there is a community released version with all the latest and greatest link from their forums: http://sourceforge.net/projects/unofficialwamp2/files/

CAUTION: These installers are not designed to be used for live websites. They are really intended to speedup the setup of a development environment.

qazplm114477 commented: very nice and detailed explaination +1
mschroeder 251 Bestower of Knowledge Team Colleague

Hello iammirko. Both, hielo and mschroeder, are right, but you must "close" all your name, id, and that stuff with "" or '', and use style="" for styling your table... your html code must be:

<form action="CreateUser.php" method="post" name="form">
     <table class="CreateUser" style="cellpadding:4px; cellspacing:2px;">
          <tr class="TableHeading">
               <td colspan="2">Enter the infomation below</td>
          </tr>
          <tr class="FormContents">
               <td>Username</td>
               <td><input type="text" name="text" id="usrName" size="20px"/></td>
          </tr>
          <tr class=FormContents>
               <td>Password</td>
               <td><input type="password" name="password" id="pWord" size="20px"/></td>
          </tr>
          <tr class="FormContents">
               <td></td>
               <td align="right"><input type="submit" name="submit" id="Cu_Bt" value="Login"/></td>
          </tr>	
     </table>
</form>

Actually only the XHTML 1.0 spec (http://www.w3.org/TR/xhtml1/#h-4.4) requires attributes to be quoted. The HTML 4 spec (http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.2.2) does not require them to be quoted unless they fail to meet certain criteria: In certain cases, authors may specify the value of an attribute without any quotation marks. The attribute value may only contain letters (a-z and A-Z), digits (0-9), hyphens (ASCII decimal 45), periods (ASCII decimal 46), underscores (ASCII decimal 95), and colons (ASCII decimal 58). We recommend using quotation marks even when it is possible to eliminate them. Just FYI.

mschroeder 251 Bestower of Knowledge Team Colleague

You don't have name="" attributes in your html form code.

<form action="CreateUser.php" method="post">
	<table class=CreateUser cellpadding=4px, cellspacing=2px>
		<tr class=TableHeading>
			<td colspan=2>Enter the infomation below</td>
		</tr>
		<tr class=FormContents>
				<td>Username</td>
				<td><input type=text id=usrName name=usrName size=20px></input>
				</td>
		</tr>
		<tr class=FormContents>
				<td>Password</td>
				<td><input type=password id=pWord name=pWord size=20px></input>
				</td>
		</tr>
		<tr class=FormContents>
				<td></td>
				<td align=right><input type=submit id=Cu_Bt value=Login></td>
		</tr>	
	</table>
	</form>
mschroeder 251 Bestower of Knowledge Team Colleague
var Editor1 = FCKeditorAPI.GetInstance('editor1') ;
var Editor2 = FCKeditorAPI.GetInstance('editor2');
Editor2.InsertHtml( Editor1.GetHTML() );
mschroeder 251 Bestower of Knowledge Team Colleague

This is Very Normal Error This is Error Comes Due to the Full of Memory Means Your Computer's Memory is Full.You have to Remove the Temporary Files,Cookies,Browsing History and also Recycle Bin Form the Your Computer.You can Manually Delete it or You can Use any Software like the Ccleaner.It will Delete the all this things with the Single Click.

This has nothing to do with the ops original question. Period.
Besides those things all exist in storage (the harddrive) not in memory (ram).