veedeoo 474 Junior Poster Featured Poster

Hi,

It all depends on server configuration. You will need to find out these configurations by using the codes below.

Save as anyfileYoulike.php

<?php phpinfo(); ?>

Upload to your server and direct your browser to this file. Look for the value of Server API . If your server says CGI or FAST CGI, then you need to make those entries on php.ini file. Meaning, you can create a new file and name it as php.ini, and then upload it to your server. It could be either in the same level of the directory needing the increase in max_filesize or above it.

Here is the content of your php.ini file

upload_max_filesize = 50M
post_max_size = 50M
max_execution_time = 500
max_input_time = 500

If your server API says, Apache 2.0 Handler , apache module or anything about apache, then your .htaccess file should look like this

php_value upload_max_filesize 50M
php_value post_max_size 50M
php_value max_execution_time 500
php_value max_input_time 500

Remember to check what is on your phpinfo() first.. normally your upload_max_filesize would show 8M and not 8Mb...

WARNING! You CANNOT use BOTH.. ONLY ONE mUST be selected.. CGI or Apache...

R.Manojkumar commented: Thank your very much, problem solved brother +0
veedeoo 474 Junior Poster Featured Poster

correction!

Change this...

$total_AmountDue = $total_Mprice + $total_Mprice + $total_Mprice ;

to this

$total_AmountDue = $total_Sprice + $total_Mprice + $total_Lprice ; 
echo "Must Pay ".$total_AmountDue." Immediately, or else I will eat these Pizza";

if you will be adding sales tax to your cutomer total amount due, then it should changed to

$gross_AmountDue = $total_Sprice + $total_Mprice + $total_Lprice ; 
$tax_Rate = 9.5 ; ## this is for a sales tax rate of 9.5 percent
$total_AmountDue = round((($gross_AmountDue) * ($tax_Rate / 100)), 2 );
echo "Must Pay ".$total_AmountDue." Immediately, or else I will eat these Pizza";
veedeoo 474 Junior Poster Featured Poster

Hi,

You can add <input> to your form and give them a name unique to the pizza size. Fore example, take a look at the codes below..

<INPUT TYPE=checkbox NAME="pica10" VALUE="S">10" Php300 
<input type="text" name="sq" value=""/> 
      <INPUT TYPE=checkbox NAME="pica14" VALUE="M">14" Php450 
	  <input type="text" name="mq" value=""/> 
      <INPUT TYPE=checkbox NAME="pica18" VALUE="L">18" Php650
	  <input type="text" name="lq" value=""/>

Then on your form processor, you need to make sure that specific pizza has been selected, otherwise you might end up charging the customer for something they did not order. Use jquery to validate your form for the quantity.. it has to be an integer.

So, look for something like

if(($_POST['pica10']) && ($_POST['sq'])){
## set condition if the quantity is not empty then proceed below

## calculate the sum of the small pizza ordered
$total_Spizza = 1 * ($_POST['sq']);
## calculate the price of the small pizza
## WARNING! DO NOT put any integer inside the quotes..it don't matter if single or double
$total_Sprice = 300 * ( $total_Spizza );

## if quantity is empty $total_Spizza = 0

}

if(## this is for medium pizza){
## Do the same for the medium pizza exact format as above
$total_Mpizza ="";
$total_Mprice ="";

}

## do the same for the large
if(){

}

## calculate the sum of the total bills to be paid by custumer

$total_AmountDue = $total_Mprice + $total_Mprice + $total_Mprice ; 

## calculate the total Pizza you need to bake and deliver to the customer

echo "Need to bake".$total_Spizza." Small Pizza ".$total_Mpizza." Medium …
veedeoo 474 Junior Poster Featured Poster

try.. make sure the directory and the file name are properly assigned below.

if (file_exists($attcid."whatever.extensionOfFile"){
						@unlink($attcid."whatever.extensionOfFile") ;
					}
else{

echo "Are you kidding me? This file don't even exist. I already looked.";

}
karthik_ppts commented: Useful post +6
veedeoo 474 Junior Poster Featured Poster

The echo test..

ok let's do it this way first.. We need to see if the form data is being posted on the script side and the data is even being pick up; what we are trying to insert.

<?php
    mysql_connect("localhost", "root", "test") or die(mysql_error());
    mysql_select_db("testdb") or die(mysql_error());
     
    ## lets remove the error suppressors for now
    $username = $_POST['name'];
    $country =  $_POST['country'];
    
    if (isset($_POST['submit'])) {
## we need to comment out the query first to see if it is posting your form
/*
        mysql_query("INSERT INTO users(name, country) VALUES('$username', '$country' ) ")
    or die(mysql_error());

  
*/

## lets echo the username and country to view the result
 echo $username."<br/>";
echo $country."<br/>";
    }   
    ?>
    <form method="post">
    username<input type="text" name="name" value=""> </br>
    country<input type="text" name="country" value=""></br>
    <input type="submit" name="submit" value="Submit">
    </form>

If you are viewing the username and country, you script is working. You can then remove the comment tags and try again if it will post on your database.


I just realize that all along the error on your code are these..

if (isset($_POST['Submit']))

and

<input type="submit" name="submit" value="Submit">

to correct the problem, the above should be changed to this

if (isset($_POST['submit']))

You will probably noticed that I already made a correction on your codes on the echo test

veedeoo 474 Junior Poster Featured Poster

try changing this

mysql_query("INSERT INTO users(name, country) VALUES('$username', '$country' ) "); 
or die(mysql_error());

to this

mysql_query("INSERT INTO users(name, country) VALUES('$username', '$country' ) ")
or die(mysql_error());

The T_LOGICAL_OR error is caused by ; the or die is part of your statement and should not be separated from the query.

Just a humble question, what is the reason behind this code?

if (isset($_REQUEST['Submit']))

Can't we just make it like this?

if (isset($_POST['Submit']))

or

if (isset($_GET['Submit']))

$_REQUEST is generalized form processor function. Many people find it handy, because you don't even have to take a second look on whatever form method assignment they have on the form. One function takes all...

I don't see much problem using $_REQUEST in non-database pagination applications, or maybe some flat file processing where data is somewhat pretty casual in terms of security. However, if the application is going to be inserting, deleting, dropping, and updating data, it can create some security issues on the application.

veedeoo 474 Junior Poster Featured Poster

@evanburry,

Try changing this part of you codes

$src = 'images/outofstock.gif';

To this

echo 'images/outofstock.gif';
veedeoo 474 Junior Poster Featured Poster

Hi,

Thanks for clearing that out. :) I was only joking of course. :).

To print the current page where the browser is on, we need javascript function something like window.print()

So, my example would be like this..

<?php

echo "Hello I am written by way of php echo function, but I will definitely get printed by way of javascript function";

?>
<!-- we do it by form -->
<form>
<input type="button" value="Print Me" onClick="window.print()" />
</form>
<br/>
<!-- or do it by text link -->
<a href="#" onClick="window.print()"/>Print Me</a><br/>
veedeoo 474 Junior Poster Featured Poster

Hi,

I don't intend to sound like as if I am really dumb or stupid, I mean nothing like that :). You mean "print" as in "echo" in php? Or print as executing the viewer's printer attached to its desktop?

veedeoo 474 Junior Poster Featured Poster

I think this

$result = mysql_query("SELECT * FROM post_categories");

while ($row = mysql_fetch_array($result)){

echo $row['Name'];

}

Will not stop outputting, while $row = mysql_fetch_array($result)) if still equal to be true.

And this one will only output one

$result = mysql_query("SELECT * FROM post_categories");

$row = mysql_fetch_array($result)

echo $row; //because of this

However, this will output all of them also

$result = mysql_query("SELECT * FROM post_categories");

print_r(mysql_fetch_array($result));
veedeoo 474 Junior Poster Featured Poster

Hi,

Here is the simple example for both of the responses above.

<?php
$first_ar = array('one','two','three','four','five','six','seven');
$second_ar = array('two','ten','eleven','five','twelve','nine','three');
	       $result = array_intersect($first_ar, $second_ar);
foreach($result as $something){
	
	
	echo "Matched: ".$something."<br/>";
}

?>
veedeoo 474 Junior Poster Featured Poster

Hi,

This maybe the simplest example I could ever think of.. Say, your above xml file is called test.xml, then you can easily parse the email XX and the name: XX from it by using these few lines of php codes.

<?php
## type in your xml file location
$xml ='test.xml';
## remove @ to debug
$xml = @simplexml_load_file($xml); 
 foreach($xml as $items)
{
echo "Name: ".$items->value[2]." Email: ".$items->value[4]."<br/>";

}

  ?>

We can also assign them into variables as you wish, as shown in my example below..

$name = $items->value[2];
$email = $items->value[4];


You may want to consider setting up some check points to see if the xml file does exist, like so

if (file_exists('test.xml')) {
$xml = @simplexml_load_file($xml);

}
## instruct the script what to do if xml file does not exist.

else{

## it's your call here

}

veedeoo 474 Junior Poster Featured Poster

Hi,

I can show you how to do a pseudostreaming for flv videos, and a quick start on MP4/h264 just like the one you see on youtube. However, before I can do that you need to change your player preferences . It has to be jwplayer or flowplayer. On top of the player change, you will need to have flvtool2,ffmpeg, and ffmpeg php installed on your server, OR at least have the means to inject metadata on your videos prior to uploading them in your server.

The quick start for the mp4/h264 videos requires an mp4box installed on your server, and the ffmpeg installation must be compiled with the x264 if you are to encode videos in the server. Otherwise, some GUI video encoders and MOOV ATOM relocators will just do as fine as what I have already mentioned above.

I wrote many scripts for video applications, including bandwidth calculators, remote server transfer to and fro, video server load balancer, and remote server streamers by way of HTTP and RTMP video streaming, and the script that went flop flv VOD..that did not make the cut at all ;).

veedeoo 474 Junior Poster Featured Poster

Can you please confirm if the password in your database was posted as md5 hash? You can check it on your MyPhpAdmin..locate the member in questions, and then check the password column. In the password column the password should look something like this 9cafeef08db2dd477098a0293e71f90a, or you can check the form processor on your registration page if the password made by the new user is being posted as md5..for example $password = md5($_POST).

If it was not or your registration form processor does not convert the password to md5, then do what prvnkmr194 is suggesting.

veedeoo 474 Junior Poster Featured Poster

Hi,

Without any intend of disrespect, session_register is deprecated in php version 5.3.x . Plus it is a dangerous thing to do security wise. http://php.net/manual/en/function.session-register.php

Just in case some people are trap into using this php function, because their sessions are stack within an array.. The simple solution is put the sessions in an array as shown below.
$session_inarray = array($user,$info1,$info2, $info3, $some_moreinfo_here);
## assign the above into session
$_SESSION = $session_inarray;
## to get the values in the session onto the other page, we simply do it
$user = $_SESSION[0]; $info1 = $_SESSION[1];...and so forth.

My post may not directly answer your questions, but it addressed one of the most critical issues on your script.

veedeoo 474 Junior Poster Featured Poster

Hi martymaven,

Can we please see at least a sample of the codes that you have..

e.g. $query =("SELECT * FROM employee WHERE id = '".$some_id."' LIMIT 1") ;

Something like that or your employee table structure such as

id | name | department | position | rate | supervisor | personal info 1 | personal info. 2 |

something very similar to the above can truly get people here going at it :).

veedeoo 474 Junior Poster Featured Poster

Hi Matt,

You may want to read this first http://php.net/manual/en/features.file-upload.php.

The keywords for your question are if (empty($_FILES) && empty($_POST) && isset($_SERVER)

Please read the above link and try to integrate some of the methods they used. If still does not work for you, let us know and I will write the codes for you.

veedeoo 474 Junior Poster Featured Poster

you are very much welcome :).

veedeoo 474 Junior Poster Featured Poster

Hi,

I just borrowed this from someone...please see the script's credit on top. This might be more than what you need..if it just table names that you want, then just remove the bottom part of the script.

<?php
/****************
* File: displaytables.php
* Date: 1.13.2009
* Author: design1online.com
* Purpose: display all table structure for a specific database
****************/

//connection variables

$host = "localhost";
$database = "database";
$user = "user";
$pass = "password";

//connection to the database
mysql_connect($host, $user, $pass)
or die ('cannot connect to the database:' . mysql_error());

//select the database
mysql_select_db($database)
or die ('cannot select database:' . mysql_error());

//loop to show all the tables and fields
$loop = mysql_query("SHOW tables FROM $database")
or die ('cannot select tables');

while($row = mysql_fetch_array($loop))
{

echo "
<table cellpadding=2 cellspacing=2 border=0 width=75%>
<tr bgcolor=#666666>
<td colspan=5><center><b><font color=#FFFFFF>” . $row[0] . “</font></center></td>
</tr>
<tr>
<td>Field</td><td>Type</td><td>Key</td><td>Default</td><td>Extra</td>
</tr>";

$i = 0;

$loop2 = mysql_query("SHOW columns FROM " . $row[0])
or die ('cannot select table fields');

while ($row2 = mysql_fetch_array($loop2))
{
echo "<tr ";
if ($i % 2 == 0)
echo "bgcolor=#CCCCCC";
echo "><td>". $row2[0] . "</td><td>". $row2[1] . "</td><td>" . $row2[2] . "</td><td>" . $row2[3] . "</td><td>" . $row2[4] . "</td></tr>";
$i++;
}
echo "</table><br/><br/>";

}
?>
veedeoo 474 Junior Poster Featured Poster

,and here is how you can sort the allowed extensions. This will be based on the codes presented above.

$username= "Member Name";
$filename = strtolower($_FILES['file']['name']);
//lets get the extension of uploaded image
$ext = strtolower(substr($filename, strrpos($filename, '.') + 1));
//compare the uploaded extension to allowed extensions
$allowed_exts = array('jpg', 'gif', 'bmp', 'png');
if ((array_search($ext, $allowed_exts) !== FALSE)){
//do whatever you want here
 // can name the image file with the username of the uploader if you want
$filename = str_replace(" ", "-", $username).".".$ext;
//move the uploaded file with the username name
move_uploaded_file($_FILES['file']['tmp_name'], $path.$filename);
//insert to database

}
else{
echo "File extension NOt allowed";

}