|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
I have the following if statement...
PHP Code:
But I get the following error... Parse error: parse error, unexpected T_BOOLEAN_OR in C:\FoxServ\www\grabfile.php on line 19 And this is from a script copied straight out of a text book! Any ideas as to why I am getting this error? Your help is always appreciated! Gee |
|
#2
|
|||
|
|||
|
PHP Code:
__________________
~ Joe Penn We work for free to help make this a valuable resource on the internet. Do you appreciate the help - did we provide help that will help you prosper and help that has contributed to sharpening your current skill set? Show your appreciation and purchase something from our Amazon Wishlist's - it's simple and a great way to say thank you. |
|
#3
|
|||
|
|||
|
PHP Code:
Just to let you know the problem was in your if statement if (!$ModCode) is the first part of the code, you closed off your if statement too early, hence the problems occuring. |
|
#4
|
|||
|
|||
|
ThnX,
That solved the problem... however, now the script always returns "you have not completed the form properly, go back and try again". Even though I make sure I enter the correct data into each field on the form. I had this same problem with another tutorial I was working on, saying I hadn't filled in all the form properly when I made sure I did. Any Ideas? I keep running into brick walls here! Gee ![]() |
|
#5
|
|||
|
|||
|
Have you checked that the name of the forms are the same as the name of the variables you are checking in your if-statement?
Maybe a dumb question but hey ![]() |
|
#6
|
|||
|
|||
|
PHP Code:
make sure you have the exact variable names, and try to use the superglobals ![]() |
|
#7
|
|||
|
|||
|
Hey ThnX Crazytrain81,
And all u other guys for helping me out. I am finally starting to get the hang of this language!!! One thing however, is this business with naming variables, $varname; global $varname; $_POST[varname]; and you mention superglobals? my text book doesnt have much on this subject and I find the online manual doesnt explain things very well. Do you know of any tutorials out there that address this subject or maybe you could tell me in plain n simple terms (haha) exactly how I should be declaring each of my variables. All the examples in my book just declare them as $varname; Gee ![]() |
|
#8
|
|||
|
|||
|
In the variables section of the php manual at php.net, you'll see a section for 'predefined' variables. It goes in depth into the superglobals, $_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_SESSION, and the scarcely used $_REQUEST.
A very brief explanation of these... first of all, they're intended to replace $HTTP_X_VARS arrays. The main purpose is an easy, always-accessible method to access variables that are 'beyond the scope' of your script. eg, $_REQUEST, $_GET, $_POST.. they're all part of the http request. $_SERVER is based on http data your server has about the requesting host. $_ENV contains server environment information. I'd just check that part of the manual.. hope this helped =P |
|
#9
|
|||
|
|||
|
Hey Crazytrain,
I am gonna study that manual and make sure Ive got the information sunk into my brain! Still that if statement doesnt work. I have attached my form, script and database file if anyone wants to take a look at it. I WOULD BE VERY GRATEFUL Gee ![]() |
|
#10
|
|||
|
|||
|
Hey peoples
I got the if statement working finally, using the $_POST['var'], ThnX for that!!! haha - but its not over yet... ![]() ok - all my code now seems to run fine apart from this... PHP Code:
the problem is, only the first value 0, goes into my table no problem, I use this as a unique file id (It works correctly, giving a new id each time a record is inserted) . All the rest of the values do not insert into the table (when I look at the table in mysql these records contain NULL values). Is this my bad syntax again? Ive checked n checked n changed it but still ziltch. Massive respect if you can put this 1 to bed!!! Gee |
|
#11
|
|||
|
|||
|
Gee,
You should put your string variables within quotes when placing them in an SQL statement. Also, I'm not sure if they're variables or not, but you should be using your variable values. PHP Code:
Hope it helps!
__________________
____________________________________________ Developer Shed Weekly Writer | DevArticles Forum Moderator Build Your Own KlipFolio Klip With PHP FrankManno.com - Under Construction Design Interactive Group - Under Construction |
|
#12
|
|||
|
|||
|
Frankieshakes,
Yes they are variables recieved from a user form. But your method unfortunatly still doesn't work for me. Any other ides? ThnX Gee |
|
#13
|
|||
|
|||
|
PHP Code:
When anything is submitted via a form you should always use $_POST[] In this cause, because $_POST is actually an array, you must encase the array $_POST[] in {} |
|
#14
|
|||
|
|||
|
ThanX Ben and everyone else,
My script is working perfectly now! ![]() Is this the normal way of handling such variables or have I taken a longer way round than most would? (Works a treat though!). What makes me say this is just because there is an awful lot of syntax needed for each variable. '{$_POST['modCode']}', Gee ![]() |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > if statment not working? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|