[PHP-DB] // FW Water_foul AW: [PHP-DB] Hi I am new

2004-04-27 Thread Shahed, Raja
This is a very easy and clear tutorial.The basic of PHP/DB you can learn here.

http://hotwired.lycos.com/webmonkey/programming/php/tutorials/tutorial4.html

Best Regards
Raja shahed



-Ursprüngliche Nachricht-
Von: water_foul [mailto:[EMAIL PROTECTED] 
Gesendet: Samstag, 24. April 2004 05:06
An: [EMAIL PROTECTED]
Betreff: [PHP-DB] Hi I am new


I am new to databases and php and I was wondering if any one 
would point me
to a good guide
anything would help :)
thanks in advance,
water_foul

-- 
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



[PHP-DB] Hi I am new

2004-04-23 Thread water_foul
I am new to databases and php and I was wondering if any one would point me
to a good guide
anything would help :)
thanks in advance,
water_foul

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



[PHP-DB] Hi I am new to PHP

2004-04-15 Thread andy amol

I have posted my problem at No: 33892 of this mailing list. I have received 1 reply. 
No: 33897

My exact problem with second file is as follows:

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource on 
line 15


Can you help me to solve problem, any help would be appreciated.

Thanks.



-
Do you Yahoo!?
Yahoo! Tax Center - File online by April 15th

[PHP-DB] Hi I am new to PHP

2004-04-15 Thread andy amol
Hi,
I have a problem with the second file. I am not able to update the 
data from the php program. Any help on that would be appreciated. 
Any modification which would be reduce the code like directly using the 
Update command would be appreciated.
thanks in advance.
 
My exact problem with second file is as follows:

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource on 
line 15


Here are the 3 files.

File1
---
htmlheadtitleBook Update Form/title/head
body
?
$db=project;
$link = mysql_connect(localhost,name,passwd);
if (! $link)
die(Couldn't connect to MySQL);
mysql_select_db($db , $link)
or die(Couldn't open $db: .mysql_error());
$result = mysql_query( SELECT * FROM books )
or die(SELECT Error: .mysql_error());
$num_rows = mysql_num_rows($result);
print There are $num_rows records.P;
print table width=800 border=1\n;
while ($get_info = mysql_fetch_row($result)){ 
print tr\n;
foreach ($get_info as $field) 
print \ttdfont face=arial size=2/$field/font/td\n;
print /tr\n;
}
print /table\n;
mysql_close($link);
//form method=POST action=book_change_form.php
?
br
form method=POST action=book_change_form.php
pre
Enter ISBN Number to Edit: input type=text name=id size=10
input type=submit value=Submitinput type=reset
/pre
/form
/body
/html

File 2
-
htmlheadtitleBook change form/title/head
body
?
$id=$_POST['id'];
$db=project;
//mysql_connect(localhost,$_POST['username'],$_POST['pass']);
$link = mysql_connect(localhost,name,passwd);
if (! $link)
die(Couldn't connect to MySQL);
mysql_select_db($db , $link)
or die(Couldn't open $db: .mysql_error());
$query= SELECT * FROM books WHERE id='$id';
$result=mysql_query($query);
$num=mysql_num_rows($result);
//echo $num;
$i=0;
while ($i  $num)
{ 
$isbn=mysql_result($result,$i,isbn);
$title=mysql_result($result,$i,title);
$author=mysql_result($result,$i,author);
$edition=mysql_result($result,$i,edition);
$course_id=mysql_result($result,$i,course);
$quantity=mysql_result($result,$i,quantity);
$stack_no=mysql_result($result,$i,stack_no);
?
table width=300 cellpadding=10 cellspacing=0 border=2
tr align=center valign=top
td align=center colspan=1 rowspan=1 bgcolor=#64b1ff
h3Edit and Submit/h3
form action=book_change_record.php method=post
input type=hidden name=username value=?php print 
$_POST['username']?
input type=hidden name=pass value=?php print $_POST['pass']?
input type=hidden name=ud_id value=? echo $id ?
ISBN:input type=text name=ud_isbn value=? print 
$isbn?br
Title:   input type=text name=ud_title value=? print 
$title?br
Author:  input type=text name=ud_author value=? print 
$author?br
Edition: input type=text name=ud_edition value=? print 
$edition?br
Course Id:   input type=text name=ud_course_id value=? print 
$course_id?br
Quantity:input type=text name=ud_quantity value=? print 
$quantity?br
Stack Number:input type=text name=ud_stack_no value=? echo 
$stack_no?br
input type=Submit value=Update
/form
/td/tr/table
?
++$i;
}//end while
?
/body
/html
//
File 3

htmlheadtitleBook Change Record/title/head
body
?
$user=$_POST['username'];
$password=$_POST['password'];
$ud_id=$_POST['ud_id'];
$ud_isbn=$_POST['ud_isbn'];
$ud_title=$_POST['ud_title'];
$ud_author=$_POST['ud_author'];
$ud_edition=$_POST['ud_edition'];
$ud_course_id=$_POST['ud_course_id'];
$ud_quantity=$_POST['ud_quantity'];
$ud_stack_no=$_POST['ud_stack_no'];
$db=project;
$link = mysql_connect(localhost,name,passwd);
if (! $link)
die(Couldn't connect to MySQL);
mysql_select_db($db , $link)
or die(Couldn't open $db: .mysql_error());
mysql_query( UPDATE books  SET isbn='$ud_isbn' ,title='$ud_title',
   
author='$ud_author',edition='$ud_edition',course_id='$ud_course_id',   
quantity = '$ud_quantity', stack_no = 
'$ud_stack_no' 
WHERE isbn='$ud_id');
echo Record Updated;
mysql_close($link);
?
form method=POST action=book_update_form.php
input type=hidden name=username value=?php print 
$_POST['username']?
input type=hidden name=pass value=?php print 
$_POST['password']?
input type=submit value=Change Another
/formbr
form method=POST action=book.php
input type=hidden name=username value=?php print 
$_POST['username']?
input type=hidden name=pass value=?php print 
$_POST['password']?
input type=submit value=Book Interface
/form
/body
/html




-
Do you Yahoo!?
Yahoo! Tax Center - File online by April 15th

Re: [PHP-DB] Hi I am new to PHP

2004-04-15 Thread George Patterson
On Thu, 15 Apr 2004 14:58:09 -0700 (PDT)
andy amol [EMAIL PROTECTED] wrote:

 Hi,
I have a problem with the second file. I am not able to update the 
 data from the php program. Any help on that would be appreciated. 
 Any modification which would be reduce the code like directly using
 the Update command would be appreciated.

 thanks in advance.
  
 My exact problem with second file is as follows:
 
 Warning: mysql_num_rows(): supplied argument is not a valid MySQL
 result resource on line 15

Andy, 
This is probably not the entire error message. The above error message would have 
shown the name of the php script that is broken. This would have made it easier for 
whoever
 
 
 Here are the 3 files.
 
 File1
Looks okay...

 
 File 2
 -
 htmlheadtitleBook change form/title/head
 body
 ?
 $id=$_POST['id'];
 $db=project;
 //mysql_connect(localhost,$_POST['username'],$_POST['pass']);
 $link = mysql_connect(localhost,name,passwd);
 if (! $link)
 die(Couldn't connect to MySQL);

A better way to write this is 
 $link = mysql_connect(localhost,name,passwd) 
or die(Couldn't connect to MySQL);

 mysql_select_db($db , $link)
 or die(Couldn't open $db: .mysql_error());
 $query= SELECT * FROM books WHERE id='$id';
 $result=mysql_query($query);
 $num=mysql_num_rows($result);
 //echo $num;
 $i=0;
 while ($i  $num)
 { 

This could be rewritten as
while ($row = mysql_fetch_assoc($result);) {
The reason wil soon become apparent.

Okay, using mysql_result() functions calls is expensive as far as resources go.

 $isbn=mysql_result($result,$i,isbn);
Each of these lines change into similar to the following example line
echo $row[isbn];

 $title=mysql_result($result,$i,title);
echo $row[title];
 $author=mysql_result($result,$i,author);
echo $row[author];
 $edition=mysql_result($result,$i,edition);
echo $row[edition];
 $course_id=mysql_result($result,$i,course);
echo $row[course];
 $quantity=mysql_result($result,$i,quantity);
echo $row[quantity];
 $stack_no=mysql_result($result,$i,stack_no);
echo $row[stack_no];

The reason for doing this is that each call to mysql_result() requires PHP to ask the 
MySQL server for the cell specified. Even if your web server and MySQL server is on 
the same machine, you will still notice a speed increase if you do just one fetch per 
row rather than a fetch per field in the row. You would use mysql_result() if you are 
wanting only one cell from a query result. 

Otherwise this the rest of the looks pretty good.

 ?
 /body
 /html
 //
 File 3
 
 htmlheadtitleBook Change Record/title/head
 body
 ?
 $user=$_POST['username'];
 $password=$_POST['password'];
Move this line up to the other database connection values.

The rest of the file looks okay...

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