Jump to content

Archived

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

aaronlzw_21

php can't connect to mysql

Recommended Posts

hi i need help. the codes i written to connect to a database (MySQL) can't be executed. i'm not sure y. this is my codes. i did a echo 'testing'; juz before "@ $db= mysql_pconnect("localhost", "root","password");" it shows out "testing". however, if i do a echo 'testing'; after "@ $db= mysql_pconnect("localhost", "root","password");" it doesn't show anything. it appears that the codes are not executed after that line. am i coding anything wrongly? please correct me.. thanks alot..


<table width="80%" border="0" align="center" cellpadding="2" cellspacing="0">
<tr>
<td width="40%"><div align="right"><strong>Site:</strong></div></td>
<td width="60%"><strong>
<?php

@ $db= mysql_pconnect("localhost", "root","password");
if (!$db){
echo 'Error: unable to connect to database. Please try again later.';
exit;

}
mysql_select_db('psarecords');
$query= "select site from tblsite";
$result= mysql_query($query);
$num_results = mysql_num_rows($result);

echo '<select name="ListSite" id="ListSite">';
echo "<option>--------</option>";
for ($i=0; $i <$num_results; $i++)
{
$row=mysql_fetch_array($result);
echo '<option>'& $row['site'] & '</option>';
}
echo '</select>';
?>
</strong></td>


oh ya by the way, i'm running apache and mySQL 5. thanks alot!

Share this post


Link to post
Share on other sites
If you're working with Dreamweaver, why don't you just use the Dreamweaver features to recreate that connection and data?

Share this post


Link to post
Share on other sites
[!--quoteo(post=370515:date=May 2 2006, 07:11 PM:name=moberemk)--][div class=\'quotetop\']QUOTE(moberemk @ May 2 2006, 07:11 PM) [snapback]370515[/snapback][/div][div class=\'quotemain\'][!--quotec--]
If you're working with Dreamweaver, why don't you just use the Dreamweaver features to recreate that connection and data?
[/quote]




ya i've tried doin that.. it keeps saying error. don't know wats wrong wif it.. my mysql works fine. somehow the php codes can't connect to it..

Share this post


Link to post
Share on other sites

×

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.