|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today! |
|
#1
|
|||
|
|||
|
i have a if statement which doesn't work which is:
include("../db_funcs/dbconnect.inc"); if(!$cat_name || !$lang_select) echo "Please enter all the necessary fields"; else{ $sql = "INSERT INTO q_cat (cat_name, lang) VALUES ('$cat_name', '$lang_select')"; $result = mysql_query($sql); echo "<strong>Category successfully added to the database...</strong>\n"; echo "onload=\"where='index.php'; setTimeout('document.location.href=where',2000);\""; } what is the problem and how can i find a good tutorial about using javascript in php??? |
|
#2
|
|||
|
|||
|
Re: Not working if???
PHP Code:
You missed out the opening and closing curly braces on the if statement. |
|
#3
|
|||
|
|||
|
I opened for else and close for it but it is not necessary for if i think, i mean it is working without the line of
PHP Code:
it is a javascript and i think i am writing it wrong... |
|
#4
|
|||
|
|||
|
you dont need curley braces if you only have one line after
say if() //code here that would excute if above if statement is true |
|
#5
|
|||
|
|||
|
Are you sure? I'd always used the curly braces religiously... how else would PHP know when to start executing the code and where to stop?
PHP Code:
|
|
#6
|
|||
|
|||
|
Kanu,
I, too, use braces for all my if statements, but you don't necessarily need them if you have single-lined IF statements. They are only required for multi-lined statements...
__________________
____________________________________________ Developer Shed Weekly Writer | DevArticles Forum Moderator Build Your Own KlipFolio Klip With PHP FrankManno.com - Under Construction Design Interactive Group - Under Construction |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > Not working if??? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|