Jump to content

Simple MySQL Question...


blufish

Recommended Posts

I know you are all really good at MySQL so can you tell me why this is not working?

 

<?php
$database_connect = mysql_connect("sql204.byethost7.com","--","--");
if (!$database_connect) {
die('Error Connecting to Database: ' . mysql_error());
}
else {
echo "Succesfully Connected to Database!";
}

$page_query = mysql_query("SELECT * FROM page_info");
while($page_values = mysql_fetch_array($page_query))
{
echo $page_values['page_title'] . " " . $page_values['page_name'];
echo "<br />";
}
mysql_close($database_connect);
?>

 

I'm sures its a simple question, but could you please explain what I have to do to fix this because I am new to MySQL.

 

Thanks,

Mark Swingle

 

Link to comment
https://forums.phpfreaks.com/topic/137323-simple-mysql-question/
Share on other sites

'is not working' is not enough information.

 

Change

$page_query = mysql_query("SELECT * FROM page_info");

 

to

 

$page_query = mysql_query("SELECT * FROM page_info") or die(mysql_error());

 

This will show information about any mysql errors you might have.

Okay, I am currently using this code:

<?php
$database_connect = mysql_connect

("sql204.byethost7.com","--3","--");
if (!$database_connect) {
die('Error Connecting to Database: ' . mysql_error());
}
else {
echo "Succesfully Connected to Database!";
}

$select_database = mysql_select_db("b7_2627673_pages", 

$database_connect);
if (!select_database)
{
die ("Error Selecting Database: " . mysql_error());
}
else {
echo "Database Succesfully Selected!";
}

$page_query = mysql_query("SELECT * FROM page_info") or die

(mysql_error());
while($page_values = mysql_fetch_array($page_query))
{
echo $page_values['page_title'] . " " . $page_values['page_name'];
echo "<br />";
}
mysql_close($database_connect);
?>

 

And Getting This Response:

Succesfully Connected to Database!Database Succesfully Selected! <br /> <br />

 

I Should Be Getting This Response:

Succesfully Connected to Database!Database Succesfully Selected! Page 1 pg1.htm<br /> Page 2 pg2.htm<br />

 

Any Ideas?

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.