?
Solved

Need an extra set of eyes

Posted on 2014-10-03
6
Medium Priority
?
71 Views
Last Modified: 2014-10-04
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";
0
Comment
Question by:breeze351
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 58

Accepted Solution

by:
Gary earned 2000 total points
ID: 40360294
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
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 40360375
Why is there a '%' instead of a '$' in "%fontage"?
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 40360412
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
Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

 
LVL 58

Expert Comment

by:Julian Hansen
ID: 40360464
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
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 40360476
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
 

Author Closing Comment

by:breeze351
ID: 40361431
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

Featured Post

Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question