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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Dynamic Table mySQL stored procedure 5 61
MySQL HA and DR solution. 5 36
object method as an event handler 8 72
how can I see the time difference in only seconds? 4 38
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

738 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