Jump to content

[SOLVED] PHP SYNTAX ERROR ! Need Help


logicopinion

Recommended Posts

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 !

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.  ???

Link to comment
Share on other sites

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!";

}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.