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

Posted by zek2005 on 02/10/07 15:52

On 10 feb, 16:34, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> zek2005 wrote:
> > On 10 feb, 15:09, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> >> 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.
> >> jstuck...@attglobal.net
> >> ==================- Ocultar texto de la cita -
>
> >> - Mostrar texto de la cita -
>
> > mysql_error Returns the text of the error message from previous MySQL
> > operation
>
> > Any help?
>
> > REgards!
>
> > Ezequiel
>
> Not at all.
>
> I know what it does. That's why I asked the question. But what's the
> error message you get?
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================- Ocultar texto de la cita -
>
> - Mostrar texto de la cita -


Sorry Jeey for the misunderstanding. I added the mysql_error and I
only get the "Connection OK" message from the function, but I don't
receive the result of the select (the table "usuarios" has 4 rows)

I'm going crazy!!!!!

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

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