MySQL/PHP

2001-09-05 Thread Chakravarthy K Sannedhi

Hello all,

I am trying to integrate the mysql with php. As I am using the Red Hat
7.0, I know that they come pre-installed and pre-configured. When i
created test.php with the ?php phpinfo() ? line, the page shows that
the php is able to recognize the presense of mysql. I created a small
table 'namelist' in a database named 'newone'. I am trying to read the
table through a php file. Here is the simple php page that i have
created for this purpose.

  html
  head
  titleName List/title
  /head
  body
  ?php
  $db=mysql_connect (localhost,myname,mypassword);
  mysql_select_db (newone,$db);
  $result = mysql_query (select * from namelist);
  printf (First Name: %sbr\n, mysql_result($result,
  0, firstname));
  printf (Last Name: %sbr\n, mysql_result($result,
  0, lastname));
  ?
  /body
  /html

It is producing the following bunch of errors.

Warning: MySQL Connection Failed: Can't connect to local MySQL server
through socket '/var/lib/mysql/mysql.sock' (111) in   
/var/www/html/namelist.php on line 7

Warning: Supplied argument is not a valid MySQL-Link resource in
/var/www/html/namelist.php on line 8

Warning: MySQL Connection Failed: Can't connect to local MySQL server
through socket '/var/lib/mysql/mysql.sock' (111) in
/var/www/html/namelist.php on line 9

Warning: MySQL: A link to the server could not be established in
/var/www/html/namelist.php on line 9

Warning: Supplied argument is not a valid MySQL result resource in
/var/www/html/namelist.php on line 10
First Name: 

Warning: Supplied argument is not a valid MySQL result resource in
/var/www/html/namelist.php on line 11
Last Name: 

Can any one tell me what causing it to generate these errors.

TIA

Chakravarthy Sannedhi
http://www.dpo.uab.edu/~kalyan

__
Do You Yahoo!?
Get email alerts  NEW webcam video instant messaging with Yahoo! Messenger
http://im.yahoo.com

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: MySQL/PHP

2001-09-05 Thread Chakravarthy K Sannedhi


--- Steve Suehring [EMAIL PROTECTED] wrote:
 
 hmm.  Are you sure that MySQL is running?  Conversely, does the file 
 /var/lib/mysql/mysql.sock exist?
 
 Steve


The mysql server is running and the mysql.sock file exists. Also I am
able to connect to the mysql database by any of the following ways.

mysql -u myname -p mypassword
mysql -u myname -p mypassword -h localhost

But when I try to connect in the following way, it says 'ERROR 1130:
Host 'the.host.name' is not allowed to connect to this MySQL server

mysql -u myname -p mypassword -h the.host.name

That is the reason I specified 'localhost' in the PHP file.

Still the following php file produces those bunch of errors that I
specified earlier.

html
head
titleName List/title
/head
body
?php
$db=mysql_connect (localhost,myname,mypassword);
mysql_select_db (newone,$db);
$result = mysql_query (select * from namelist);
printf (First Name: %sbr\n, mysql_result($result,
0, firstname));
printf (Last Name: %sbr\n, mysql_result($result,
0, lastname));
?
/body
/html

When I changed the file as below 

html
head
titleName List/title
/head
body
?php
mysql_connect (localhost,myname,mypassword);
$database=newone;
@mysql_select_db (database) or die (Unable to connect to the
database);
$result = mysql_query (select * from namelist);
printf (First Name: %sbr\n, mysql_result($result, 0, firstname));
printf (Last Name: %sbr\n, mysql_result($result, 0, lastname));
?
/body
/html

For which it gives the following error:

Warning: MySQL Connection Failed: Can't connect to local MySQL server
through socket '/var/lib/mysql/mysql.sock' (111) in
/var/www/html/namelist.php on line 7
Unable to connect to the database

Thanks

Chakravarthy Sannedhi

__
Do You Yahoo!?
Get email alerts  NEW webcam video instant messaging with Yahoo! Messenger
http://im.yahoo.com

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




how to import a text file into the mysql database

2001-08-28 Thread Chakravarthy K Sannedhi

hello all,

i am trying to install web calendar software on my machine, which is
available at sourceforge.net website. to run that software first of all
a textfile named tables-mysql.sql needs to imported into the mysql
database. for doing that i typed the following command at the shell
prompt

shell # mysqlimport -u root -p webcalendar tables-mysql.sql

where, 'webcalendar' is the database that i have created for this
purpose. after entering the password at the password prompt it is
displaying the following error:

mysqlimport: Error: You have an error in your SQL syntax near
'tables-mysql' at line 1, when using table: tables-mysql

how can i avoid this error?

TIA

=
Chakravarthy K Sannedhi
Research Assistant, CTER, UAB
Birmingham, AL-35205
Ph: (205) 821-6805 (M)
http://www.dpo.uab.edu/~kalyan

__
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




if ... else ...

2001-01-25 Thread Chakravarthy K Sannedhi

Hi all,

I am having 5 rows in a mysql database related to five
different users. these rows contains their firstname,
lastname and details of scenes 1 to 5(these details
are numeric values from 1 to 3). if any of these
fields from scenes 1 to 5 are empty that will be
detected from the firstname of the user(collected from
a form with a filed name 'fname') by opening the
database and will be indicated to that user from which
scene he got empty fields. here is the code that i
wrote works like a champ.

$db = mysql_connect ("localhost","myname","password")
or die("bUnable to connect to database./b");
mysql_select_db ("nimitztest",$db) or die("bUnable
to select database./b");
$result = mysql_query ("select * from mytable order by
id",$db);
if ($row=mysql_fetch_array($result))
{
while ($row=mysql_fetch_array($result))
{
$FirstName = $row["firstname"];
if ($fname == $FirstName) 
{
for ($i=1; $i=5; $i++)
  {
  $Num[$i] = $row["num$i"];
  if ($Num[$i] == '') {
  printf ("You have to goto Scene$ip"); 
  break;
   }
  } 
}
}
}

But when i include the else statement like below, to
indicate an user with all the fields filled up as 'You
don't have any thing to fill', this code is giving
weird results such as printing like this onto the
screen:

You don't have anything to fill
You have to goto Scene2
You have to goto Scene3
You have to goto Scene4
You have to goto Scene5

for a user with scene2 onwards empty fields.
This may be, because of fault in my code or because of
misinterpretation of the mysql functions by me. 

-
for ($i=1; $i=5; $i++)
{
  $Num[$i] = $row["num$i"];
  if ($Num[$i] == '') {
  printf ("You have to goto Scene$ip");
  }
  else {
  printf ("You don't have anything to fillp");
  }
}
--

Please correct me about the mistake i am making over
above.

TIA
Chakravarthy K Sannedhi



__
Do You Yahoo!?
Yahoo! Auctions - Buy the things you want at great prices. 
http://auctions.yahoo.com/

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




altering the table

2001-01-18 Thread Chakravarthy K Sannedhi

I am having a table of 60 rows of data with userid as
the primary key. I want to start the new data entry
with the userid '1' instead of from '61' now, how can
i do that with out dropping the table and its content
altogether.

TIA
Chakravarthy K Sannedhi

__
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail. 
http://personal.mail.yahoo.com/

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php