[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

please help me to convert old style php to something great  to mysqli or PDO

Posted on 2015-02-10
5
Medium Priority
?
240 Views
Last Modified: 2015-02-11
$link = new mysqli("localhost","root","","portfolio");
if ($link->connect_errno)  die("Error " . $link->connect_errno );

$link->query("SET NAMES 'utf8'");


 
$id= $_GET['id'];
$query = "SELECT `id`, `$tl` as 'info' FROM image WHERE id ='$id'";
    $result = mysql_query($query) or die('Erreur de la requête infos : ' . $query);

while ($row = mysql_fetch_assoc($result)) {
echo $row["info"];

}

Open in new window

0
Comment
Question by:jerrrrry
[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
5 Comments
 
LVL 31

Expert Comment

by:Marco Gasi
ID: 40602684
$id= $_GET['id'];
$query = "SELECT `id`, `$tl` as 'info' FROM image WHERE id ='$id'";
$result = mysqli_query($conn,$query) or die(mysqli_error($conn));
while ($row = $result->fetch_assoc()) {
   echo $row['info'];
}
$result->free();

Open in new window

Cheers
0
 

Author Comment

by:jerrrrry
ID: 40602702
ok i changed $conn to $link
then i have this warning Warning: mysql_fetch_assoc() expects parameter 1 to be resource, object given in C:\wamp\www\test-ajax2.php on line 18

?
thanks
0
 
LVL 31

Accepted Solution

by:
Marco Gasi earned 2000 total points
ID: 40602709
? we are using $result->fetch_assoc() and do you get an error about mysql_fetch_assoc()? Mmmhh, can you post the whole script?
0
 

Author Comment

by:jerrrrry
ID: 40602835
my apologize i made a mistake and let a part of the old script!
0
 

Author Closing Comment

by:jerrrrry
ID: 40602837
thanks
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

650 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