• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 400
  • Last Modified:

Need help converting mysql statement to mysqli statement

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
Ken Graser
Asked:
Ken Graser
  • 2
1 Solution
 
Dan CraciunIT ConsultantCommented:
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
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
I confirm the above.
you may want to read up the technical reference pages for such kind of questions:
php.net/mysqli_query
0
 
Ken GraserIT ManagerAuthor Commented:
Thanks Dan,

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

Ken
0
 
Dan CraciunIT ConsultantCommented:
Glad I could help!
0

Featured Post

Industry Leaders: 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!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now