|
Posted by Jerry Stuckle on 02/10/07 14:09
zek2005 wrote:
> Hi !!
>
> Here is my problem. I can connect to data base through PHP (I receive
> a "Connection OK" message)
>
> <?php
> function Conectarse()
> {
> if (!($link=mysql_connect("localhost","myuser","mypass")))
> {
> echo "Error to connect to DB.";
> exit();
> }
> if (!mysql_select_db("users1",$link))
> {
> echo "Error selecting DB.";
> exit();
> }
> return $link;
> }
> $link=Conectarse();
> echo "Connection OK.<br>";
> mysql_close($link); //
> ?>
>
> Then I try to execute a simple select * query, but I dont receive
> results:
>
> <?php
> include("test.php"); // test.php refers to the file with the
> function above
> $link=Conectarse();
> $result=mysql_query("select * from usuarios",$link);
> while($row = mysql_fetch_array($result)) {
> printf($row["Nombre"],$row["Apellido"]);
> }
> mysql_free_result($result);
> mysql_close($link);
> ?>
>
> I also try other types of queries (update, as example), but it doesnt
> work
>
> Could it be a setting problem in my site?
>
> Thanks in advance for your answer.
>
> Ezequiel
>
What does mysql_error() say about it?
$result=mysql_query("select * from usuarios",$link);
if (!$result)
echo mysql_error();
else
while($row = mysql_fetch_array($result)) {
...
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
[Back to original message]
|