Solved

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

Posted on 2015-02-10
5
230 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
  • 3
  • 2
5 Comments
 
LVL 30

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 30

Accepted Solution

by:
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?
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
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 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…

744 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now