Need an extra set of eyes

Having a problem with this code.
mysql_query($conn,"UPDATE mapfile SET TYPE = .$type, \" TENANT = .$tenant, FRONTAGE = .%fontage, SIC = .$sic
            WHERE SEQ = .$Building_Id and STOREKEY = .$Space_Id";
breeze351Asked:
Who is Participating?
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.

GaryCommented:
mysql_query("UPDATE mapfile SET TYPE =\"$type\", TENANT = \"$tenant\", FRONTAGE = \"%fontage\", SIC = \"$sic\"
            WHERE SEQ = \"$Building_Id\" and STOREKEY = \"$Space_Id\"",$conn); 

Open in new window

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
Dave BaldwinFixer of ProblemsCommented:
Why is there a '%' instead of a '$' in "%fontage"?
0
Ray PaseurCommented:
Fortunately all of the PHP functions are documented in the online man pages.  Example here, showing the mysql_query() function.
http://php.net/manual/en/function.mysql-query.php

When you get to the warning and discover that PHP is doing away with MySQL support, you may find this article helpful.  It shows how to make the required upgrade from MySQL to one of the supported extensions.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/PHP_Databases/A_11177-PHP-MySQL-Deprecated-as-of-PHP-5-5-0.html
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Julian HansenCommented:
Did you cut and paste that from your code or type it in - because there are so many things wrong with it as has been pointed out in previous posts it is not surprising it does not work.

The only change I would make to Gary's post is to use single quotes instead of double around the strings - just makes for a neater look but that is personal preference.
Unless you are using multiple connections you don't have to specify the link resource in the mysql_query call
I also have developed a habit of putting {} around my in-string variables - it is not necessary but it does help to highlight where the variables are.

mysql_query("UPDATE mapfile SET TYPE ='{$type}', TENANT = '{$tenant}', FRONTAGE = '%fontage', SIC = '$sic'
            WHERE SEQ = '{$Building_Id}' and STOREKEY = '{$Space_Id}'"); 

Open in new window


And as Ray mentioned in his post post 5.5 the mysql library is no longer supported - mysql lib calls will simply fail - I would consider moving over to mysqli.

Beyond that - try getting the query to work in a query editor SQLYog, MySQL Workbench or PHPMySQL - once it is working there translate it back into your code.
0
Ray PaseurCommented:
Here is a good way to write a query - construct it in a PHP variable, instead of loading it into the function call.  That way you can visualize the query and you don't have to guess about what might be wrong.

$sql = "SELECT col FROM myTable WHERE name='Ray' LIMIT 1";
$res = mysql_query($sql);
if (!$res)
{
    var_dump($sql);
    echo mysql_error();
    trigger_error("QUERY FAILED", E_USER_ERROR);
}

Open in new window

0
breeze351Author Commented:
Thanks.
I has a bad day yesterday and I couldn't see it.
You ever had one of those where you stare at the code and you can't see it.
Glenn
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.