LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-16-2014, 03:05 PM   #1
pr0xibus
Member
 
Registered: Apr 2004
Location: Scotland
Distribution: Slackware
Posts: 215

Rep: Reputation: 44
PHP / MySQLI display results


Evening,

So from the previous code which was wrong since ts all changed too mysqli the code i have now is

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
PHP Code:
<?php // CONNECT TO THE DATABASE     $DB_NAME '*****';     $DB_HOST '192.168.1.1';     $DB_USER '*******';     $DB_PASS '*******';          $mysqli = new mysqli($DB_HOST$DB_USER$DB_PASS$DB_NAME);              if (mysqli_connect_errno()) {         printf("Connect failed: %s\n"mysqli_connect_error());         exit();     } ?>
<head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body>
PHP Code:
<?php // Query DATABASE $query =  "SELECT * FROM  `mfdtble` WHERE `Asset Tag` LIKE 'ADMN-033054'"; $result $mysqli->query($query) or die($mysqli->error.__LINE__); // Display Query     while($row $result->fetch_assoc()){     echo $row[0] . '<br />';      } ?>
PHP Code:
<?php echo 'Total results: ' $result->num_rows; ?>
</body> </html>
now i have no experience with this but i cannot see the row on page, although i can see the total result as 1. can anyone help with this
 
Old 06-17-2014, 04:23 AM   #2
j-ray
Senior Member
 
Registered: Jan 2002
Location: germany
Distribution: ubuntu, mint, suse
Posts: 1,591

Rep: Reputation: 145Reputation: 145
$row[0] is not set. You fetch the result as an associative array so you have to replace the [0] with [correspondingKeys], means with the column names.
 
Old 06-17-2014, 02:27 PM   #3
pr0xibus
Member
 
Registered: Apr 2004
Location: Scotland
Distribution: Slackware
Posts: 215

Original Poster
Rep: Reputation: 44
thank you very much
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help me to disable mysqli in php kaviajan Linux - Server 1 09-25-2012 04:46 AM
PHP - mysqli_connect doesn't exist but mysqli is enabled? Splenden Linux - Server 2 04-23-2012 10:39 PM
php mysqli::connection must stay in scope? sogenant Programming 2 07-10-2008 08:57 PM
Php and MySQL Whats this New stuff (Mysqli)? helptonewbie Linux - Newbie 5 04-04-2008 10:59 AM
apache 2.0 + PHP 5 + mysql AND mysqli? nyttoc Linux - Server 1 05-08-2007 08:28 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:10 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration