HELP!! PHP can't connect to MySql database!
Posted by: Monica (---.ambra.ro)
Date: February 20, 2006 11:36AM

Hy! I'm using Wamp server, it's great, but I have a big problem: my SQL database exists, I can see it with PHPMyadmin or with any other mysql manager (with the same user and no password, as you can see bellow), I don't have password on it, the data is OK, but....the PHP code can't connect to this database. There's no error messege, the browser prints the PHP code, without connecting to my database! Please, can anyoane help me?? Nearby I send my code:

<a href="posta.html"> Inapoi la pagina principala </a>
<br><br>
<?
mysql_pconnect("localhost","root",""winking smiley;
mysql_select_db("posta"winking smiley;
$sql="select * from firme ORDER BY cod asc";
$resursa=mysql_query($sql);
print "<table border='1'>";
while ($row=mysql_fetch_array($resursa))
{print "<tr>
<td> ".$row['cod']." </td>
<td> ".$row['numefirma']." </td>
<td> ".$row['telefon']." </td>
<td> ".$row['str']." </td>
<td> ".$row['nr']." </td>
<td> ".$row['bloc']." </td>
<td> ".$row['sc']." </td>
<td> ".$row['et']." </td>
<td> ".$row['ap']." </td>
<td> ".$row['codp']." </td>
<td> ".$row['loc']." </td>
<td> ".$row['jud']." </td>
</tr>";}
print "</table>";
?>
<br><br>
<a href="posta.html"> Inapoi la pagina principala </a>

If I run this script in browser, the answer is:

<td> ".$row['cod']." </td>
<td> ".$row['numefirma']." </td>
<td> ".$row['telefon']." </td>
<td> ".$row['str']." </td>
<td> ".$row['nr']." </td>
<td> ".$row['bloc']." </td>
<td> ".$row['sc']." </td>
<td> ".$row['et']." </td>
<td> ".$row['ap']." </td>
<td> ".$row['codp']." </td>
<td> ".$row['loc']." </td>
<td> ".$row['jud']." </td>
</tr>";}
print "</table>";
?>

What's wrong?? Please, help!! Thanks, Monica

Options: ReplyQuote
Re: HELP!! PHP can't connect to MySql database!
Posted by: Stan (---.adsl.versatel.nl)
Date: February 20, 2006 01:20PM

Are you sure PHP is on? Because when you're browser displays the PHP code, that means that you're WAMP Server isn't translating the PHP code. Click (LeftMouseButton) on the WAMP icon in your tray, and choose --> START all services

It should work now winking smiley

Good luck,

Stan


Options: ReplyQuote
Re: HELP!! PHP can't connect to MySql database!
Posted by: CyberSpatium (---.hsd1.or.comcast.net)
Date: February 21, 2006 04:29AM

php not a server, it is a scripting language. you can not turn php on or off.

Monica, the php code you just posted uses what is called 'ASP style tags'. you need to use full php tags.

change the very first line of your script from:

<?

to:

<?php

Options: ReplyQuote


Sorry, only registered users may post in this forum.