473,327 Members | 2,016 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Methods of accessing variables

Hi all,

Okay after reading some text on PHP i have come across my first query...

What is the best method in using and accessing varibales... my book gives me
three methods but gives pro's and con's for each

1) $myvarb
2) $_POST['myvarb']
3) $HTTP_POST_VARS['myvarb']

Which is the most robust. i.e. I would obviously like to use mehod 1 buit is
that common amongst all versions of PHP?

Thanks in advance,

Domestos
Jul 17 '05 #1
2 1956
Domestos wrote:
Hi all,

Okay after reading some text on PHP i have come across my first query...

What is the best method in using and accessing varibales... my book gives me
three methods but gives pro's and con's for each

1) $myvarb
2) $_POST['myvarb']
3) $HTTP_POST_VARS['myvarb']

Which is the most robust. i.e. I would obviously like to use mehod 1 buit is
that common amongst all versions of PHP?

Thanks in advance,

Domestos


$_POST is the one you should be using. $HTTP_POST_VARS is deprecated,
and $var will not work by default from PHP 4.2 onwards.

--
Chris Jenkinson
Jul 17 '05 #2
Awesome...That worked! Thank you. I used the empty() function, however
moving the username db query to the end is what solved problem. The next
thing im trying to fix is to check file attachment for proper mime type
extension. Doesnt seem to work either, dies after password validation. It
does read through the photo validation because if i enter a username in db
then it does call $msg = "This username is taken, please choose a
different one.";
} elseif ($password != $password2) {
$focus = "password2";
$msg = "Passwords do not match.";

} elseif ($photo > 0) {

$ext = strtolower(substr($photo, -3));

if ($ext == "peg") { $ext = "jpg"; }

if ($ext != "gif" || $ext != "jpg" || $ext != "jpeg" || $ext != "bmp" )
{

$msg = "Please provide a valid gif, jpeg, or bmp photo";

}

if ($ltype == "1") { $type = "hotel"; }
if ($ltype == "2") { $type = "inn"; }
if ($ltype == "3") { $type = "bandb"; }
if ($ltype == "4") { $type = "resort"; }

$imgdir = "$DOCUMENT_ROOT/lodging/$type";
if (!file_exists($imgdir)) { mkdir($imgdir, 0755); }
$imgdir.= "/$account_id";
if (!file_exists($imgdir)) { mkdir($imgdir, 0755); }

move_uploaded_file($photo, "$imgdir/photo1.jpg");

if (file_exists("$imgdir/photo1.jpg")) {
$foo = '/usr/local/bin/convert -unsharp 1x1x1x1 -thumbnail 150x110
$imgdir/photo1.jpg $imgdir/photo2.jpg';
move("$imgdir/photo2.jpg", "$imgdir/photo1.jpg");
}

$addr = "Email Adress Here";
$subject = "Client #$account_id - Lodging Photo Uploaded";
$body = "Image located in: $imgdir/photo1.jpg";
mail($addr, $subject, $body);

} elseif ($username) {

$q = "SELECT id FROM account WHERE username='". apos($username) ."'";
$res = mysql_query($q);
$num = mysql_num_rows($res);

if ($num > 0) {
$focus = "username";
$msg = "This username is taken, please choose a different one.";

}} else {

$q = "INSERT INTO account (";
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

27
by: gabor | last post by:
hi, as far as i know in python there aren't any private (i mean not accessible from the outside of the object) methods/fields. why? in java/c++ i can make a method private, this way...
99
by: David MacQuigg | last post by:
I'm not getting any feedback on the most important benefit in my proposed "Ideas for Python 3" thread - the unification of methods and functions. Perhaps it was buried among too many other less...
4
by: Neil Zanella | last post by:
Hello, I would like to know whether it is possible to define static class methods and data members in Python (similar to the way it can be done in C++ or Java). These do not seem to be mentioned...
11
by: Roger Leigh | last post by:
The C++ book I have to hand (Liberty and Horvath, Teach yourself C++ for Linux in 21 Days--I know there are better) states that "static member functions cannot access any non-static member...
2
by: blue | last post by:
We have an abstract class with all static methods. It makes sense to have it static because there are no member variables and the constructor is empty. Some of the methods update the SQL Server...
15
by: Laser Lu | last post by:
I was often noted by Thread Safety declarations when I was reading .NET Framework Class Library documents in MSDN. The declaration is usually described as 'Any public static (Shared in Visual...
14
by: Karsten Dambekalns | last post by:
Hi. Thomas Mlynarczyk wrote: Why do you want them to be private in the first place? I have yet to see code where this really makes sense... And if it does, then the external public API is...
1
by: alireza6485 | last post by:
Hi,Please help me to answer this question.I tried my best and I am not sure if my code is good or useless. I am writing a program that calculates projectile motion. so the ball is thrown with...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.