|
Posted by Jerry Stuckle on 02/10/07 15:34
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.
jstucklex@attglobal.net
==================
Navigation:
[Reply to this message]
|