Solved

SQL statement not working

Posted on 2007-03-18
7
173 Views
Last Modified: 2008-02-01
Is the $_GET statement typed wrong here?

$SQLstr = mysql_query("SELECT strProviderservice, strCompanyname, strOwner, strAddress, strTown, strZipcode, strPhone, str2ndphone, strMobile, strPager, strFax, strEmail, strWebsite, strlicense, strInsured, strBonded, strHours, str24houremerg, strOtherservices, strServicearea, strInbusiness_since, strServicesoffered, strFreeestimate, strWorkguaranteed, strProvidertagline, strAd_size, strImage FROM tblAdspace WHERE providerID = " $_GET["providerID"]
or die("SQL statement is not working");
0
Comment
Question by:pingeyeg
  • 3
  • 2
  • 2
7 Comments
 
LVL 27

Assisted Solution

by:yodercm
yodercm earned 300 total points
ID: 18744787
NEVER EVER use a form input directly in a query!!  It's wide open to SQL Injection hacking.



$providerID = $_GET["providerID"];

Then

$SQLstr = mysql_query("SELECT strProviderservice, strCompanyname, strOwner, strAddress, strTown, strZipcode, strPhone, str2ndphone, strMobile, strPager, strFax, strEmail, strWebsite, strlicense, strInsured, strBonded, strHours, str24houremerg, strOtherservices, strServicearea, strInbusiness_since, strServicesoffered, strFreeestimate, strWorkguaranteed, strProvidertagline, strAd_size, strImage FROM tblAdspace WHERE providerID = mysql_real_escape_string($providerID")
or die("SQL statement is not working");
0
 
LVL 27

Assisted Solution

by:yodercm
yodercm earned 300 total points
ID: 18744793
Oops, missing )....

$SQLstr = mysql_query("SELECT strProviderservice, strCompanyname, strOwner, strAddress, strTown, strZipcode, strPhone, str2ndphone, strMobile, strPager, strFax, strEmail, strWebsite, strlicense, strInsured, strBonded, strHours, str24houremerg, strOtherservices, strServicearea, strInbusiness_since, strServicesoffered, strFreeestimate, strWorkguaranteed, strProvidertagline, strAd_size, strImage FROM tblAdspace WHERE providerID = mysql_real_escape_string($providerID)")
or die("SQL statement is not working");
0
 
LVL 1

Author Comment

by:pingeyeg
ID: 18744805
Ok, right now I am getting the "SQL statement is not working" string.
0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
LVL 1

Author Comment

by:pingeyeg
ID: 18744821
When using mysql_error() I get FUNCTION providers.mysql_real_escape_string does not exist
0
 
LVL 50

Accepted Solution

by:
Steve Bink earned 200 total points
ID: 18744880
$query = "SELECT strProviderservice, strCompanyname, strOwner, strAddress, strTown, strZipcode, strPhone, str2ndphone, strMobile, strPager, strFax, strEmail, strWebsite, strlicense, strInsured, strBonded, strHours, str24houremerg, strOtherservices, strServicearea, strInbusiness_since, strServicesoffered, strFreeestimate, strWorkguaranteed, strProvidertagline, strAd_size, strImage FROM tblAdspace WHERE providerID = " . mysql_real_escape_string($providerID);
$result = mysql_query($query) or die("SQL statement is not working");
0
 
LVL 1

Author Comment

by:pingeyeg
ID: 18744896
Is that just another way of writing the sql query?  Putting the mysql_query at the bottom?
0
 
LVL 50

Expert Comment

by:Steve Bink
ID: 18761288
Just better organization for readability.  The problem in the statement was a combo of quotes and parenthesis.  
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
mysql between clause 2 24
hosting images 4 29
google map tracking website 5 24
Logic behind "best rated" calculation 11 22
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
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 …

778 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