IF ELSE statement

I'm trying to use php with an if/else statement but i cannot get it to work. I have it working perfectly in Perl but PHP not so much.
<?   # Dialer_pull.php
error_reporting(E_ALL);

$vendor_id=$_GET["vendor_id"];
$user=$_GET["user_custom_one"];
$firstname=$_GET["first_name"];
$lastname=$_GET["last_name"];
$street=$_GET["address1"];
$city=$_GET["city"];
$state=$_GET["state"];
$zip=$_GET["postal_code"];
$phone=$_GET["phone_number"];


if (strlen($vendor_id)>0)
        {
        $hostname="";
        $username="";
        $password="";
        $database="";

        // Connect to the database
        mysql_connect($hostname, $username, $password) OR DIE("Unable to connect");
        mysql_select_db("$database") or die("Unable to select database");


        $query="UPDATE vtiger_crmentity SET smownerid='$user' where crmid='$vendor_id';";
        $checkresult = mysql_query($query);
        if ($checkresult) echo 'Lead assigned to you successfully'.' '. '--> ';
        else echo 'update query failed';

        $query="UPDATE vtiger_leaddetails SET leadstatus='Contacted' where leadid='$vendor_id';";
        $checkresult = mysql_query($query);
        if ($checkresult) echo '<a href="http://website/crm/index.php?module=Leads&parenttab=Sales&action=DetailView&record='.$vendor_id.'">Click here to view lead in the$
        if ($checkresult) echo '';
        else echo 'update query failed';

        //mysql_close();
        }
else
        {
        else echo 'Vendor Lead Code not valid';
        }

?>

Open in new window

alxmrtAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
Line 42 - lose the word "else"
0
betawarzCommented:
That's the correct syntax. How is it not working? Is the first condition never being met? Check to see if your variable contains the value you expect it to.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ray PaseurCommented:
Also, you might want to try working out a coding standard to keep your control structures lined up.  I like to use braces on their own lines and indent each control structure four spaces.  It's a modified Zend standard that I find easy to read.  Braces line up with the first character of the statement that initiates the inflection point in the logic.

And with things like this extract from lines 27 - 30, see the code snippet for a way to get better diagnostic information out of that code.

        $query="UPDATE vtiger_crmentity SET smownerid='$user' where crmid='$vendor_id';";
        $checkresult = mysql_query($query);
        if ($checkresult) echo 'Lead assigned to you successfully'.' '. '--> ';
        else echo 'update query failed';

$query  = "UPDATE vtiger_crmentity SET smownerid='$user' where crmid='$vendor_id'";
$result = mysql_query($query);
if (!$result)
{
    $msg = "QUERY FAILED: $query";
    $msg .= '<br/>' . mysql_errno() . ' ' . mysql_error();
    die($msg);
}
echo 'Lead assigned to you successfully --> ';

Open in new window

0
Introduction to R

R is considered the predominant language for data scientist and statisticians. Learn how to use R for your own data science projects.

Ray PaseurCommented:
And one last note, not related to the redundant "else" but important before you release this code into the wild.  Learn about this function.  It will save your data base some day, I promise.
http://php.net/manual/en/function.mysql-real-escape-string.php

All the best, ~Ray
0
Dave BaldwinFixer of ProblemsCommented:
Line 34 appears to be incomplete also.
0
Ray PaseurCommented:
@Dave: Good point.
@alxmrt: What is the error message that you get?  If it's Parse Error, you will get a line number.  Usually that line or one close above it is to blame.
0
alxmrtAuthor Commented:
I figured it out it was my fault. Thank you to all for the responses.

Ray, Thank you once again you are always on point and ready to help. I will be looking into your suggestions and using them moving forward.

Thanks again
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.