Solved

Need help converting mysql statement to mysqli statement

Posted on 2014-03-10
4
378 Views
Last Modified: 2014-03-10
Our web server has just been updated to use PHP 5.8.  When this happened we started getting warning messages about mysql be depreciated and we should use mysqli.  I was able to get my database connector converted but I ran into another problem.

There is a routine on our sites with calculates the county sales tax on orders.  This was written by a third party who is not around any more.  Therefore I'm trying to modify his program and I have run into a problem.

I need to know how to rewrite this query:
$query = mysql_query($sSQL);

If I just change mysql to mysqli, I get an error message "mysqli_query() expects at least 2 parameters, 1 given".

I'm not sure what the other parameter should be.  

Any assistance would be appreciated.

Thanks
Ken
0
Comment
Question by:Kenbg
[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
  • 2
4 Comments
 
LVL 35

Accepted Solution

by:
Dan Craciun earned 500 total points
ID: 39917515
The first parameter is the connection.

$con=mysqli_connect("myhost","myuser","mypassw","mybd") or die("Error " . mysqli_error($link));
$query = mysqli_query($con, $sSQL);

Open in new window


HTH,
Dan
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 39917523
I confirm the above.
you may want to read up the technical reference pages for such kind of questions:
php.net/mysqli_query
0
 

Author Closing Comment

by:Kenbg
ID: 39917588
Thanks Dan,

That is exactly what I needed.  Considering that I don't know mysql, you saved me a lot of time.

Ken
0
 
LVL 35

Expert Comment

by:Dan Craciun
ID: 39917623
Glad I could help!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
Determining the an SCCM package name from the Package ID
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

738 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