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

Posted on 2015-02-10
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

Question by:jerrrrry
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
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'];

Open in new window


Author Comment

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

LVL 31

Accepted Solution

Marco Gasi earned 500 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?

Author Comment

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

Author Closing Comment

ID: 40602837

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

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.
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 the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

717 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