cwarn23 387 Occupation: Genius Team Colleague Featured Poster

If that's all that the problem is then the following should do the job:

<?php
for ($i =0; $i < $ValuenumtableChildren; $i++)
{
echo '<a href="viewingdetails.php?name='.$Valuechild[$i].'">'.$Valuechild[$i].'</a>';
}
?>

If the above code doesn't displaying anything at all then try the code in my previous post.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Hi,
I get an error 500 when I try to open my web page with IE, but not with other Programs as Firefox or Safari. The problem I think is with the redirect in the index.php file, but I don't see the problem.
Here is the code:

<?
fcnX('home.php');

And the function is a Java script:

}
function fcnX($prUrl){
  echo '<script language="javascript">' . "\n";
  echo '<!--' . "\n";
  echo 'document.location = \'' . $prUrl . '\';' . "\n";
  echo '-->' . "\n";
  echo '</script>' . "\n";
  break;
  exit;
}

Any ideas?
Thks!

Well perhaps you may need to specify the full url in the function instead of just a page name. Below is an example of how you should use your function:

<?
fcnX('http://www.example.com/blogs/home.php');

You may find that IE is just getting confused without the full address.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

By any chance would the variable $ValuenumtableChildren = 0 or something like that. Also make sure that the array $valuechild[] actually exists. So try the below script if your not using mysql for the data.

<?php
if (empty($Valuechild) || !isset($Valuechild)) {
die('$Valuechild is not a valid variable. That is whats causing the problem.');
} 
foreach ($Valuechild AS $val) {
echo '<a href="viewingdetails.php?name='.$val.'>'.$val.'</a>';
}
?>

If you are using mysql and are displaying the results in a loop then the following would apply:

<?php
while ($row=mysql_fetch_array($sqlresult)) {
echo '<a href="viewingdetails.php?name='.$row[0].'>'.$row[0].'</a>';
}
?>

Hope that helps.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

any other suggestion?

Could you please post the lines around $Valuechild=array(); and check that it also uses the right casing because I can only see half the picture here.

tulipputih commented: thanks for your help..hope the problem could be solved..I have tried so many ways to make a link from that array variable +1
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Is this what you mean?

<TEXTAREA NAME="comments3" style='width:50%' rows='4'>
<?php
for ($i =0; $i < $ValuenumtableChildren; $i++)
{
echo '<a href="viewingdetails.php?name='.$Valuechild[$i].'</a>';
}
?>	
</TEXTAREA>
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Hi cwarn

I've never gone further than doing simple select, update and delete requests but if I understand this correctly JOINS join two tables together, so when I do the while loop for the initial JOIN then I nest another MySQL statement looking for the relevant info in order for me to calculate the total amounts?

From what I can understand of that yes that is correct. So basically it just joins the columns of the two tables so there is one big table with lots of columns then the new data joins with the existing table data where those two columns are the same if you get what I mean. So have a play around with it and you'll see what I mean.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

When combining tables to make one big table, you need to have a common column to pair with which in your case appears to be the column named "code". A tutorial can be found at http://www.tizag.com/mysqlTutorial/mysqljoins.php and below is a query example:

SELECT *
FROM fruit, cart
WHERE fruit.code = cart.code
Venom Rush commented: Helped a lot. Thanks ;) +2
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

php returns static html pages
nothing else is seen on the user browser, unless part of the html is a javascript, then the javascript is dynamic (from the user perspective)
Trying to get my head round how what you want could not be solved with a mod_rewrite rule, with lower overheadI might (grimace(probably)) be missing somethingbut I guess my learning curve isnt helping your problem, sorry

I managed to get my head around the problem with a simple question. What if php in this case does no processing and only displays multiple pages based on url input? That is the theorm my script works on. So to some degree you would then convert the usage of if(/*blah*/$_GET/*blah*/) to html. It is only things like $_POST, mysql input and mail() that won't process. So there are 2 answers to your question depending on what your using php for.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I just tested the script for the bug you mentioned and have now got a fix and the code is as follows:

<?
$domain='http://example.com/'; //must end in a slash
$links=array(
'index.php',
'index.php?id=1',
'data.php',
'folder/phpfile.php?id=43');
//set the links in the array above
foreach ($links AS $link) {
$data=file_get_contents($domain.$link);
file_put_contents(str_replace(array('?','*',':','|','"',"'"),'_',$link).'.html',$data);
unset($data);
}
echo 'process complete.';
?>

However, with the change in the code, in the domain variable on the second line you will need to specify your website domain and all the links in the array below that will need to be relative to the homepage directory. Hope that helps.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Do you mean that you want to convert all your php documents into html documents or are you trying to place php content under a .html extension. If you are trying to convert all the php documents to html documents then the following script will do the job although you will need to specify each php location in the array.

<?
$links=array(
'index.php',
'index.php?id=1',
'data.php',
'folder/phpfile.php?id=43');
//set the links in the array above
foreach ($links AS $link) {
$data=file_get_contents($link);
file_put_contents(str_replace(array('?','*',':','|','"',"'"),'_',$link).'.html',$data);
unset($data);
}
echo 'process complete.';
?>

If however you want to keep them as php files but want to give them a .html extension without .htaccess files then you could modify apache to treat html files as php files and just leave the extension .htm (not .html) for the regular html files.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Edit: Sorry but I was typing this when adatapost beat me to the answer by seconds.
Simply use action="test.php" in the <form> tag. Below is an example:

<form method="post" action="test.php">
<input type="text" name="mobile" id="mobile" />
<input type="submit" value="send"></form>

Then in test.php, to display the value use the following

$mobile=$_POST['mobile']; //retrieves it
echo $mobile; //displays it

Although you may want to modify the form a bit to suit your needs, the above is the basic code.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

If $_POST contains the email address then that would not be such a wise idea since it would be open to experienced hackers. I would suggest making a html form like the following then below that is the php code that will process the form.

<?
if (isset($_POST) && !empty($_POST)) {
//set details
$subject='This is a test';
$message='This is a test email and this text will apear in the message body.';

//set email addresses
$email[0]='email1@domain.com';
$email[1]='another@domain.com';
$email[2]='user@gmail.com';
$email[3]='user@hotmail.com';

//decide which email to use
$n=stripslashes($_POST['to']);
$to=$email[$n];
unset($n);

//process email
if (mail($to, $subject, $message)) {
echo '<b>Success</b>, email sent to '.$email;
} else {
echo '<b>Failure</b>, try checking your server settings or that you have specified a valid email.';
}
} //!empty($_POST)
?> <form method="post"><select name="to">
<option value="0">email1@domain.com
<option value="1">another@domain.com
<option value="2">user@gmail.com
<option value="3">user@hotmail.com
</select></form>
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

To make it easier below is a more complete version of my code:

$to=stripslashes($_POST['to']);
$subject='This is a test';
$message='This is a test email and this text will apear in the message body.';
$headers='';
if($to == '1'){
$email='user@gmail.com';
mail($email, $subject, $message, $headers);
}else {
$email='name@hotmail.com';
mail($email, $subject, $message, $headers);
}

Another version of the same thing but with error reporting is as follows:

$to=stripslashes($_POST['to']);
$subject='This is a test';
$message='This is a test email and this text will apear in the message body.';
$headers='';
if($to == '1'){
$email='user@gmail.com';
}else {
$email='name@hotmail.com';
}
if (mail($email, $subject, $message, $headers)) {
echo '<b>Success</b>, email sent to '.$email;
} else {
echo '<b>Failure</b>, try checking your server settings or that you have specified a valid email.';
}
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
$to=stripslashes($_POST['to']);
if($to == '1'){
mail($email, $subject, $message, $headers);
}else {
mail($email, $subject, $message, $headers);
}

Above is an example and for further reading the mail function manual is at http://au2.php.net/function.mail

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I just checked the script for that error and turns out that the table variable wasn't assigned to the mysql query. So the following updated script should do the job providing the variables at the top are configured correctly.

<?
$username='admin'; //Mysql access username
$password=''; //Mysql access password
$database='mydatabase'; //Database to connect to - not the table name.
$tablename='mytable'; //the name of the table - not the database.
$idfieldname='id'; //the column name for the id field.
//configure above variables

//DO NOT CHANGE THE BELOW
//==========================
mysql_connect('localhost', $username, $password) or die('Invalid login details.<hr>'.mysql_error());
mysql_select_db($database) or die('Cannot connect to selected database.<hr>'.mysql_error()); 
mysql_query('UPDATE `'.$tablename.'` SET `'.$idfieldname.'`=""') or die(mysql_error());
$result=mysql_query('SELECT * FROM `'.$tablename.'`');
if (mysql_num_rows($result)>0) {
    for ($row=1; $data=mysql_fetch_assoc($result); $row++) {
        $where='';
        foreach ($data AS $key => $val) { 
            $where.='`'.$key.'`="'.mysql_real_escape_string($val).'" AND';
            }
        $where=substr($where,0,-3);
        $where.='LIMIT 1';
        mysql_query('UPDATE `'.$tablename.'` SET `'.$idfieldname.'`="'.$row.'" WHERE '.$where) or die(mysql_error());
        unset($where);
        unset($key);
        unset($val);
        }
    echo 'ID field updated';
    } else {
    echo 'Nothing to update';
    }
?>
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I think what you are looking for is .htaccess files which is part of the apachie rewrite module. With .htaccess files, you can make fake urls that on the server side rewrite to the real file.

Example - real url:
site.com/index.php?username=cwarn23&id=blog
Fake url:
site.com/cwarn23/blog/

I would provide some code but I just need to know your real url is including what goes after the ? symbol.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Depending on your dictionary I am guessing you will need a numbered id field if there are non a-z0-9 characters. To solve this, the following script will automatically fill in the id field for you:

<?
$username='admin'; //Mysql access username
$password=''; //Mysql access password
$database='mydatabase'; //Database to connect to - not the table name.
$tablename='mytable'; //the name of the table - not the database.
$idfieldname='id'; //the column name for the id field.
//configure above variables

//DO NOT CHANGE THE BELOW
//==========================
mysql_connect('localhost', $username, $password) or die('Invalid login details.<hr>'.mysql_error());
mysql_select_db($database) or die('Cannot connect to selected database.<hr>'.mysql_error()); 
mysql_query('UPDATE `table` SET `'.$idfieldname.'`=""') or die(mysql_error());
$result=mysql_query('SELECT * FROM `'.$tablename.'`');
if (mysql_num_rows($result)>0) {
    for ($row=1; $data=mysql_fetch_assoc($result); $row++) {
        $where='';
        foreach ($data AS $key => $val) { 
            $where.='`'.$key.'`="'.mysql_real_escape_string($val).'" AND';
            }
        $where=substr($where,0,-3);
        $where.='LIMIT 1';
        mysql_query('UPDATE `'.$tablename.'` SET `'.$idfieldname.'`="'.$row.'" WHERE '.$where) or die(mysql_error());
        unset($where);
        unset($key);
        unset($val);
        }
    echo 'ID field updated';
    } else {
    echo 'Nothing to update';
    }
?>

I made this script as part of a mysql tutorial. Hope it helps.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I just tested the script and found out that 2 variable names I placed were incorrect. So replace the end bit with the following:

list($width, $height) = getimagesize($file_tmp);
           //calculate the image ratio
           if ($width>$height) {
               $ratio=$height/$width;
               $newwidth=200;
               $newheight=$newwidth*$ratio;
               } else {
               $ratio=$width/$height;
               $newheight=200;
               $newwidth=$newheight*$ratio;
               }           
           //function for resize image.
           if (function_exists(imagecreatetruecolor)){
           $resized_img = imagecreatetruecolor($newwidth,$newheight);
           }else{
                 die("Error: Please make sure you have GD library ver 2+");
           }
           //the resizing is going on here!
           imagecopyresized($resized_img, $new_img, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
           //finally, save the image
           ImageJpeg ($resized_img,"$path_thumbs/$rand_name.$file_ext");
           ImageDestroy ($resized_img);
           ImageDestroy ($new_img);
 
 
        }
 
        //ok copy the finished file to the thumbnail directory
		move_uploaded_file ($file_tmp, "$path_big/$rand_name.$file_ext");
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Do you mean like this:

//make sure this directory is writable!
		$path_thumbs ='c:/wamp/www/thumb';
		
		//the new width of the resized image, in pixels.
		$img_thumb_width = 200; // 

		$extlimit = "yes"; //Limit allowed extensions? (no for all extensions allowed)
		//List of allowed extensions if extlimit = yes
		$limitedext = array(".gif",".jpg",".png",".JPG",".JPEG",".jpeg",".bmp");
		
		//the image -> variables
	    $file_type = $_FILES['vImage']['type'];
        $file_name = $_FILES['vImage']['name'];
        $file_size = $_FILES['vImage']['size'];
        $file_tmp = $_FILES['vImage']['tmp_name'];

        //check if you have selected a file.
        if(!is_uploaded_file($file_tmp)){
           echo "Error: Make sure Your Image is not More 2MB before You Upload!. <br><a href=profilephoto.php>back</a>";
           exit(); //exit the script and don't process the rest of it!
        }
       //check the file's extension
       $ext = strrchr($file_name,'.');
       $ext = strtolower($ext);
       //uh-oh! the file extension is not allowed!
       if (($extlimit == "yes") && (!in_array($ext,$limitedext))) {
          echo "Wrong file extension.  <br>--<a href=profilephoto.php>back</a>";
          exit();
       }
       //so, whats the file's extension?
       $getExt = explode ('.', $file_name);
       $file_ext = $getExt[count($getExt)-1];

       //create a random file name
       $rand_name = md5(time());
       $rand_name= rand(0,999999999);
       //the new width variable
       $ThumbWidth = $img_thumb_width;

	   //////////////////////////
	   // CREATE THE THUMBNAIL //
	   //////////////////////////
	   
       //keep image type
       if($file_size){
          if($file_type == "image/pjpeg" || $file_type == "image/jpeg"){
               $new_img = imagecreatefromjpeg($file_tmp);
           }elseif($file_type == "image/x-png" || $file_type == "image/png"){
               $new_img = imagecreatefrompng($file_tmp);
           }elseif($file_type == "image/gif"){
               $new_img = imagecreatefromgif($file_tmp);
           }
           //list the width and height and keep the height ratio.
           list($width, $height) = getimagesize($file_tmp);
           //calculate the image ratio
           if ($width>$height) {
               $ratio=$height/$width;
               $newwidth=200;
               $newheight=$width*$ratio;
               } else {
               $ratio=$width/$height;
               $newheight=200;
               $newwidth=$height*$ratio;
               }           
           //function for resize image.
           if (function_exists(imagecreatetruecolor)){
           $resized_img = imagecreatetruecolor($newwidth,$newheight);
           }else{
                 die("Error: Please make sure you have GD library ver 2+"); …
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

If you mean modifying the same text file a few billion times in a loop and the file gets damaged then I believe that is the same with windows servers and possibly all servers. Point is that on occasion there is the unexpected error which can really mess things up. That is why I find it's best to have lots of little files or databases.

However, to test this bug of yours, try the following script:

<?
file_put_contents('test.txt','The server is writable.');
if (file_get_contents('test.txt')!==false) {
echo 'The server can read files<br>';
} else {
echo 'There was an error reading a php generated text file.<br>';
}
if(touch ('test.txt')) {
echo 'The server can use the touch function on text files';
} else {
echo 'There was an error using the touch function on a text file';
}
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Opps, I was up late when writing that and forgot to put in the brackets. So a better example that should work is as follows:

RewriteEngine On
RewriteRule ^(page)\/(.*)$ $1.php?$2
RewriteRule ^(page2)\/(.*)$ $1.php?$2
RewriteRule ^(page3)\/(.*)$ $1.php?$2
RewriteRule ^(blog)\/(.*)$ $1.php?$2

or as your example should show:

RewriteEngine On
RewriteRule ^(var=page)$ test.php?$1
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Then did you place the .htaccess file in the same directory/folder as the index.php page? Also, did you remember to place the dot before the word login within the login. So the url should be something like http://www.example.com/.login Also check that the real file responds when using the real address.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

If you mean weather you can write to a file using php then the following should be able to test that:

<?
file_put_contents('test.txt','The server is writable.');
echo file_get_contents('test.txt');
?>
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Place this in the .htaccess file that is in the same directory is the homepage:

RewriteEngine On
RewriteRule ^([^.]+)\/(.*)$ $1.php?$2

Edit:
I discover that the script I posted takes over all real directories so you will need to specify each directory like the following:

RewriteEngine On
RewriteRule ^page\/(.*)$ $1.php?$2
RewriteRule ^page2\/(.*)$ $1.php?$2
RewriteRule ^page3\/(.*)$ $1.php?$2
RewriteRule ^blog\/(.*)$ $1.php?$2

And so on.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Hi Cwarn,

Thank you for your reply.

The problem is that I have this code already in my .htaccess file

RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?req=preview&login_name=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php?req=preview&login_name=$1L]

this code turns this url
mysite.com/index.php?req=preview&login_name= 'somename'

into
mysite.com/somename

So, this code does not let the code work that you told me like.

Well then that means that you will need to have a escape character so login and any other new entries can pass by the existing entries. So for example, instead of having just login as the prefix you would need something like .login Below is an example for .login as the ending prefix.

RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?req=preview&login_name=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php?req=preview&login_name=$1

RewriteRule ^\.login$ index.php?req=login
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Try this:

RewriteEngine On
RewriteRule ^([^.]+[^/])$ index.php?req=$1
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Well your while loop can be replaced with a mysql query. So your script can be replaced with the following:

else
{

    ##User isn't registering, check verify code and change activation code to null, status to activated on success
    mysql_connect("localhost", sssssss, passs) or die(mysql_error());

    mysql_select_db("sssss") or die(mysql_error());

    $queryString = $_SERVER['QUERY_STRING'];

    $query = "SELECT * FROM users";

    $result = mysql_query($query) or die(mysql_error());

    /*
    Your script is always falling into this WHILE statement, which is what causes your page to output "Congrats!", etc. at the top of the registration page.  Also, your script is outputting this text before the <head> section of your HTML.  To get it to output in the correct place on the page, you should store that statement in a variable, then echo your variable somewhere down your page.  You can add PHP scripts to pretty much anywhere in your HTML and so doing this will not be a problem.

    More importantly, you need to examine why your script is *always* going into this WHILE statement.  I think it is always going into this WHILE statement because of line 133.  You are selecting all records from your database.  On line 135, you're checking that variable for data to ensure the query was successful.  Since the variable has data in it, then your script falls into the WHILE statement and echos all the usernames stored in it from the SELECT statement.  It seems to me that you need to improve your SELECT statement and that should correct the problem.
    */ …
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

actually i implemented both ways they r not working

I just tried some of the previously posted examples and the ones I have tested so far all seem to work for me but the only difference is I'm using drive C. Below is several examples that work for me:

<?
function delete_directory($dirname) {
    if (is_dir($dirname))
        $dir_handle = opendir($dirname);
    if (!$dir_handle)
        return false;
    while($file = readdir($dir_handle)) {
        if ($file != "." && $file != "..") {
            if (!is_dir($dirname."/".$file))
                unlink($dirname."/".$file);
            else
                delete_directory($dirname.'/'.$file);          
        }
    }
    closedir($dir_handle);
    rmdir($dirname);
    return true;
}
//now the function is defined the examples can be used
delete_directory('C:/folder');
//or
delete_directory('/folder');
//or
delete_directory('../../folder');
?>

So the only two things I can think of is that your either not placing the functions raw code like in the above and assuming it is part of an internal library or that there is a configuration on your server preventing such action from being taken. You may even need to do a checkdisk to clean up the errors on your harddrive as I had this problem when creating 2 billion folders. To perform a checkdisk, just click start->run then type cmd. A black window will appear and in the window type CHKDSK /F while in the appropriate drive. To learn how to use that command line just read up on msdos.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

yes the apache is in d:/wamp i created a folder using mkdir on d:/ with name lucky ...now i want to delete tht ...i tried moving the folder lucky into the folder having .php script and tested still its not working

So you made the directory with a php script. At the moment there are only two other options I can think of both using the function I provided earlier. They are a- place in the $dir= the same as you placed in the mkdir function. And b- keep on using ../ in the $dir= until your at the base of the drive then specify lucky
Example: ../../../lucky

cwarn23 387 Occupation: Genius Team Colleague Featured Poster
$dir = "d:/lucky";

I've seen that mistake been made so many times but I shall explain again. The path is incorrect because you need to specify the relative location without the drive letter. So this means that you cannot have your domain in the path nor can you specify the drive letter like you have done previously.
If your web directory is d:/htdocs/ then you will need to specify the following although the following assumes that htdocs is always in the base of drive d

$dir = "/lucky";

However that script on a Linux or Unix server in general not work and certainly will never work on a shared server as the folder is being created in the root of the drive. If you plan to place the directory on your server then you may need to place it within your web directory meaning you will need to change the code for that. However, for the info within the quote, the above code should work if the web directory in the apache service is set to the root of drive d.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

thanx ... i did use mkdir ...with tht i m able to make the dir successfully on my harddisk while testing. ut on web server its not doing it ....cant figure out y plz help

here is my code

<?php
  mkdir ("/htdocs/lucky", 0777);
  echo " dir made successfully";

  ?>

plz help

Well from that path specified, if it were on an online server it would look like if you have a dedicated server or same server configurations as your testing environment. When placing a / at the beginning of the path, it makes the location start from the beginning of the server root and usually there are a few folders it has to go through before getting to your account. I would suggest making a relative path to the script so for example, if the script was in your hompage or the same directory as your homepage then the following would apply:

<?php
  mkdir ("lucky", 0777);
  echo " dir made successfully";
  ?>
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I found a nice little script that will do the job but won't delete 2 billion subdirectories due to a permissions denied error.

function delete_directory($dirname) {
    if (is_dir($dirname))
        $dir_handle = opendir($dirname);
    if (!$dir_handle)
        return false;
    while($file = readdir($dir_handle)) {
        if ($file != "." && $file != "..") {
            if (!is_dir($dirname."/".$file))
                unlink($dirname."/".$file);
            else
                delete_directory($dirname.'/'.$file);          
        }
    }
    closedir($dir_handle);
    rmdir($dirname);
    return true;
}

Below is the web address I found the code:
http://www.ozzu.com/programming-forum/php-delete-directory-folder-t47492.html

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Hi!
I was wondering if there is any way to just include a small part of a file?
...
Is this possible?

Well actually yes it is possible. Just place an if element around what you don't want. Below is an example:

<? //index.php
$includes='t';
include('file.php');
?>
<? //file.php
echo 'This will be included.';
if ($includes!=='t') {
    echo '<br>This will not be included.';
    }
?>

As hard it may first seem ya just need to think past the barrier.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

In case you need more info on how to enable it with xampp, I shall post more detailed instructions. First as a backup, copy the file located at C:\xampp\apache\conf\httpd.conf to another location in case you do a few things wrong. After copying that file, open the original at C:\xampp\apache\conf\httpd.conf then uncomment line 118 which should contain the following data:

#LoadModule rewrite_module modules/mod_rewrite.so

To uncomment it, just remove the hash at the beginning. Then save and close the file. After that, do a reboot and .htaccess files should then be enabled.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

If the 64-bit version works then it probably means that you have a 64-bit operating system. To check weather you have a 32-bit or 64-bit operating system just follow the instructions under the vista section in this page. If you follow those instructions and it says 64 bit on the screen then you know that you must have the 64 bit version of IE.
If however that is not the case, I would suggest switching to Firefox or Opera.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Depending on how your web host is set up, you may need to change the database server to localhost At least that is what most web hosts would have it set to.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

It meens that the file located at /forum/forums/libs/functions_forums.inc.php does not exist. If you believe it should exist and that the location is relative to the base of your website then you will need to a - adjust it to the base of something like the server root or b - specify a location relative to the folder the script is in without a slash at the beginning.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Try the following code:

<?php
$num_to_guess=42;
$num_tries=0;
$num_tries = (!isset($_POST["num_tries"])) ? $num_tries + 1 : 0;
$message = "";
if (!isset($_POST["guess"])){
 $message = "WELCOME TO THE GUESSING MAChINE!";
 } else if ($_POST["guess"] >$num_to_guess) {
 $message = "$_POST[guess] is too big! TRY a smaller number";
 }else if ($_POST["guess"] < $num_to_guess) {
	$message = "TOO SMALL OR EMPTY";
 } else { 
	$message = "WELL DONE!";
 }
(isset($_POST["guess"])) ? $guess = $_POST["guess"] : $guess = '';
?>
<html>
<head>
<title>SAVE STATE WITH HIDDEN FIELD</title>
</head>
<body>
<h1>
<?php echo $message ?>
</h1>
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="POST">
<p><strong>Type your guess Here: </strong>
<input type="text" name="guess" value="<?php echo $guess ?>" >
<input type="hidden" name="num_tries" value="<?php echo $num_tries ?>" >
<p><input type="submit" value="submit your guess" /></p>
</form>
</body>
</html>
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I've tested the htaccess code I've posted and it seems to work perfectly for me so perhaps the rewrite module isn't correctly enabled as in the past, I have encountered that error while trying to enable the rewrite module.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Your php code is incorrect and needs quotes inside the array. So the correction is the following:

<html>
<head>
<title>READING IMPUTS FROM THE FORM </title>
</head>
<body>
<?php
echo "<p><b>YOUR NAME IS: </b>".$_POST['user']."</p>";
echo "<p><b>YOUR ADDRESS IS: </b>".$_POST['address']."</p>";
echo "<p><br>YOUR PRODUCT CHOICES ARE:<br></p>";
if(!empty($_POST['products'])){
echo "<ul>";
foreach($_POST['products'] as $value) {
echo "<li>$value";
}
echo "</ul>";
}
?>
</body>
</html>

And please use code tags as it makes the code easier to read.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Trying placing the following in your htaccess file and place the htaccess file in the same folder as the homepage:

RewriteEngine On
RewriteRule ^([^.]+[^/])$ $1.php

Also note that when linking to directories such as the hompage you may need a forward slash at the end.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Doesn't make sense to me. When there is two topics with the same category, you will run into problems. Maybe I am not thinking correctly as its 4:47am but I can't think of how that would work.

Well I have designed it so that if there are two topics or more topics in the one category, the category field will always contain the same category name as like an identifier and that is what the following if statement is all about:

if ($catid!==$row['catname']) {
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

As you've mentioned, it is best to have 1 table as it will save recourses and space. So the table structure will be as follows:

tblCategory
cat_id as primary key
cat_name as nvarchar
topic_id as nvarchar
topic_name as nvarchar

Then to retrieve the data and display it as the html format shown in post #1, simply use the following:

<?
//mysql connections

$result=mysql_query('SELECT * FROM `tblCategory` ORDER BY cat_id');
$catid=false;
while ($row=mysql_fetch_array($result)) {
    if ($catid!==$row['catname']) {
        if ($catid==false) {
            echo '<ul><li>'.$row['cat_name'].'</li><ul>';
            } else {
            echo '</ul><li>'.$row['cat_name'].'</li><ul>';
            }
        echo '<li>'.$row['topic_name'].'</li>';
        }
    $catid=$row['cat_name'];
    }

Hope that helps.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

If you would like it to post on server side then you could just use curl. So the following is an example script that will display only the paypal page but still submit the post variables to the second link:

$vars='';
foreach ($_POST AS $key => $val) {
$vars.=$key.'='.$val.'&';
}
$vars=substr($vars,0,-1);
$ch = curl_init();
// set the target url
curl_setopt($ch, CURLOPT_URL,'xyz.com/order/email_order.php');
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.15) Gecko/20080623 Firefox/2.0.0.15") ); // request as if Firefox
// howmany parameter to post
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS,$vars);
curl_setopt($ch, CURLOPT_NOBODY, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$dresult= curl_exec ($ch);
curl_close ($ch);

//now for paypal
$ch = curl_init();
// set the target url
curl_setopt($ch, CURLOPT_URL,'https://www.paypal.com/cgi-bin/webscr');
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.15) Gecko/20080623 Firefox/2.0.0.15") ); // request as if Firefox
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS,$vars);
curl_setopt($ch, CURLOPT_NOBODY, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result= curl_exec ($ch);
curl_close ($ch);
echo $result;

So if you post to a page that has just the above script, the above script will then re-post the data to the 2 links provided.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

hi,
In htaccess

RewriteEngine on
RewriteBase /project_test/

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^projects/(.*)/$ project_detail.php?pname=$1 [L]

and my project_detail.php file at
http://localhost/demo/abc/index.php
http://localhost/demo/abc/project_detail.php
when click on link
http://localhost/demo/abc/projects/school-project/
IT gives page not found

I think some modification needed at this line

RewriteRule ^projects/(.*)/$ project_detail.php?pname=$1 [L]

plz tell me what to do??

Try making the following your .htaccess file:

RewriteEngine on

RewriteRule ^projects/(.*)/$ project_detail.php?pname=$1

Also make sure that mod_rewrite is enabled in the apachie configurations.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

If you meen to check 4 more fields in the mysql query then you will need to specify them in one long string like the following:

mysql_query('SELECT * from dbname WHERE type="'.mysql_real_escape_string($type).'" AND location="'.mysql_real_escape_string($location).'" AND gender="'.mysql_real_escape_string($gender).'" AND married="'.mysql_real_escape_string($married).'" AND photo="'.mysql_real_escape_string($photo).'"');

I think that's what your talking about - is there any way of making the mysql_query shorter and the answer is not unless you want the query to be able to select a wider range of rows by specifying fewer columns after the where clause.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Try this:

<?
$result=mysql_query('SELECT * FROM `table`');
$fields=mysql_fetch_array($result);
foreach($fields AS $field) {
    $string.=$field;
    } unset($field);
$kilobites=strlen($string);
$kilobites=$kilobites/1024;

echo $kilobites;
?>

Basically the string length is the number of bytes and there are 1024 bytes in a kilobite.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Try the following:

<?php

   function showproducts($catid, $page, $currentpage, $newpage)
   {
      $query = "Select count(prodid) from products where catid = $catid";
      $result = mysql_query($query);
      $row = mysql_fetch_array($result);
      if ($row[0] == 0)
	  
      {
         echo "<h2><br>Sorry, there are no products in this category</h2>\n";
      }
      else
      {
         $thispage = $page;
         $totrecords = $row[0];
         $recordsperpage = 3;
         $offset = ($thispage - 1) * $recordsperpage;
         $totpages = ceil($totrecords / $recordsperpage);
         echo "<table width=\"100%\" cellpadding=\"1\" border=\"0\">\n";
         $query = "SELECT * from products WHERE catid=$catid LIMIT $offset,$recordsperpage";
         $result = mysql_query($query); 
         $var=1;
         while ($var=mysql_fetch_array($result, MYSQL_ASSOC))
         {
         unset($var);
         echo '<tr>';
         for ($x=0; $x<4, $row=mysql_fetch_array($result, MYSQL_ASSOC) ; $x++) {
            $prodid = $row['prodid'];
            $description = $row['description'];
            $price = $row['price'];
            $quantity = $row['quantity'];
            $onsale = $row['onsale'];

            echo "<td>\n";
               echo "<img src=\"showimage.php?id=$prodid\" width=\"150\" height=\"150\">\n";

			     echo "<a href=\"$newpage&id=$prodid\">$description\n";
               echo "$" . $price . "\n";

            if ($onsale)
               echo "On sale!\n";
            else
               echo "&nbsp;\n";
            echo "</td>\n";
            }
         echo '</tr>';
         $var=$row;
         }
         echo "</table>\n";   // Code to implement paging
         if ($thispage > 1)
         {
            $page = $thispage - 1;
            $prevpage = "<a href=\"$currentpage&cat=$catid&page=$page\">Previous page</a>";
         } else
         {
            $prevpage = " ";
         }         if ($thispage < $totpages)
         {
            $page = $thispage + 1;
            $nextpage = " <a href=\"$currentpage&cat=$catid&page=$page\">Next page</a>";
         } else
         {
            $nextpage = " ";
         }         if ($totpages > 1)
            echo $prevpage . "  " . $nextpage;      }
   }

?>

I just tested that script for the unknown error you mentioned and found that the for loop opening line needed to be replacing with the following:

for ($x=0; $x<3, $row=mysql_fetch_array($result, MYSQL_ASSOC) ; $x++) {

Then that just leaves the …

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I thank yo Cwarn23, I tried the code and unfortunately it did not work. It came out exactly like the result I had. The only difference is that it minus by one, the amount of item shown on the page.

I am trying the code below, but I am getting undefine variable for $table and my content for row on the $table .= "<td>{$row}</td>"; line I think is wrong. Because it mark as undefine
This is the code that I am now trying from Keith. Knowing me I am screwing up something. The other guy from the other thread successfully made his page work just like how I want mines to work. But I don't know what I am doing wrong. I even found out by messing aournd with Cwarn and Keith code that my table I had thought was going from left to right I made it wrong. So now I have another problem because it is going downward: vertically. But I think it might correct itself if the page is set up for the images to display as:
image image image
image image image
image image
next page

Well by reading that I don't 100% understand how you want the images to be displayed. From that it looks like you want to have an empty cell at the end of the table due to the number of images. And do you want pegination? Looks like it judging by the next page text at …

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Try the following:

<?php

   function showproducts($catid, $page, $currentpage, $newpage)
   {
      $query = "Select count(prodid) from products where catid = $catid";
      $result = mysql_query($query);
      $row = mysql_fetch_array($result);
      if ($row[0] == 0)
	  
      {
         echo "<h2><br>Sorry, there are no products in this category</h2>\n";
      }
      else
      {
         $thispage = $page;
         $totrecords = $row[0];
         $recordsperpage = 3;
         $offset = ($thispage - 1) * $recordsperpage;
         $totpages = ceil($totrecords / $recordsperpage);
         echo "<table width=\"100%\" cellpadding=\"1\" border=\"0\">\n";
         $query = "SELECT * from products WHERE catid=$catid LIMIT $offset,$recordsperpage";
         $result = mysql_query($query); 
         $var=1;
         while ($var=mysql_fetch_array($result, MYSQL_ASSOC))
         {
         unset($var);
         echo '<tr>';
         for ($x=0; $x<4, $row=mysql_fetch_array($result, MYSQL_ASSOC) ; $x++) {
            $prodid = $row['prodid'];
            $description = $row['description'];
            $price = $row['price'];
            $quantity = $row['quantity'];
            $onsale = $row['onsale'];

            echo "<td>\n";
               echo "<img src=\"showimage.php?id=$prodid\" width=\"150\" height=\"150\">\n";

			     echo "<a href=\"$newpage&id=$prodid\">$description\n";
               echo "$" . $price . "\n";

            if ($onsale)
               echo "On sale!\n";
            else
               echo "&nbsp;\n";
            echo "</td>\n";
            }
         echo '</tr>';
         $var=$row;
         }
         echo "</table>\n";   // Code to implement paging
         if ($thispage > 1)
         {
            $page = $thispage - 1;
            $prevpage = "<a href=\"$currentpage&cat=$catid&page=$page\">Previous page</a>";
         } else
         {
            $prevpage = " ";
         }         if ($thispage < $totpages)
         {
            $page = $thispage + 1;
            $nextpage = " <a href=\"$currentpage&cat=$catid&page=$page\">Next page</a>";
         } else
         {
            $nextpage = " ";
         }         if ($totpages > 1)
            echo $prevpage . "  " . $nextpage;      }
   }

?>