5 Replies - 464 Views - Last Post: 14 October 2012 - 10:47 PM Rate Topic: -----

#1 DoxramosPS  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 174
  • Joined: 07-October 12

MySQLI not allowing website to display.

Posted 14 October 2012 - 10:53 AM

After my Mysqli call the remainder of my webpage is not showing.
   $db = new mysqli($host, $user, $pass, $dbname);
	if(mysqli_connect_errno())
{
    die('The connection to the database could not be established.');
}	
$query = 'SELECT * FROM pages where name="Index"';
$result = $db->query($query);
$total_results = $result->num_rows;
while ($row = $result->fetch_object())
{				
				echo '<title>';
	            echo $row->title;
				echo '</title>';
            }
				$result->free();
?>

I'm not sure how to describe it other than that, so attached are 2000 words.
With MySQLIAttached Image
Without MySQLIAttached Image
Thanks for any help.

Is This A Good Question/Topic? 0
  • +

Replies To: MySQLI not allowing website to display.

#2 CTphpnwb  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 2988
  • Posts: 10,326
  • Joined: 08-August 08

Re: MySQLI not allowing website to display.

Posted 14 October 2012 - 11:05 AM

Check your error log.
$row should be an array, not an object.
http://www.php.net/m...fetch-array.php
Was This Post Helpful? 1
  • +
  • -

#3 DoxramosPS  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 174
  • Joined: 07-October 12

Re: MySQLI not allowing website to display.

Posted 14 October 2012 - 01:44 PM

Any idea why this doesn't work?
<?php
$link = mysqli_connect("$server", "$user", "$pass", "$webdb");

if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}

$query = "SELECT title FROM pages WHERE name='Index'";
$result = mysqli_query($link, $query);

$row = mysqli_fetch_array($result, MYSQLI_ASSOC);
echo '<title>';
printf ("%s (%s)\n", $row["title"]);
echo '</title>';

mysqli_free_result($result);

mysqli_close($link);
?>

The end goal is to have the title pulled from the database which I was able to succeed with mysql connections, but having issues with mysqli doing the same thing.
Also; I echoed the query and the row['title'] without the html inside and it is pulling the info and performing the query successfully.

This post has been edited by DoxramosPS: 14 October 2012 - 01:48 PM

Was This Post Helpful? 0
  • +
  • -

#4 CTphpnwb  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 2988
  • Posts: 10,326
  • Joined: 08-August 08

Re: MySQLI not allowing website to display.

Posted 14 October 2012 - 03:33 PM

Why is printf set to print two strings when you only have one?
Was This Post Helpful? 0
  • +
  • -

#5 DoxramosPS  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 174
  • Joined: 07-October 12

Re: MySQLI not allowing website to display.

Posted 14 October 2012 - 03:49 PM

That's because I screwed it up when looking through. It's resolved now where I used a simple echo rather then a printf
Was This Post Helpful? 0
  • +
  • -

#6 Dormilich  Icon User is online

  • 痛覚残留
  • member icon

Reputation: 3541
  • View blog
  • Posts: 10,235
  • Joined: 08-June 10

Re: MySQLI not allowing website to display.

Posted 14 October 2012 - 10:47 PM

tip: var_dump() can output any datatype for debugging.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1