simple issue

simple issue

am 22.11.2006 06:07:36 von Chris Carter

Hi,

I am new to PHP, just trying a peace of code to access mySQL database to
fetch and show result on web page. But getting errors. Can you help me with
this code please. Or if you have a very basic code where in I can do some
insertion in the database.


--
View this message in context: http://www.nabble.com/simple-issue-tf2683559.html#a7485306
Sent from the Php - Database mailing list archive at Nabble.com.

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: simple issue

am 22.11.2006 06:13:17 von Chris

Chris Carter wrote:
> Hi,
>
> I am new to PHP, just trying a peace of code to access mySQL database to
> fetch and show result on web page. But getting errors. Can you help me with
> this code please. Or if you have a very basic code where in I can do some
> insertion in the database.

There are hundreds of mysql + php tutorials on the 'net - do a search in
your preferred search engine.

If you *still* can't work it out post a sample of the code you're trying
to use and the errors you get.

--
Postgresql & php tutorials
http://www.designmagick.com/

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: simple issue

am 22.11.2006 06:16:49 von John Comerford

You'll have to supply more information

a) code sample
b) error message



Chris Carter wrote:
> Hi,
>
> I am new to PHP, just trying a peace of code to access mySQL database to
> fetch and show result on web page. But getting errors. Can you help me with
> this code please. Or if you have a very basic code where in I can do some
> insertion in the database.
>
>
>

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: simple issue

am 22.11.2006 06:27:14 von Chris Carter

my code:




$username="chris";
$password="carter";
$database="chris_phpb1";

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM phpbb_banlist";
$result=mysql_query($query);

if (!$result)
{exit("Error in SQL");}
echo "

";
echo "";
echo "";
while (odbc_fetch_row($result))
{
$compname=odbc_result($result,"CompanyName");
$conname=odbc_result($result,"ContactName");
echo "";
echo "";
}
odbc_close($conn);
echo "
CompanynameContactname
$compname$conname
";
?>




My error:

Fatal error: Call to undefined function: odbc_fetch_row() in
/home/chandan/public_html/deb.php on line 19
Companyname Contactname

Also .. I am trying this live on cPanel compiler coz I could not install the
PHP thing on my localhost. I have apache-tomcat-5.5.17 which works perfectly
with jsp files but I do not understand what does it take to run a php using
apache.

chris smith-9 wrote:
>
> Chris Carter wrote:
>> Hi,
>>
>> I am new to PHP, just trying a peace of code to access mySQL database to
>> fetch and show result on web page. But getting errors. Can you help me
>> with
>> this code please. Or if you have a very basic code where in I can do some
>> insertion in the database.
>
> There are hundreds of mysql + php tutorials on the 'net - do a search in
> your preferred search engine.
>
> If you *still* can't work it out post a sample of the code you're trying
> to use and the errors you get.
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>

--
View this message in context: http://www.nabble.com/simple-issue-tf2683559.html#a7485434
Sent from the Php - Database mailing list archive at Nabble.com.

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: simple issue

am 22.11.2006 06:39:59 von Ankur Dave

Just chk your phpinfo() is odbc supprt is ebable in that. ??
If not need to enable odbc settings in that.=0D

-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-
@nkur d@ve || http://ullu.wordpress.com=0D
=0D

-----Original Message-----
From: Chris Carter [mailto:chandan9sharma@yahoo.com]=0D
Sent: Wednesday, November 22, 2006 10:57 AM
To: php-db@lists.php.net
Subject: Re: [PHP-DB] simple issue


my code:




$username=3D"chris";
$password=3D"carter";
$database=3D"chris_phpb1";

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query=3D"SELECT * FROM phpbb_banlist";
$result=3Dmysql_query($query);

if (!$result)
{exit("Error in SQL");}
echo "

";
echo "";
echo "";
while (odbc_fetch_row($result))
{
$compname=3Dodbc_result($result,"CompanyName");
$conname=3Dodbc_result($result,"ContactName");
echo "";
echo "";
}
odbc_close($conn);
echo "
CompanynameContactname
$compname$conname
";
?>




My error:

Fatal error: Call to undefined function: odbc_fetch_row() in
/home/chandan/public_html/deb.php on line 19
Companyname Contactname

Also .. I am trying this live on cPanel compiler coz I could not install
the
PHP thing on my localhost. I have apache-tomcat-5.5.17 which works
perfectly
with jsp files but I do not understand what does it take to run a php
using
apache.

chris smith-9 wrote:
>=0D
> Chris Carter wrote:
>> Hi,
>>=0D
>> I am new to PHP, just trying a peace of code to access mySQL database
to
>> fetch and show result on web page. But getting errors. Can you help
me
>> with
>> this code please. Or if you have a very basic code where in I can do
some
>> insertion in the database.
>=0D
> There are hundreds of mysql + php tutorials on the 'net - do a search
in=0D
> your preferred search engine.
>=0D
> If you *still* can't work it out post a sample of the code you're
trying=0D
> to use and the errors you get.
>=0D
> --=0D
> Postgresql & php tutorials
> http://www.designmagick.com/
>=0D
> --=0D
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>=0D
>=0D
>=0D

--=0D
View this message in context:
http://www.nabble.com/simple-issue-tf2683559.html#a7485434
Sent from the Php - Database mailing list archive at Nabble.com.

--=0D
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



The information contained in, or attached to, this e-mail, contains=
confidential information and is intended solely for the use of the=
individual or entity to whom they are addressed and is subject to legal=
privilege. If you have received this e-mail in error you should notify the=
sender immediately by reply e-mail, delete the message from your system=
and notify your system manager. Please do not copy it for any purpose, or=
disclose its contents to any other person. The views or opinions presented=
in this e-mail are solely those of the author and do not necessarily=
represent those of the company. The recipient should check this e-mail and=
any attachments for the presence of viruses. The company accepts no=
liability for any damage caused, directly or indirectly, by any virus=
transmitted in this email.

www.aztecsoft.com

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: simple issue

am 22.11.2006 06:54:14 von John Comerford

--------------050806090301010208090206
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

I'm pretty new to this stuff myself but try this:

while ($row = $result->fetch_array())
{
$compname=$row["CompanyName"];
$conname=$row["ContactName"];
echo "$compname";
echo "$conname";
}




Chris Carter wrote:
> my code:
>
>
>
>
> > $username="chris";
> $password="carter";
> $database="chris_phpb1";
>
> mysql_connect(localhost,$username,$password);
> @mysql_select_db($database) or die( "Unable to select database");
> $query="SELECT * FROM phpbb_banlist";
> $result=mysql_query($query);
>
> if (!$result)
> {exit("Error in SQL");}
> echo "

";
> echo "";
> echo "";
> while (odbc_fetch_row($result))
> {
> $compname=odbc_result($result,"CompanyName");
> $conname=odbc_result($result,"ContactName");
> echo "";
> echo "";
> }
> odbc_close($conn);
> echo "
CompanynameContactname
$compname$conname
";
> ?>
>
>
>
>
> My error:
>
> Fatal error: Call to undefined function: odbc_fetch_row() in
> /home/chandan/public_html/deb.php on line 19
> Companyname Contactname
>
> Also .. I am trying this live on cPanel compiler coz I could not install the
> PHP thing on my localhost. I have apache-tomcat-5.5.17 which works perfectly
> with jsp files but I do not understand what does it take to run a php using
> apache.
>
> chris smith-9 wrote:
>
>> Chris Carter wrote:
>>
>>> Hi,
>>>
>>> I am new to PHP, just trying a peace of code to access mySQL database to
>>> fetch and show result on web page. But getting errors. Can you help me
>>> with
>>> this code please. Or if you have a very basic code where in I can do some
>>> insertion in the database.
>>>
>> There are hundreds of mysql + php tutorials on the 'net - do a search in
>> your preferred search engine.
>>
>> If you *still* can't work it out post a sample of the code you're trying
>> to use and the errors you get.
>>
>> --
>> Postgresql & php tutorials
>> http://www.designmagick.com/
>>
>> --
>> PHP Database Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>>
>>
>
>


--------------050806090301010208090206--

Re: simple issue

am 22.11.2006 07:10:57 von Chris

Chris Carter wrote:
> my code:
>
>
>
>
> > $username="chris";
> $password="carter";
> $database="chris_phpb1";
>
> mysql_connect(localhost,$username,$password);
> @mysql_select_db($database) or die( "Unable to select database");
> $query="SELECT * FROM phpbb_banlist";
> $result=mysql_query($query);
>
> if (!$result)
> {exit("Error in SQL");}
> echo "

";
> echo "";
> echo "";
> while (odbc_fetch_row($result))
> {
> $compname=odbc_result($result,"CompanyName");
> $conname=odbc_result($result,"ContactName");
> echo "";
> echo "";
> }


Connecting using mysql_connect and then using odbc_fetch_row won't work
- they are completely separate interfaces (apart from odbc not being
supported on your server).

Try

while ($row = mysql_fetch_assoc($result)) {
$compname = $row['CompanyName'];
}

See http://www.php.net/mysql_fetch_assoc for more info.

--
Postgresql & php tutorials
http://www.designmagick.com/

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: simple issue

am 22.11.2006 07:47:56 von Chris

John Comerford wrote:
> I'm pretty new to this stuff myself but try this:
>
> while ($row = $result->fetch_array())
> {
> $compname=$row["CompanyName"];
> $conname=$row["ContactName"];
> echo "

";
> echo "";
> }

$result from mysql_query doesn't return an object, so that won't work -
if he was using mysqli_query it might have worked.

mysql_query and mysqli_query are different interfaces again to mysql and
odbc.

--
Postgresql & php tutorials
http://www.designmagick.com/


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: simple issue

am 22.11.2006 08:13:34 von jeffreyb

You should be aware the the PHP-DB archives are openly available on the
web and searchable. Assuming you have listed your actual username,
password, etc, you should immediately go to your web site and change
your password. If possible change also your username and database name.
Do it now.

It would not be an overly demanding task for a hacker to find your web
site and once she does, she has free access to your database.

And in future, when sharing code on PHP-DB, which is a must if you want
the expert help people here can provide, always leave out or change the
MySQL log in info.

Good luck,

Jeffrey


Chris Carter wrote:
> my code:
>
>
>
>
> > $username="chris";
> $password="carter";
> $database="chris_phpb1";
>
> mysql_connect(localhost,$username,$password);
> @mysql_select_db($database) or die( "Unable to select database");
> $query="SELECT * FROM phpbb_banlist";
> $result=mysql_query($query);
>
> if (!$result)
> {exit("Error in SQL");}
> echo "

CompanynameContactname
$compname$conname
$compname$conname
";
> echo "";
> echo "";
> while (odbc_fetch_row($result))
> {
> $compname=odbc_result($result,"CompanyName");
> $conname=odbc_result($result,"ContactName");
> echo "";
> echo "";
> }
> odbc_close($conn);
> echo "
CompanynameContactname
$compname$conname
";
> ?>
>
>
>
>
> My error:
>
> Fatal error: Call to undefined function: odbc_fetch_row() in
> /home/chandan/public_html/deb.php on line 19
> Companyname Contactname
>
> Also .. I am trying this live on cPanel compiler coz I could not install the
> PHP thing on my localhost. I have apache-tomcat-5.5.17 which works perfectly
> with jsp files but I do not understand what does it take to run a php using
> apache.
>
> chris smith-9 wrote:
>
>>Chris Carter wrote:
>>
>>>Hi,
>>>
>>>I am new to PHP, just trying a peace of code to access mySQL database to
>>>fetch and show result on web page. But getting errors. Can you help me
>>>with
>>>this code please. Or if you have a very basic code where in I can do some
>>>insertion in the database.
>>
>>There are hundreds of mysql + php tutorials on the 'net - do a search in
>>your preferred search engine.
>>
>>If you *still* can't work it out post a sample of the code you're trying
>>to use and the errors you get.
>>
>>--
>>Postgresql & php tutorials
>>http://www.designmagick.com/
>>
>>--
>>PHP Database Mailing List (http://www.php.net/)
>>To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>>
>
>

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: simple issue

am 22.11.2006 09:54:31 von Chris Carter

Thanks Jeff,

As I mentioned, this is just a sample code with username password db name
all changed. Thanks for your advice coz I never knew the php db archive is
searchable.


Jeffrey-2 wrote:
>
> You should be aware the the PHP-DB archives are openly available on the
> web and searchable. Assuming you have listed your actual username,
> password, etc, you should immediately go to your web site and change
> your password. If possible change also your username and database name.
> Do it now.
>
> It would not be an overly demanding task for a hacker to find your web
> site and once she does, she has free access to your database.
>
> And in future, when sharing code on PHP-DB, which is a must if you want
> the expert help people here can provide, always leave out or change the
> MySQL log in info.
>
> Good luck,
>
> Jeffrey
>
>
> Chris Carter wrote:
>> my code:
>>
>>
>>
>>
>> >> $username="chris";
>> $password="carter";
>> $database="chris_phpb1";
>>
>> mysql_connect(localhost,$username,$password);
>> @mysql_select_db($database) or die( "Unable to select database");
>> $query="SELECT * FROM phpbb_banlist";
>> $result=mysql_query($query);
>>
>> if (!$result)
>> {exit("Error in SQL");}
>> echo "

";
>> echo "";
>> echo "";
>> while (odbc_fetch_row($result))
>> {
>> $compname=odbc_result($result,"CompanyName");
>> $conname=odbc_result($result,"ContactName");
>> echo "";
>> echo "";
>> }
>> odbc_close($conn);
>> echo "
CompanynameContactname
$compname$conname
";
>> ?>
>>
>>
>>
>>
>> My error:
>>
>> Fatal error: Call to undefined function: odbc_fetch_row() in
>> /home/chandan/public_html/deb.php on line 19
>> Companyname Contactname
>>
>> Also .. I am trying this live on cPanel compiler coz I could not install
>> the
>> PHP thing on my localhost. I have apache-tomcat-5.5.17 which works
>> perfectly
>> with jsp files but I do not understand what does it take to run a php
>> using
>> apache.
>>
>> chris smith-9 wrote:
>>
>>>Chris Carter wrote:
>>>
>>>>Hi,
>>>>
>>>>I am new to PHP, just trying a peace of code to access mySQL database to
>>>>fetch and show result on web page. But getting errors. Can you help me
>>>>with
>>>>this code please. Or if you have a very basic code where in I can do
some
>>>>insertion in the database.
>>>
>>>There are hundreds of mysql + php tutorials on the 'net - do a search in
>>>your preferred search engine.
>>>
>>>If you *still* can't work it out post a sample of the code you're trying
>>>to use and the errors you get.
>>>
>>>--
>>>Postgresql & php tutorials
>>>http://www.designmagick.com/
>>>
>>>--
>>>PHP Database Mailing List (http://www.php.net/)
>>>To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>>>
>>
>>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>

--
View this message in context: http://www.nabble.com/simple-issue-tf2683559.html#a7487209
Sent from the Php - Database mailing list archive at Nabble.com.

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php