You are here: Can Connect, Can´t execute queries « PHP Programming Language « IT news, forums, messages
Can Connect, Can´t execute queries

Posted by zek2005 on 02/10/07 11:32

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация