Jump to content


Photo

php can't connect to mysql


  • Please log in to reply
2 replies to this topic

#1 aaronlzw_21

aaronlzw_21
  • Members
  • PipPip
  • Member
  • 19 posts

Posted 02 May 2006 - 08:57 AM

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!

#2 moberemk

moberemk
  • Members
  • PipPipPip
  • Advanced Member
  • 695 posts

Posted 02 May 2006 - 11:11 AM

If you're working with Dreamweaver, why don't you just use the Dreamweaver features to recreate that connection and data?
Disclaimer: No matter how harsh I may be, I'm always IMO only.

#3 aaronlzw_21

aaronlzw_21
  • Members
  • PipPip
  • Member
  • 19 posts

Posted 02 May 2006 - 02:51 PM

[!--quoteo(post=370515:date=May 2 2006, 07:11 PM:name=moberemk)--][div class=\'quotetop\']QUOTE(moberemk @ May 2 2006, 07:11 PM) View Post[/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..




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users