Solved

Need help converting mysql statement to mysqli statement

Posted on 2014-03-10
4
363 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
  • 2
4 Comments
 
LVL 34

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 142

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 34

Expert Comment

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

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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.
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‚Ķ
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

706 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now