Page 1 of 1

[SOLVED] database problem

Posted: Tue Apr 19, 2005 12:54 pm
by arong
hi, I hope someone can help me with this,
I have installed php 5, Sql server and apache all well configured.

I´m new to php programing, so now i´m only trying to connect
to a database, extract files from it and display them.

I have made a simple script to do that but the IE returns nothing,
it displays a blank page, not even an error, all is well configured
and I have tested that.

this is my script:

Code: Select all

<?php
$myServer = "06-sistemas";
$myUser = "sa";
$myPass = "password";
$myDB = "nueva";

$s = mssql_connect($myServer, $myUser, $myPass)
or die("Couldn't connect to SQL Server on $myServer");

$d = mssql_select_db($myDB, $s)
or die("Couldn't open database $myDB");

$query = "select * from tabla1";
      $result = mssql_query($query);

while($tmp = mssql_fetch_array($result)) {

              print $tpm["nombre"];
              print "<br>";
              print $tpm["edad"];
              print "<br>";

                   }
      mssql_close($s);

?>
thanks in advanced
Arong


feyd | Please review how to post code using

Code: Select all

and

Code: Select all

tags. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Posted: Tue Apr 19, 2005 1:50 pm
by feyd
check your php.ini to make sure error_reporting is set to E_ALL only, and display_errors is on.

Next, if the sql server is on the web server, try using 'localhost'

Posted: Tue Apr 19, 2005 2:45 pm
by arong
Thanks for your replay,

It does not appear any error after doing that, however I realised that
It does extract the data from the database, it is there, but it is invisible
I don´t know why.

I realised that because I added this: (echo ¨hi¨;) at the end of the script
and It appeared at the middle of the page, then I added more data to the database and the hi text appeared but down.

I changed the color of the page but without luck.

any idea
arong

Posted: Tue Apr 19, 2005 2:53 pm
by vigge89
arong wrote:Thanks for your replay,

It does not appear any error after doing that, however I realised that
It does extract the data from the database, it is there, but it is invisible
I don´t know why.

I realised that because I added this: (echo ¨hi¨;) at the end of the script
and It appeared at the middle of the page, then I added more data to the database and the hi text appeared but down.

I changed the color of the page but without luck.

any idea
arong
the $tpm['edad'] and $tpm['nombre'] variables are probably empty, or non-existant. Check your table structure and contents, you mayb be missing something ;)

Posted: Tue Apr 19, 2005 2:53 pm
by feyd
you have any other code on this script/page? It likely means you got something goofy in your output page code.. or you are accidentally writing this stuff into an "invisible" div or similar.

Posted: Tue Apr 19, 2005 4:00 pm
by arong
thanks again for your replays, I´m still stuck.

the whole code is that I already posted,

I´ll keep looking the couse of the error on the web , I have almost proved everything.

Arong

Posted: Tue Apr 19, 2005 4:04 pm
by feyd
did you notice that $tpm is not $tmp ? :P

You don't have error_reporting turned on to E_ALL.. :)

Posted: Wed Apr 20, 2005 6:50 am
by arong
:roll:

thank you, everything is working fine now, that stupid mistake almost killed me.

:) :) :) :)

I know I´ll have more questions cause Im new to php.
Arong