Solved

SQL statement not working

Posted on 2007-03-18
7
176 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
[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
  • 3
  • 2
  • 2
7 Comments
 
LVL 27

Assisted Solution

by:Cornelia Yoder
Cornelia Yoder 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:Cornelia Yoder
Cornelia Yoder 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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 51

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 51

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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

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…
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…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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 …

623 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