logicopinion Posted September 7, 2007 Share Posted September 7, 2007 Hello Guys, This is realy Nice community, i have read and learnt a lot of interesting things on PhpFreeaks.. I am Realy Newbie in PHP and MySQL So i have another Question/Problem i could not solve by MySelf.. Here it is.. i want to check if all these are True: $the_name="$name"; $the_s_name="$s_name"; $the_city="$city"; $the_school_id="$school_id"; $the_telephone="$telephone"; $the_personal_id="$personal_id"; after This If Statmant Should Come: Like .. if ($the_name="$name" $the_s_name="$s_name" $the_city="$city" $the_school_id="$school_id" $the_telephone="$telephone" $the_personal_id="$personal_id" } else { echo "All Fields Should be Filled!"; } ?> But It Gives me Syntax Error and i think i miss something in code (some "" semicolons around or so) please help. Thanks ! Quote Link to comment https://forums.phpfreaks.com/topic/68388-solved-php-syntax-error-need-help/ Share on other sites More sharing options...
lemmin Posted September 7, 2007 Share Posted September 7, 2007 You need the and operator and you need to use a comparison operator for the checks. if ($the_name=="$name" && $the_s_name=="$s_name" && $the_city=="$city" && $the_school_id=="$school_id" && $the_telephone=="$telephone" && $the_personal_id=="$personal_id") EDIT: Although, that should always return true if you just set them to those values. If one is null, it is still checking it against that null value. You should use !isset($the_name) or something. Quote Link to comment https://forums.phpfreaks.com/topic/68388-solved-php-syntax-error-need-help/#findComment-343820 Share on other sites More sharing options...
micah1701 Posted September 7, 2007 Share Posted September 7, 2007 you need an "and" operator ( && ) between each clause in your if statment. $the_name="$name" && $the_s_name="$s_name" && $the_city="$city" && etc... also, why do you need this if statment at all, you already know their all set correctly? you set them in your code in the above lines and this if statement will always return true. ??? Quote Link to comment https://forums.phpfreaks.com/topic/68388-solved-php-syntax-error-need-help/#findComment-343821 Share on other sites More sharing options...
logicopinion Posted September 7, 2007 Author Share Posted September 7, 2007 thank you guys.. i need this because after .. if the value is true it does the next thing { mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("trainings") or die(mysql_error()); mysql_query("CREATE TABLE IF NOT EXISTS trainingsdb( id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), name VARCHAR(100), s_name VARCHAR(100), city VARCHAR(100), school_id VARCHAR(100), proffesion VARCHAR(100), telephone VARCHAR(100), personal_id VARCHAR(100)) ") or die(mysql_error()); mysql_query("INSERT INTO trainingsdb (name, s_name, city, school_id, proffesion, telephone, personal_id) VALUES('$name', '$s_name', '$city', '$school_id', '$proffesion', '$telephone', '$personal_id' ) ") or die(mysql_error()); echo "ოპერაცია წარმატებით შესრულდა. გთხოვთ დაელოდოთ, მიმდინარეობს გადამისამართება..."; echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"5; URL=http://localhost/traingings/index.php \">"; } else { echo "All Fields Should be Filled!"; } Quote Link to comment https://forums.phpfreaks.com/topic/68388-solved-php-syntax-error-need-help/#findComment-343831 Share on other sites More sharing options...
logicopinion Posted September 7, 2007 Author Share Posted September 7, 2007 do you undestand why do i use this thing? do i miss something or need to remove or change something in this code? or its ok? Quote Link to comment https://forums.phpfreaks.com/topic/68388-solved-php-syntax-error-need-help/#findComment-343836 Share on other sites More sharing options...
lemmin Posted September 7, 2007 Share Posted September 7, 2007 Are you having a problem with that code? What is not working? If it is working then there is no reason not to use it. Quote Link to comment https://forums.phpfreaks.com/topic/68388-solved-php-syntax-error-need-help/#findComment-343837 Share on other sites More sharing options...
logicopinion Posted September 7, 2007 Author Share Posted September 7, 2007 everything if working perfectly. Thank You All. C U L8ter. Quote Link to comment https://forums.phpfreaks.com/topic/68388-solved-php-syntax-error-need-help/#findComment-343841 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.