Solved

Need help converting mysql statement to mysqli statement

Posted on 2014-03-10
4
385 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
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…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

636 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