I'd suggest a simple variable that increments with each iteration of the foreach loop. With something like the code below, you can access the number of the element with the counter variable.
// +--
// | Loop through the products.
// +--

$counter = 0; //Init the counter

foreach ($prodlist as $num => $prod) {
//Leave the below line at the top of the loop
$counter++; //Increment the counter with each product
//The counter starts at 1 and counts up

  // +--
  // | Print a table row opener.
  // +--

  print '<tr class="' . $trclass . '">' . $eol . $eol;

  // +--
  // | Print the tds and their content.
  // +--

  $prodname  = $this->xhtml_encode($prod['name']);
  $prodid    = $this->xhtml_encode($prod['id']);
  $prodlink  = $this->link_namespace($app,'prodshow',$prod['id']);
  $proddesc  = $this->xhtml_encode($prod['descshort']);
  $imgname   = $prod['imgsm'];

  $add_ok = 1;

  if (($prod['useinv']) && (!($prod['invlevel'] > 0))) {$add_ok = 0;}
  if ($prod['pricestatus'] == 'D') {$add_ok = 0;}

  $quandisp = 0;
  $quanform = $this->globals('khxc_cgi.' . $formid . '--' . $prodid . '--quantity');

  if (isset($quanform)) {$quandisp = $quanform;}

  if ($add_ok) {

       print '<td class="' . $tdclass . '">' . $eol . $eol;
       print '<label for="' . $formid . '--' . $prodid . '--quantity';
       print '" class="hidden">Quantity</label>' . $eol;
       print '<input class="khxc_formfield" type="text" name="';
       print $formid . '--' . $prodid . '--quantity';
       print '" id="' . $formid . '--' . $prodid . '--quantity';
       print '" value="' . $quandisp . '" size="5" maxlength="5" />' . $eol;
       print '</td>' . $eol . $eol;

  } else {

       print '<td class="' . $tdclass . '">&nbsp;' ...

[QUOTE=garryamin;1318061]The limits are based on characters and not with words. LongText allows 4GB of characters, so in theory it depends on how long your words are. It is possible to have ten words that contain characters more than 100 words. But I doubt it is. Some possible restrictions could fontend backend script trimming and / or server limitations.[/QUOTE]
This sounds awfully familiar, almost like this was a post I wrote. In fact it is (the first post in this thread after the author's post).

"Limits are based on characters and not by words. Longtext allows for 4GB of characters, so in theory it depends on how long your words are. It is possible to have ten words that contain more characters than 100 words. But I doubt this is the case. Some possible limitations could be fontend scripts, backend trimming, and/or server limitations.
It would really help to see some code. As a rule, I would always post some relevant code unless your question involves theory."

Besides the thread is already solved, garryamin. Maybe you can contribute to another thread.

Great! Please make sure to mark this thread as solved so other users know you don't require further assistance. Thanks :)

[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! :)

Well first, there's [URL="

[QUOTE=britoniah3480;1316693]Lol because of this

$id = $_GET['id']; //you forgot to put the $id =

$username = "root";
$password = '123456';
$hostname = "localhost";
$db = mysql_connect($localhost, $username, $password)
or die ("Unable to connect to mySQL".mysql_error());

$del = "DELETE FORM newdbase WHERE id = $id";

$nres = mysql_query("$del);


you should try my site it might help you better :)[/QUOTE]

It also might be useful to note that once quotes are opened, they must be closed. But in your instance, quotes aren't necessary on this line.
$id = $_GET['id']; //you forgot to put the $id =

$username = "root";
$password = '123456';
$hostname = "localhost";
$db = mysql_connect($localhost, $username, $password)
or die ("Unable to connect to mySQL".mysql_error());

$del = "DELETE FORM newdbase WHERE id = $id";

$nres = mysql_query($del); //Much better

[QUOTE=chrishea;1317011]If you create the output as a Word file, you can tell it where you want the page breaks. I don't have the details handy but if you want to go that way I can dig up some details (I have done it but I would need to dig through a program to remember how).[/QUOTE]
If your users don't mind the hassle of opening a word document, you might consider a PDF for compatibility. I know a lot of people, myself included, hate them, but there are a bunch of PDF libraries for PHP, probably a lot more than there are word document libraries for PHP.

If you are using this code to download an image to [i]your[/i] computer (and not a server), I would use Python instead since it is suited for server side development as well as little scripts you want to schedule on your computer.
If you would like to continue with PHP, hielo has the right idea. Although I think cURL can handle FTP if you use an FTP URL like [url]ftp://user:pass@host:port[/url], but I'm not sure.
On second glance I noticed that you provided us with port 22, which happens to be the port for SSH (most likely for SFTP use). If you are using SSH/SFTP, you will need to use [URL="

You probably couldn't find anything because this is not a PHP specific feature. It only requires some HTML & CSS. I found [URL="

Props to you for using something other than MD5.
Now on to business. The basic way to validate a password stored in a database is to use a one way encryption such as SHA1. This involves hashing the password the user provides at registration and storing it in a database. To check if login credentials are valid, simply run the given password through the same hash function and compare the hashes. If the hashes are the same, the passwords match.

The code snippet you provided is not valid, nor does it validate. Please provide a better snippet that shows your problem.

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:
<a href="<?= $ip ?>"><?= $ip ?></a>

Also notice that since you have shorttags enabled I used shortened syntax to print variables. It removes the need for print or echo in short, one-line variable outputs and will be compatible with PHP (with shorttags enabled) until 6.0.0.

If application/octet-stream works, why not use it? The only problem you mentioned is that Opera reports the file as 1.2MB instead of 1.12MB. This is probably not an error on your part. Opera usually rounds up all sizes to the tenths place so a file might be 12.56 MB but Opera will show it as 12.6 MB for succinctness. As long as the file downloads properly and reports the correct size when you view it in Explorer (as in viewing files on your computer, not Internet Explorer), why bother?

[QUOTE=vibhadevit;1316560]The function will not internally parse it.
But lets say i have one php page : [url]http://www.mysite.com/register.php[/url]
And i use file_get_contents('http://www.mysite.com/register.php') then html source will be returned by file_get_contents function.

Simply we can have 'View Source' type of functionality.[/QUOTE]

From the PHP.net documentation:
"file_get_contents() is the preferred way to [b]read[/b] the contents of a file into a string. It will use memory mapping techniques if supported by your OS to enhance performance."

If the file is stored locally, [icode]file_get_contents()[/icode] basically does the following:
$fp = fopen($file, "r");
$contents = fread($fp, filesize($file));
It will not execute any PHP contained within the file. For any PHP code within the file to execute you will have to use output buffering and include the file, as mschroeder suggested, or grab the file with cURL (which is similar to grabbing the source from a browser). By far, including the file is faster since it doesn't require any socket connections like cURL does.

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?

Ahh yes, my suggestion only satisfied the aesthetic requirements, but doesn't seem that logical. I would instead use CSS like Darz mentioned and style each row to be a certain height.
table tr {
height: 18px;
line-height: 18px;


I would have done the same, but apparently, a space alone doesn't retain the same font size as the rest of the text in the table. If all else fails, insert some dummy text and style it with [icode]visibility: hidden;[/icode].

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.

[icode]mysql_real_escape_string()[/icode] should be applied to any user generated content passed to MySQL to prevent SQL injections, but has no bearing on the limits on the text submitted (other than escaping characters).
The first thought that comes to mind is you aren't viewing the entire field. Try querying the DB, selecting the field, and outputting the description with PHP after inserting your description with your script. PhpMyAdmin never displays all the text if it exceeds a certain length. Usually you have to view the record individually to see the entire value of a long text field. When PhpMyAdmin truncates text, I believe it adds '...' after it to denote the truncation, but don't hold me to that.
Grab the description with PHP after inserting to verify, but I believe all the text will be there.

Sample of using [icode]mysql_real_escape_string()[/icode] to protect yourself from SQL injections, a dangerous hack that can expose and compromise data:
mysql_query("SELECT * FROM users WHERE username='".mysql_real_escape_string($_POST['username'])."' AND id='".mysql_real_escape_string($_POST['id')."'");

To grab the description, use the following:
//Conect to MySQL
//Then grab all the descriptions
$result = mysql_query("SELECT description FROM shortitem");
while($data = mysql_fetch_array($result)) {
echo $data['description']."<br>\n";

[QUOTE=ﻼim;1315132]this just proves that i still have a lot to learn! :$
i haven't used any of the functions here.
really nice to know all this.

thanks PMC. Ϋ[/QUOTE]
You're welcome! :D

As you learn more about PHP, you'll see a lot of these useful features like cURL. As it says in my signature, be sure to take some time to look over some of the listed extensions on the PHP.net documentation. You'll discover some other great extensions such as the GD image library. Best of luck with your future PHP scripts!

[QUOTE=detweiller;1313996]what does this mean:


and this:


They ([icode]<?=$something?>[/icode]) are PHP shorttags, and can be disabled on some server configurations. They basically an easier way of typing [icode]<?php echo $something; ?>[/icode] and while most don't recommend them, I will stubbornly continue to use them until their deprecation in PHP6! :)

The first one outputs the address of the page, so the form submits itself to the page that created it. The second outputs the id and name values from the MySQL database. The [icode]$data[/icode] variable is set to the values from each row of the MySQL query.

@ﻼim: Thanks! Back at ya!

@ev Sorry about that! I didn't see that you already answered the question. :P

[QUOTE=ﻼim;1315107]:) hey there PMC.

i do also have an idea about on what baudday's asking for.
programmers have different ways in solving the same problem, right?

mine's to adjudicate first if possible, the summary of a whole program code,
and after doing so that's when I'll start giving it a shot. Ϋ

it's also my way on knowing how good the person is in terms of his or her coding.
and just so you know i guess you're one of the best already. Ϋ

:icon_wink: mabuhay ka PMC![/QUOTE]
You have a valid point. Sometimes it is better to post code (as a rule, it's a good idea to post some for reference) and other times its not. Though, as the asker, its nicer if answers can be tailored to their exact needs. Salamat ﻼim!

baudday: If this thread has been solved, please make sure to mark it as solved so other users know that this thread does not need further clarification. Thanks! :D

britoniah3480 has a point. MySQL doesn't limit the number of rows in a table because that is not the purpose of a database. You can assume rows are empty if they aren't set (See britoniah3480's code above).
When inserting, you can ensure that there are still spaces by doing a quick check with PHP.
//Connect to MySQL
mysql_connect($host, $user, $pass) or die(mysql_error());
mysql_select_db($db) or die(mysql_error());

//Check if there are spaces left
$result = mysql_query("SELECT * FROM players WHERE team = '".$team."'");
if(mysql_num_rows($result) < 25) {
//Still spaces
} else {
//Team full

[QUOTE=ﻼim;1315091]hi there! Ϋ

would you mind displaying a part of your code that has relation with that?
that's to solve the problem faster.

:) thanks.[/QUOTE]
If you absolutely want it from baudday, you can ask for some code, but I found that baudday's description of what he/she was looking for was sufficient to come to a solution.

You could use [icode]ob_start()[/icode], include the file that creates the page (taking care to add any necessary GET variables to the include path as you would with a URL), and then store the contents of [icode]ob_get_contents()[/icode] in a variable. Demo below:

//Start output buffering
//Get the contents of the dynamic page
//Get the contents of the page through the OB
$contents = ob_get_contents();

//To demonstrate it works
echo '$contents = ';

//Sample dynamic content
echo 'This is dynamic. A = '.$_GET['a'];

If you need to send POST variables to the dynamic page you could use [URL="

Limits are based on characters and not by words. Longtext allows for 4GB of characters, so in theory it depends on how long your words are. It is possible to have ten words that contain more characters than 100 words. But I doubt this is the case. Some possible limitations could be fontend scripts, backend trimming, and/or server limitations.
It would really help to see some code. As a rule, I would always post some relevant code unless your question involves theory.

I know I'm kinda late to the party here, but if you prefer not to use JS (I'd use a library then like @ev said) here's the basic structure of populating a list with PHP and then returning results for that list:
//Connect to MySQL & Select DB
mysql_connect($host, $user, $pass) or die('There was an error with the database server. Please try again later.');
mysql_select_db($db) or die('There was an error with the database. Please try again later.');
<!docytype html>
<title>PHP Popluate & Return Demo</title>

<form action="<?=$_SERVER['PHP_SELF']?>" method="get">

<?php $result = mysql_query("SELECT id, name FROM data") or die('Could not retrieve database information. Please try again later.'); ?>
<select name="id">
<?php while($data = mysql_fetch_array($result)): ?>
<option value="<?=$data['id']?>"><?=$data['name']?></option>
<?php endwhile; ?>

<input type="Submit" name="action" value="View">

<?php if($_GET['action'] == 'View'): ?>

<?php if($result = mysql_query() && mysql_num_row($result) > 0): ?>
<!-- etc. -->

<?php while($data = mysql_fetch_array($result)): ?>
<td><?= $data['id'] ?></td>
<td><?= $data['name'] ?></td>
<td><?= $data['field1'] ?></td>
<td><?= $data['field2'] ?></td>
<!-- etc. -->
<?php endwhile; ?>

<?php else: ?>
<p>No results could be found for the given id</p>
<?php endif ?>

<?php endif; ?>

Thanks man! If you need any help implementing it, shoot me a PM or post on the PHP forum.

PhpMyCoder :)

Well it would take a little more work than that if you wanted true security. Slightly advanced authorization should look something like this. You should also look into [URL="

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.

The basics of a user system involves three main parts.
[][B]Registration -[/B] The user provides details such as desired username, password, and email. Some verification should be done to make sure that the user names and emails are unique to that user. If they are, insert this information into a users table of your database. This table should include a unique ID, username, password (encrypted with the [icode]md5()[/icode] function, a one way hash), email, and session id. As an extra layer of security and to prevent spam you can filter for valid emails and send email verifications to ensure users give you valid addresses.
][B]Authentication -[/B] The user provides login details such as username and password or email and password. The username/email should be checked against the database. If it does exist, run the given password through an md5 hash to verify that the passwords match. From here, store the unique user id and a random session id as cookies on the users browser. To validate login, check to see if the unique id stored in the cookie matches a record in the table along with the session id. You can regenerate the sessionid for maximum security.
[*][B]Management -[/B] Something as simple as PhpMyAdmin can be used for user administration. You can update, delete, and add users with little to no extra work. If you prefer a more targeted admin panel, you can add advanced options that includes all of the above and other features such as banning by ...