Jump to content

PHP and MYSQL problems


englishcodemonkey

Recommended Posts

Ok so I’m now using MySQL 5.0 and I have now managed to connect to the MySQL database. I have trouble-shooted two errors and now the page is showing but it is blank http://www.wadeandgattonnurseries.com/hosta_new.html is the URL.  Once you click the ‘submit my information’ button it should show the information that is pulled from the database.  The code for this page is displayed below:

 

<?php

require_once('conn.php');

$hosta= $_REQUEST['name'];

$hosta1= $_REQUEST['name'];

$q = "SELECT hybridizer, size, price, description from hostajess where hosta_name='$hosta'";

$r = @mysqli_query ($magic, $q);

if ($r) {

echo '<table align="center" cellspacing="3" cellpadding="3" width="75%">

<tr><td align="left" width="33.3%"><b>Hybridizer</b></td><td align="left" width="33.3%"><b>Size</b></td><td align="left" ><b>Price</b></td></tr>';

while ($row = mysqli_fetch_array($r,MYSQLI_ASSOC)) {

echo '<tr><td align="left">' .$row['hybridizer'] . '</td><td align="left">' .$row['size'] . '</td><td align="left">' .$row['price']. '</td></tr>';

}

}

echo '</table>';

$q = "SELECT description from hostajess where hosta_name='$hosta1'";

$r = @mysqli_query ($magic, $q);

if ($r) {

echo '<table align="center" cellspacing="3" cellpadding="3" width="75%">

<tr><td align="left"><b>Description</b></td></tr>';

while ($row = mysqli_fetch_array($r,MYSQLI_ASSOC)) {

echo '<tr><td align="justify">' .$row['description'] . '</tr>';

}

}

echo '</table>';

mysqli_close($dbc);

?>

 

Link to comment
Share on other sites

You probably have a syntax error...I'm guessing in conn.php, as the code you have posted seems fine...it would help if you cleaned up your code:

<?php
require_once('conn.php');

$hosta = $_REQUEST['name'];
$hosta1 = $_REQUEST['name'];

$q = "SELECT hybridizer, size, price, description from hostajess where hosta_name='$hosta'";
$r = @mysqli_query ($magic, $q) or die(mysqli_error());

if ($r) {
echo '
	<table align="center" cellspacing="3" cellpadding="3" width="75%">
		<tr>
			<td align="left" width="33.3%">Hybridizer</td>
			<td align="left" width="33.3%">Size</td>
			<td align="left" >Price</td>
		</tr>';

while ($row = mysqli_fetch_array($r,MYSQLI_ASSOC)) {
	echo '
		<tr>
			<td align="left">' .$row['hybridizer'] . '</td>
			<td align="left">' .$row['size'] . '</td>
			<td align="left">' .$row['price']. '</td>
		</tr>';
}
}

echo '</table>';

$q = "SELECT description from hostajess where hosta_name='$hosta1'";
$r = mysqli_query ($magic, $q) or die(mysqli_query());

if ($r) {
echo '
	<table align="center" cellspacing="3" cellpadding="3" width="75%">
		<tr>
			<td align="left">Description</td>
		</tr>';

while ($row = mysqli_fetch_array($r,MYSQLI_ASSOC)) {
	echo '
		<tr>
			<td align="justify">' .$row['description'] . '</td>
		</tr>';
}
}

echo '</table>';

mysqli_close($dbc);

?>

Link to comment
Share on other sites

Ok this is the code from the conn.php file, as far as I know this part was working. I am still having problems though. Thanks.

 

<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>

<?php

$dbc = mysqli_connect ('p50mysql187.secureserver.net', 'hostajess', '***');

$magic = mysqli_select_db($dbc, 'hostajess');

?>


</body>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.