MySQL / PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sama
Forum Newbie
Posts: 4
Joined: Wed Aug 11, 2004 1:29 pm

MySQL / PHP

Post by sama »

I am running php and MySQL. If I run MySQL at cmd command prompt or through windows explorer, it works, I can create database, tables, insert data, etc. Here no problem, it works.

But when I am running the following code, just to make sure I am connected to the database, it does not work. When I run the following code, no error messages or not even 'success' message. Blank white
screen pops up. Even I refreshed id. Same.

Also, when I run phpInfo(), it works fine. Shows all the info.
Can anybody help me to fix this please.
I am running Windows 2000, IIS.


<?
$connection = @mysql_connect("d2rsyc11","myUN","myPW") or die(mysql_error());
if ($connection) {
$msg = "success!";
}
?>
<? echo "$msg"; ?>
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

Remove the @.

That supresses error messages.
sama
Forum Newbie
Posts: 4
Joined: Wed Aug 11, 2004 1:29 pm

Post by sama »

Sami, I did what you said.
now this error message,
Fatal error: Call to undefined function mysql_connect() in c:\Inetpub\wwwroot\php5code\db_connect.php on line 4

line #4 = $connection = mysql_connect("d2rsyc11.","un","pw");
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

Run this:

Code: Select all

<?php
phpinfo();
?>
What does it say about MySQL?
sama
Forum Newbie
Posts: 4
Joined: Wed Aug 11, 2004 1:29 pm

Post by sama »

Thank you for your time, the following is the result of
your latest code. Please help. Thank you again.

Array
(
[0] => bcmath
[1] => calendar
[2] => com_dotnet
[3] => ctype
[4] => ftp
[5] => iconv
[6] => libxml
[7] => odbc
[8] => pcre
[9] => session
[10] => SPL
[11] => SQLite
[12] => standard
[13] => tokenizer
[14] => zlib
[15] => dom
[16] => SimpleXML
[17] => wddx
[18] => xml
)
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

Sorry I changed the script. ;)

MySQL is built-in so it won't show up on the extension list.

Run phpinfo() and tell me what it says about MySQL.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

looks to me like he's running php5, in which case, mysql isn't built-in.
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

Yep. Just what I was thinking could be the problem...
sama
Forum Newbie
Posts: 4
Joined: Wed Aug 11, 2004 1:29 pm

Post by sama »

This is the heading,

PHP Version 5.0.0
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

Have a read of this article: http://www.raditha.com/mysql/mysqli.php

If you use Windows, check out: http://forums.devshed.com/archive/t-160413
Post Reply