SV: [PHP-DB] I am new to PHP

2004-04-15 Thread Henrik Hornemann
Hi,

I would guess your problem is in the third file:

mysql_query( UPDATE books  SET isbn='$ud_isbn' ,title='$ud_title',
author='$ud_author',edition='$ud_edition',course_id='$ud_course_id',quan
tity = '$ud_quantity', stack_no = 
'$ud_stack_no' 
WHERE isbn='$ud_id');

The WHERE clause should probaly be id='$ud_id'

Otherwise try to elaborate on what happens.

Hth Henrik Hornemann

-Oprindelig meddelelse-
Fra: andy amol [mailto:[EMAIL PROTECTED] 
Sendt: 15. april 2004 06:18
Til: [EMAIL PROTECTED]
Emne: [PHP-DB] I am new to PHP


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.
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',quan
tity = '$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

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

Re: [PHP-DB] quotations in value field

2004-04-15 Thread Mikael Grön
On Apr 14, 2004, at 15:33, Ford, Mike [LSS] wrote:

On 14 April 2004 15:21, Mikael Grön wrote:

Well, I guess a combination of htmlspecialchars and some
other function
to convert it back, before it gets sent of in the _plain text mails_.
You don't need to convert it back -- that happens automatically when 
the
form is resubmitted.

Cheers!

Mike
Ofcourse it does! I knew that.. ;)

Thanks a bunch Mike!

Regards, Mikael G

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


[PHP-DB] New To PHP

2004-04-15 Thread Tom Cloyes
I ma trying to learn PHP and am having difficulty with understanding it. Is 
there a good PHP creator that will create PHP which will let me specify 
what all I need to have done so that I can go back and try to figure out 
just how it all fits together?
Thanks,

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


RE: [PHP-DB] New To PHP

2004-04-15 Thread Galbreath, Mark A
I found Lerdorf and Tatroe's Programming PHP (O'Reilly 2002) extremely
helpful in understanding the why of PHP.

Mark

-Original Message-
From: Tom Cloyes [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 15, 2004 7:54 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] New To PHP


I ma trying to learn PHP and am having difficulty with understanding it. Is 
there a good PHP creator that will create PHP which will let me specify 
what all I need to have done so that I can go back and try to figure out 
just how it all fits together?
Thanks,

Tom
KI8IZ
http://www.wooster-isp.net

-- 
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: [PHP-DB] New To PHP

2004-04-15 Thread Mikael Grön
What I did to learn PHP was to surf to http://www.hotscripts.com/ and 
look at other peoples code.
Writing it yourself looking at the hotscript codes also helps you 
understand the logic of it.

Mike

On Apr 15, 2004, at 12:53, Tom Cloyes wrote:

I ma trying to learn PHP and am having difficulty with understanding 
it. Is there a good PHP creator that will create PHP which will let me 
specify what all I need to have done so that I can go back and try to 
figure out just how it all fits together?
Thanks,

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


RE: [PHP-DB] New To PHP

2004-04-15 Thread Tom Cloyes
Mark,

Thanks for responding.

I have read the books:
PHP4 A Beginners Guide by McCarty from Osborne
Mastering PHP 4.1 by Allen and Hornberger from Sybex
and have poked around in PHP Cookbook by Sklar and Trachtenberg from O'Reilly
Also have read books on MySQL, and am left scratching my head.
Have found a couple of programs that look promising, and the first one I've 
tried - phpmaker - http://www.hkvstore.com/ - is a cookie-cutter type that 
really makes a lot of code. Will have to work with it to see if I can get 
it to do what I need it to do. Was wondering if any of you had experience 
with one of these or do you hand code everything. My client wants to go 
live in a month and the only thing left is the one database and the 
interaction with it, that and the integration with Xoops.

I will look into the book you recommended and continue to poke around. Any 
pointers will be gladly accepted.
Thanks,
T

At 08:11 AM 4/15/04 -0400, Galbreath, Mark A wrote:
I found Lerdorf and Tatroe's Programming PHP (O'Reilly 2002) extremely
helpful in understanding the why of PHP.
Mark

-Original Message-
From: Tom Cloyes [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 15, 2004 7:54 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] New To PHP
I ma trying to learn PHP and am having difficulty with understanding it. Is
there a good PHP creator that will create PHP which will let me specify
what all I need to have done so that I can go back and try to figure out
just how it all fits together?
Thanks,
Tom
KI8IZ
http://www.wooster-isp.net
--
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
Tom
KI8IZ
http://www.wooster-isp.net
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP-DB] New To PHP

2004-04-15 Thread Galbreath, Mark A
Nice resource!  Thanks for sharing!

Mark

-Original Message-
From: Mikael Grön [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 15, 2004 9:00 AM
To: Tom Cloyes; [EMAIL PROTECTED]
Subject: Re: [PHP-DB] New To PHP


What I did to learn PHP was to surf to http://www.hotscripts.com/ and 
look at other peoples code.
Writing it yourself looking at the hotscript codes also helps you 
understand the logic of it.

Mike

On Apr 15, 2004, at 12:53, Tom Cloyes wrote:

 I ma trying to learn PHP and am having difficulty with understanding 
 it. Is there a good PHP creator that will create PHP which will let me 
 specify what all I need to have done so that I can go back and try to 
 figure out just how it all fits together?
 Thanks,

 Tom
 KI8IZ
 http://www.wooster-isp.net

-- 
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: [PHP-DB] New To PHP

2004-04-15 Thread Tom Cloyes
Lisi,

Thank you for your reply, and I've bookmarked both sites as well as 
downloaded a few scripts that look promising. I've also found another 
creator that may just be what I'm looking for - dbquiksite 
-  http://www.dbqwiksite.com/.
Thanks again,
T

At 03:20 PM 4/15/04 +0200, [EMAIL PROTECTED] wrote:
Not sure about a creator but there are plenty of existing scripts
on the Net you can download and browse to see how they fit together.
You can install and run them, play around with the code, and
see the effects of your changes.
Try hotscripts.com/PHP/ or php.resourceindex.com to start with.

-Lisi

= = = Original message = = =

I ma trying to learn PHP and am having difficulty with understanding
it. Is
there a good PHP creator that will create PHP which will let
me specify
what all I need to have done so that I can go back and try to
figure out
just how it all fits together?
Thanks,
Tom
KI8IZ
http://www.wooster-isp.net
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.
Tom
KI8IZ
http://www.wooster-isp.net
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] Re: PHP OO Problem

2004-04-15 Thread Andre Matos
Thanks Justin,

I found the problem. I am using the OOP with sessions. The idea is use um
object and put it into the session and change it when is necessary. However,
instead of change the information in the object and then change the object
that is in the session, it is adding more information in the object. As a
result, my session has the size increased from 1 to 5, from 5 to 15, from
15 to 40, etc...

Is there any way to destroy the object in PHP?

Thanks.

Justin Patrin [EMAIL PROTECTED] escreveu na mensagem
news:[EMAIL PROTECTED]
 Andre Matos wrote:
  Hi List,
 
 
 
  Two months ago I developed a project using PHP and MySQL without
problem.
  Now, I am developing using PHP and MySQL, but using PHP Object Oriented.
 
 
 
  My problem is that the access is become slowly after few accesses or if
I
  perform a reload some times. The unique way to revert is to restart the
  Apache.
 
 
 
  Is anyone had this problem? Is this problem related to PHP OO or may
  something that I used in my programs?
 
 
 
  Thanks.
 
 
 
  Andre
 
  [EMAIL PROTECTED]

 Pretty much all of the larger PHP systems around are OO. PEAR is OO. If
 OO was the problem, it would have been fixed far before now. Likely
 you're using more resources inadvertently or not closing resources. Try
 checking specific functions to see if they're slowing you down. If you
 need more help, post some code and it will get looked at.

 -- 
 paperCrane Justin Patrin

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



Re: [PHP-DB] Re: PHP OO Problem

2004-04-15 Thread Chris Boget
 Is there any way to destroy the object in PHP?

http://us2.php.net/manual/en/function.unset.php

Chris

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



[PHP-DB] finding data

2004-04-15 Thread Hull, Douglas D
I am trying to find data, or if not found set a variable to Err.  myvalue being a 
variable in my database and $zchar being my value to find.

The following result is never 1 even if no values were found, so the result is always 
2.  If the finding value does exist in my database this does find the correct value:
if (!$result = mysql_query(SELECT * FROM bivalues WHERE myvalue = '$zchar'))
{
echo 'result 1 - not found';
$myresut = Err;
}
else
{
{echo 'result 2 - found it'
}

The following result is never 2 even if the value actually exist in my database, so 
the result is always 1:
if (!$result = mysql_query(SELECT * FROM bivalues WHERE myvalue = $zchar))
{
echo 'result 1 - not found';
$myresult = Err;
}
else
{
{echo 'result 2 - found it'
}

Thanks for any help,
Doug

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



[PHP-DB] Re: finding data

2004-04-15 Thread pete M
the way I would do this is with count()

$row = mysql_fetch_assoc(SELECT count(*) as c FROM bivalues WHERE 
myvalue = '$zchar')

if ($row['c']  0)
{
echo 'result 2 - found it'
}else{
echo 'NOT found'
}
hope it helps
Pete

Douglas D Hull wrote:

I am trying to find data, or if not found set a variable to Err.  myvalue being a variable in my database and $zchar being my value to find.

The following result is never 1 even if no values were found, so the result is always 
2.  If the finding value does exist in my database this does find the correct value:
if (!$result = mysql_query(SELECT * FROM bivalues WHERE myvalue = '$zchar'))
{
echo 'result 1 - not found';
$myresut = Err;
}
else
{
{echo 'result 2 - found it'
}
The following result is never 2 even if the value actually exist in my database, so 
the result is always 1:
if (!$result = mysql_query(SELECT * FROM bivalues WHERE myvalue = $zchar))
{
echo 'result 1 - not found';
$myresult = Err;
}
else
{
{echo 'result 2 - found it'
}
Thanks for any help,
Doug
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] Re: finding data

2004-04-15 Thread Mikael Grön
The way I would do it:

$result = mysql_query(select * from bivalues WHERE myvalue - '$zchar');
if (mysql_num_rows($result) {
echo Result 2 - found it;
} else {
echo Not found;
}
This leaves you with the option to start processing the data as soon as 
error checking is over. Using Count, you'll have to re-retrieve the 
data from the database, which takes twice as long time as doing it only 
once.. (or thereabout).

The problem you had is that no matter if the query presents results or 
not, the result variable is only set to 0 (thus the !$result syntax 
gives results) when there's been an error in the mysql query. Simply an 
empty table will not return an error!

Mike

On Apr 15, 2004, at 16:54, pete M wrote:

the way I would do this is with count()

$row = mysql_fetch_assoc(SELECT count(*) as c FROM bivalues WHERE 
myvalue = '$zchar')

if ($row['c']  0)
{
echo 'result 2 - found it'
}else{
echo 'NOT found'
}
hope it helps
Pete

Douglas D Hull wrote:

I am trying to find data, or if not found set a variable to Err.  
myvalue being a variable in my database and $zchar being my value to 
find.
The following result is never 1 even if no values were found, so the 
result is always 2.  If the finding value does exist in my database 
this does find the correct value:
if (!$result = mysql_query(SELECT * FROM bivalues WHERE myvalue = 
'$zchar'))
{
echo 'result 1 - not found';
$myresut = Err;
}
else
{
{echo 'result 2 - found it'
}
The following result is never 2 even if the value actually exist in 
my database, so the result is always 1:
if (!$result = mysql_query(SELECT * FROM bivalues WHERE myvalue = 
$zchar))
{
echo 'result 1 - not found';
$myresult = Err;
}
else
{
{echo 'result 2 - found it'
}
Thanks for any help,
Doug
--
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] FPDF Help

2004-04-15 Thread Nathan Mealey
Anyone who is familiar with using FPDF to generate PDFs, I'd really 
appreciate some suggestions here:

I am using the following code, virtually identical to that used in the 
FPDF tutorial examples.  But I keep getting a parse error for the first 
line containing the variable $this.  In the tutorial they do not 
declare this variable prior to using it the same way as in the example 
below, but when I try and do this, it's a no go.

Any ideas?  Suggestions?

the code
--
define('FPDF_FONTPATH','../../../font/');
require('../fpdf.php');
class PDF extends FPDF
{
function Header()
{
//Arial 12
$this-SetFont('Arial','',12);
//Move to the right
$this-Cell(80);
//Title
$this-Cell(30,10,'Title',1,0,'C');
//Line break
$this-Ln(20);
}
function Footer()
{
//Position at 1.5 cm from bottom
$this-SetY(-15);
//Arial italic 8
$this-SetFont('Arial','I',8);
//Page number
$this-Cell(0,10,'Page '.$this-PageNo().'/{nb}',0,0,'C');
}
$pdf=new PDF();
$pdf-AliasNbPages();
$pdf-AddPage();
$pdf-SetFont('Times','',12);
for($i=1;$i=40;$i++)
{
$pdf-Cell(0,10,'Printing line number '.$i,0,1);
}
$pdf-Output();
}





Nathan Mealey
Director of Operations
Cycle-Smart, Inc.
P.O. Box 1482
Northampton, MA
01061-1482
[EMAIL PROTECTED]
(413) 587-3133
(413) 210-7984 Mobile
(512) 681-7043 Fax
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] Problems switching from MySQL 3.23 - 4.0

2004-04-15 Thread ergeorge
Hi,
I have a page that grabs some data from a MySQL 3.23.58 database on a
RedHat 9 box.  I'm trying to migrate the db to a Suse box running MySQL 4.0.15.

When I connect to the MySQL 4.0 DB, I get strange results.  For example,
there's a certain query that just returns the number of records in one of
the tables:

$c = $db-getOne(SELECT count(*) FROM tle);

print($c);

Against the 3.23 DB, this works fine.  Against the 4.0 DB this prints out
Object.  Other queries return the same thing.

What gives??

Some more details:
Webserver Box:
RedHat 9
Apache 2.0.40
PHP 4.2.2
The MySQL 3.2.3 DB also runs on this box.  The MySQL 4.0 DB runs on a
seperate Suse box.

The Database structure  data is identical on both systems.

Ideas?
Thanks
Eric



-
This message was sent using Endymion MailMan.
http://www.endymion.com/products/mailman/

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



[PHP-DB] Date SELECT with IF

2004-04-15 Thread Shaun
Hi,

Is it possible to have a clause in a mysql SELECT statement? I would the
query to display the date except where it equals the default 000-00-00 to
display n/a or something similar.

For example SELECT DATE_FORMAT(B.Booking_End_Date, \%Y-%m-%d\) AS 'Booking
End Date' FROM Bookings (IF Booking_End_Date = '-00-00' DISPLAY 'n/a');

I hope this illustrates what I am trying to achieve!

Thanks for your help

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



Re: [PHP-DB] Date SELECT with IF

2004-04-15 Thread Ignatius Reilly
SELECT
IF( B.Booking_End_Date != -00-00,
DATE_FORMAT( B.Booking_End_Date, %Y-%m-%d ),
N/A
) AS Booking_End_Date
FROM Bookings AS B, etc.

HTH
Ignatius
_
- Original Message -
From: Shaun [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, April 15, 2004 7:44 PM
Subject: [PHP-DB] Date SELECT with IF


 Hi,

 Is it possible to have a clause in a mysql SELECT statement? I would the
 query to display the date except where it equals the default 000-00-00 to
 display n/a or something similar.

 For example SELECT DATE_FORMAT(B.Booking_End_Date, \%Y-%m-%d\) AS
'Booking
 End Date' FROM Bookings (IF Booking_End_Date = '-00-00' DISPLAY
'n/a');

 I hope this illustrates what I am trying to achieve!

 Thanks for your help

 --
 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: [PHP-DB] Date SELECT with IF

2004-04-15 Thread Marcjon Louwersheimer
try the WHERE clause.
SELECT name, address, phone, date FROM usertable WHERE date =
'-00-00'
And please, look at the mysql documentation, or at least the tutorial.
-- 
  Marcjon

-- 
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] Re: Hi I am new to PHP

2004-04-15 Thread Shaun
It means there is a problem with your query,

if you send the query back to the group someone may be able to help.


Andy Amol [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]

 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 Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] lamer noob question

2004-04-15 Thread Dan Bowkley
So I'm building this website; the first I've tried to build using a mostly dynamic 
structure.  What I've done is create a mysql table, with two fields: id and page_val.  
The idea is you call the page like http://www.someplace.com/page.php?id=404 and it'll 
spit back (in this case) the infamous 404 not found page.  I've got it so it'll spit 
back stuff from the DB, but only if I hard-code it...which defies the whole point of 
this exercise.

Here's what I've got thus far:


!DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
html
head
titleWelcome to boardlady.com!/title
link rel=stylesheet type=text/css href=styles.css
SCRIPT language=JavaScript1.2 src=main.jstype=text/javascript/SCRIPT
/head
body
DIV id=TipLayer 
style=visibility:hidden;position:absolute;z-index:1000;top:-100/DIV
SCRIPT language=JavaScript1.2 src=style.js type=text/javascript/SCRIPT
table width=750
trtd
table
trtdimg src=banner-1.gif alt=The Board Lady - Eva-M. Hollmann/tdtdOver 
b3,281/b Served!/td/tr
/table
tabletrtd class=sideboxa href=index.html 
onMouseOver=stm(Text[00],Style[12]) onMouseOut=htm()HOME/abrbrbra 
href=intro.html onMouseOver=stm(Text[01],Style[12]) 
onMouseOut=htm()INTRO/abrbrbra href=repairs.html 
onMouseOver=stm(Text[02],Style[12]) onMouseOut=htm()REPAIRS/abrbrbra 
href=prices.html onMouseOver=stm(Text[03],Style[12]) 
onMouseOut=htm()PRICES/abrbrbra href=faq.html 
onMouseOver=stm(Text[04],Style[12]) onMouseOut=htm()FAQ/abrbrbra 
href=trailer.html onMouseOver=stm(Text[05],Style[12]) 
onMouseOut=htm()TRAILER/abrbrbra href=contact.html 
onMouseOver=stm(Text[06],Style[12]) onMouseOut=htm()CONTACT ME/abrbrbra 
href=directions.html onMouseOver=stm(Text[07],Style[12]) 
onMouseOut=htm()DIRECTIONS/a/td
td valign=top
!--Begin main body text--
?php
define ('DB_USER', 'user');
define ('DB_PASSWORD', '');
define ('DB_HOST', 'localhost');
define ('DB_NAME', 'database');
$dbc = mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) OR die ('Could not connect to 
database: ' . mysql_error());
@mysql_select_db (DB_NAME) OR die ('Could not connect to database: ' . mysql_error());

if ($page_req == ) {$id=index;} 
elseif ($page_req == index) {$id=index;}
else { $id=404;}

$query = SELECT page_val FROM boardlady_site WHERE id =404;
$result = @mysql_query ($query);
while ($row = mysql_fetch_array($result)) {echo $row[0];}
mysql_close();
?
!--End main body text--
/td
/tr
trtd colspan=2centerdiv class=footer onMouseOver=stm(Text[08],Style[12]) 
onMouseOut=htm()This site a href=copyright.html style=color:#2f2f2f; 
font-size:xx-small;text-decoration:none;font-weight:bold; target=newcopyright 
(C)/a 2004 by Eva-M. Hollmann.  All rights reserved./divdiv 
class=footerbrWebsite design by Dan at a href=http://www.dibcomputers.com; 
style=color:#2f2f2f; font-size:xx-small;text-decoration:none;font-weight:bold; 
target=newDIB Computers./a/div/center/td/tr/table
/td/tr/table
/body
/html

First off, I need to know how to fetch variables out of the URL.  I know this is 
/supposed/ to be easy...but dammit I just can't get it to work.  The other part that's 
pissing me off is trying to stuff a variable inside my query variable...no matter what 
I try I get a syntax error.

Yeah, I'm that noob.  So were we all.

Thanks in advance,
Dan


[PHP-DB] Re: lamer noob question

2004-04-15 Thread Justin Patrin
Dan Bowkley wrote:

So I'm building this website; the first I've tried to build using a mostly dynamic structure.  What I've done is create a mysql table, with two fields: id and page_val.  The idea is you call the page like http://www.someplace.com/page.php?id=404 and it'll spit back (in this case) the infamous 404 not found page.  I've got it so it'll spit back stuff from the DB, but only if I hard-code it...which defies the whole point of this exercise.

Here's what I've got thus far:

!DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
html
head
titleWelcome to boardlady.com!/title
link rel=stylesheet type=text/css href=styles.css
SCRIPT language=JavaScript1.2 src=main.jstype=text/javascript/SCRIPT
/head
body
DIV id=TipLayer 
style=visibility:hidden;position:absolute;z-index:1000;top:-100/DIV
SCRIPT language=JavaScript1.2 src=style.js type=text/javascript/SCRIPT
table width=750
trtd
table
trtdimg src=banner-1.gif alt=The Board Lady - Eva-M. Hollmann/tdtdOver b3,281/b 
Served!/td/tr
/table
tabletrtd class=sideboxa href=index.html onMouseOver=stm(Text[00],Style[12]) onMouseOut=htm()HOME/abrbrbra href=intro.html onMouseOver=stm(Text[01],Style[12]) onMouseOut=htm()INTRO/abrbrbra href=repairs.html onMouseOver=stm(Text[02],Style[12]) onMouseOut=htm()REPAIRS/abrbrbra href=prices.html 
onMouseOver=stm(Text[03],Style[12]) onMouseOut=htm()PRICES/abrbrbra href=faq.html onMouseOver=stm(Text[04],Style[12]) onMouseOut=htm()FAQ/abrbrbra href=trailer.html onMouseOver=stm(Text[05],Style[12]) onMouseOut=htm()TRAILER/abrbrbra href=contact.html onMouseOver=stm(Text[06],Style[12]) onMouseOut=htm()CONTACT 
ME/abrbrbra href=directions.html onMouseOver=stm(Text[07],Style[12]) onMouseOut=htm()DIRECTIONS/a/td
td valign=top
!--Begin main body text--
?php
define ('DB_USER', 'user');
define ('DB_PASSWORD', '');
define ('DB_HOST', 'localhost');
define ('DB_NAME', 'database');
$dbc = mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) OR die ('Could not connect to 
database: ' . mysql_error());
@mysql_select_db (DB_NAME) OR die ('Could not connect to database: ' . mysql_error());
if ($page_req == ) {$id=index;} 
elseif ($page_req == index) {$id=index;}
else { $id=404;}

$query = SELECT page_val FROM boardlady_site WHERE id =404;
$result = @mysql_query ($query);
while ($row = mysql_fetch_array($result)) {echo $row[0];}
mysql_close();
?
!--End main body text--
/td
/tr
trtd colspan=2centerdiv class=footer onMouseOver=stm(Text[08],Style[12]) onMouseOut=htm()This site a href=copyright.html style=color:#2f2f2f; 
font-size:xx-small;text-decoration:none;font-weight:bold; target=newcopyright (C)/a 2004 by Eva-M. Hollmann.  All rights reserved./divdiv class=footerbrWebsite design by Dan at a 
href=http://www.dibcomputers.com; style=color:#2f2f2f; font-size:xx-small;text-decoration:none;font-weight:bold; target=newDIB Computers./a/div/center/td/tr/table
/td/tr/table
/body
/html
First off, I need to know how to fetch variables out of the URL.  I know this is /supposed/ to be easy...but dammit I just can't get it to work.  The other part that's pissing me off is trying to stuff a variable inside my query variable...no matter what I try I get a syntax error..

Yeah, I'm that noob.  So were we all.

Thanks in advance,
Dan
The query vars are in the $_GET, $_POST, and $_REQUEST superglobals. 
Look up superglobals on php.net to see what they are. Here's a modified 
DB query string for you:
$query = 'SELECT page_val FROM boardlady_site WHERE id ='.$_REQUEST['id'];

You will probably also want to change your $page_req vars up above.

This is all likely happening to you because register_globals is turned 
off for you in your php.ini. Believe me, this is a good thing. Use the 
superglobal arrays instead.

--
paperCrane Justin Patrin
--
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
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



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

2004-04-15 Thread David Robley
[EMAIL PROTECTED] (Andy Amol) wrote in
news:[EMAIL PROTECTED]: 

 
 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.

Your sql syntax is probably wrong. Somewhere before line 15 you are 
presumably using mysql_query to submit your query. Try adding to that line

or exit( 'Error: ' .mysql_error() );

which will halt your script and return a useful error string from mysql if 
there is an error.

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



[PHP-DB] Link to do query

2004-04-15 Thread JeRRy
Hi,

I have a Tipster Website that lists a Tipster Ladder. 
So it shows their name and their current score.  What
I want to do is make their name clickable and upon
clicking the name it loads that persons profile which
is fetched from the mysql db.

Now which would be the best way to do this?  I have
NEVER done a link query before but am familiar with
forms.  

Would I best best to have it something like this:

http://mydomain.com/profile.php?user=blah

And do a query that fetches the user=blah bit?

Or throw them in a form somehow?

I have to be honest, with a link with the url above I
am not familiar on how to grab the user=blah bit and
throw it into a query.  So a demo example would be
great so I can learn/add to it.

All suggestions, examples appreciated here.

Thanks!

J

Find local movie times and trailers on Yahoo! Movies.
http://au.movies.yahoo.com

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