Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 246
  • Last Modified:

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

$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
jerrrrry
Asked:
jerrrrry
  • 3
  • 2
1 Solution
 
Marco GasiFreelancerCommented:
$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
 
jerrrrryAuthor Commented:
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
 
Marco GasiFreelancerCommented:
? we are using $result->fetch_assoc() and do you get an error about mysql_fetch_assoc()? Mmmhh, can you post the whole script?
0
 
jerrrrryAuthor Commented:
my apologize i made a mistake and let a part of the old script!
0
 
jerrrrryAuthor Commented:
thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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