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

Link to comment
Share on other sites

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?

 

 

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.