[PHP-DB] Help in tokenizing a string

2002-01-31 Thread George Lioumis

Good day to all.

I tried the following code from PHP's manual

 if (isset($submit))
 {
  if ($submit == "Save")
  {
  echo "$im_file";
  $tok = strtok($im_file, "\\");
  while ($tok)
  {
  echo "$tok";
  $tok = strtok ("\\");
  }
  }
 }

I have the string $im_file ="C:image.jpg" and I want to have
into a variable (say it $im) just the filename part (image.jpg).
The code above, returns me just a "C:" :((

Any suggestions greatly appreciated.


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] More Date operations.

2002-01-31 Thread Beau Lebens

you have changed the command from when you do it in mysql to when you do it
in php - you are leaving out the "'" quote marks around the date you are
passing :)

//   $sql="SELECT TO_DAYS(2001-01-01) AS bar";
should be
//   $sql="SELECT TO_DAYS('2001-01-01') AS bar";

HTH

beau


// -Original Message-
// From: Garry Optland [mailto:[EMAIL PROTECTED]]
// Sent: Friday, 1 February 2002 2:12 PM
// To: [EMAIL PROTECTED]
// Subject: [PHP-DB] More Date operations.
// 
// 
// Hi,
// 
// I am trying to access the MySQL function TO_DAYS() from PHP.
// 
// From MySQL I can type in: SELECT TO_DAYS('2000-1-1') AS bar;
// 
// and I get:
// 
// ++
// | bar|
// ++
// | 730485 |
// ++
// 1 row in set (0.00 sec)
// 
// From PHP, I have tried:
// 
//   $sql="SELECT TO_DAYS(2001-01-01) AS bar";
//   $result=mysql_query($sql) or die("Could not access database");
//   $days=mysql_fetch_array($result);
//   echo "days: ".$days["bar"]."";
// 
// But I don't get the result coming through.
// 
// I have tried mysql_field_name and the name comes across as "bar".
// 
// mysql_num_rows shows that there is one row in the result. 
// 
// Am I missing something really really obvious? 
// 
// Regards,
// Garry.
// 
// 
// 
// -- 
// PHP Database Mailing List (http://www.php.net/)
// To unsubscribe, e-mail: [EMAIL PROTECTED]
// For additional commands, e-mail: [EMAIL PROTECTED]
// To contact the list administrators, e-mail: 
// [EMAIL PROTECTED]
// 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] More Date operations.

2002-01-31 Thread Garry Optland

Hi,

I am trying to access the MySQL function TO_DAYS() from PHP.

>From MySQL I can type in: SELECT TO_DAYS('2000-1-1') AS bar;

and I get:

++
| bar|
++
| 730485 |
++
1 row in set (0.00 sec)

>From PHP, I have tried:

  $sql="SELECT TO_DAYS(2001-01-01) AS bar";
  $result=mysql_query($sql) or die("Could not access database");
  $days=mysql_fetch_array($result);
  echo "days: ".$days["bar"]."";

But I don't get the result coming through.

I have tried mysql_field_name and the name comes across as "bar".

mysql_num_rows shows that there is one row in the result. 

Am I missing something really really obvious? 

Regards,
Garry.



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Re: MSSQL Query - Unicode data in a Unicode-only collation or ntext data cannot be sent

2002-01-31 Thread William Fong

Yeah, I create a simple table with simple char data type.  Works great.

No, sorry, I don't know T-SQL.  I've just started using MSSQL.  I've only
used MySQL, and even that was using very simple queries.  Once I have a
better understanding of MSSQL, I will probably pick up the T-SQL book.

Thanks.

will


--
William Fong - [EMAIL PROTECTED]
Phone: 626.968.6424 x210  |  Fax: 626.968.6877
Wireless #: 805.490.7732|  Wireless E-mail: [EMAIL PROTECTED]




- Original Message -
From: "Oliver Cronk" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; "Php-Db ML" <[EMAIL PROTECTED]>
Sent: Thursday, January 31, 2002 6:49 PM
Subject: Re: [PHP-DB] Re: MSSQL Query - Unicode data in a Unicode-only
collation or ntext data cannot be sent


> No worries, there's an "IIS-Lockdown" Tool available from Microsoft if you
> want to play around with IIS - and not have to worry about code red etc
(you
> still need to keep it regularly updated patches wise though - I guess
thats
> the advantage of apache).
>
> The sample script is fine - thats how I got into MSSQL/PHP many moons ago.
> Note that it isn't very efficient (you can write a much faster script
using
> mssql_fetch_array() and arrays) as it makes a lot of requests on the db.
I
> think you are better off creating a simple DB in MSSQL enterprise manager
> (dead easy once you get the hang of it - much better than access IMHO but
> thats not very hard!).
>
> Do you know anything about Transactional SQL?  If you do you might be able
> to help me in return (see my question in another newer thread)!
>
> If you want any more help let me know, I have been using this stuff for a
> while and don't mind sharing info (seeing as I'm probably not going to get
> to use PHP once I'm a graduate in a few months).
>
> Cheers
>
> Ollie
>
> "William Fong" <[EMAIL PROTECTED]> wrote in message
> news:<001501c1aab2$79d83e40$0ac8a8c0@willbox>...
> > Hi Ollie,
> >
> > Thank you for your reply.
> >
> > I was mistaken.  I am using PHP 4.1.1 loaded as a CGI.  I am using
Apache
> > because I am from a Solaris/Linux background, and I know how to use it
> > better.  I don't feel comfortable enough with IIS to secure it down
(with
> > all that NIMDA and CodeRed floating around).  Our company is going to
> > implement SQL Server 2000, so I want to try it out.
> >
> > I used the sample PHP script from PHP's Web site to connect.  Here is
the
> > code:
> >
> >  >
> > $hostname = "localhost";
> > $username = "username";
> > $password = "password";
> > $dbName = "Northwind";
> >
> > MSSQL_CONNECT($hostname,$username,$password) or DIE("DATABASE FAILED TO
> > RESPOND.");
> > mssql_select_db($dbName) or DIE("Table unavailable");
> >
> > $query = "SELECT * FROM Employees";
> >
> > $result = MSSQL_QUERY($query);
> >
> > $number = MSSQL_NUM_ROWS($result);
> >
> > $i=0;
> >
> > if ($number == 0) :
> >  print "No data?";
> > elseif ($number > 0) :
> >  print "Data:";
> >  while ($i < $number) :
> >   $name = mssql_result($result,$i,"Name");
> >   print $name;
> >   print "";
> >   $i++;
> >  endwhile;
> > endif;
> > ?>
> >
> >
> > I modified it to grab information from Northwind's Employee table.
> >
> > I didn't know Unicode was something that was defined.  I will try to
make
> a
> > sample database with 'more simple' database fields to see if that works.
> I
> > just wanted to do a quick test to grab data.  I see it'll take me a
little
> > longer to learn MSSQL.
> >
> > Thanks!
> >
> >
> > william
> >
> >
> > --
> > William Fong - [EMAIL PROTECTED]
> > Phone: 626.968.6424 x210  |  Fax: 626.968.6877
> > Wireless #: 805.490.7732|  Wireless E-mail:
[EMAIL PROTECTED]
> >
> >
> >
> >
> > - Original Message -
> > From: "Oliver Cronk" <[EMAIL PROTECTED]>
> > To: "Php-Db ML" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
> > Sent: Thursday, January 31, 2002 3:19 PM
> > Subject: [PHP-DB] Re: MSSQL Query - Unicode data in a Unicode-only
> collation
> > or ntext data cannot be sent
> >
> >
> > > Hi there,
> > >
> > > PHP4.0.6 on IIS / Windows 2000 works fine with SQL Server 2000 (I have
> > teste
> > > this quite throughly) I don't know about unicode fields however as I
> > don't/
> > > haven't used them in any of my databases.  I know that varchar fields
> have
> > a
> > > few issues (can't retrieve more that 255 characters, you have to use
> text
> > > fields instead - which aren't queryable).
> > >
> > > What are you using to connect to MS-SQL? The MSSQL PHP library
functions
> I
> > > hope (NOT ODBC its much slower IMO).  Why are you using Apache on
Win32
> > may
> > > I ask(is it for apache functionality you can't get with IIS?)?
> > >
> > > Whats the query that you are sending in your test.php script?
> > >
> > > Cheers
> > >
> > > Ollie
> > >
> > > <[EMAIL PROTECTED]> wrote in message
> > > news:<[EMAIL PROTECTED]>...
> > > > Getting this error:
> > > >
> > > > Warning: MS SQL message: Unicode data in a Unicode-only collation or
> > ntext
> > > data cannot be sent to clients using DB-Library (such as ISQL) or

Re: [PHP-DB] Re: MSSQL Query - Unicode data in a Unicode-only collation or ntext data cannot be sent

2002-01-31 Thread Oliver Cronk

No worries, there's an "IIS-Lockdown" Tool available from Microsoft if you
want to play around with IIS - and not have to worry about code red etc (you
still need to keep it regularly updated patches wise though - I guess thats
the advantage of apache).

The sample script is fine - thats how I got into MSSQL/PHP many moons ago.
Note that it isn't very efficient (you can write a much faster script using
mssql_fetch_array() and arrays) as it makes a lot of requests on the db.  I
think you are better off creating a simple DB in MSSQL enterprise manager
(dead easy once you get the hang of it - much better than access IMHO but
thats not very hard!).

Do you know anything about Transactional SQL?  If you do you might be able
to help me in return (see my question in another newer thread)!

If you want any more help let me know, I have been using this stuff for a
while and don't mind sharing info (seeing as I'm probably not going to get
to use PHP once I'm a graduate in a few months).

Cheers

Ollie

"William Fong" <[EMAIL PROTECTED]> wrote in message
news:<001501c1aab2$79d83e40$0ac8a8c0@willbox>...
> Hi Ollie,
>
> Thank you for your reply.
>
> I was mistaken.  I am using PHP 4.1.1 loaded as a CGI.  I am using Apache
> because I am from a Solaris/Linux background, and I know how to use it
> better.  I don't feel comfortable enough with IIS to secure it down (with
> all that NIMDA and CodeRed floating around).  Our company is going to
> implement SQL Server 2000, so I want to try it out.
>
> I used the sample PHP script from PHP's Web site to connect.  Here is the
> code:
>
> 
> $hostname = "localhost";
> $username = "username";
> $password = "password";
> $dbName = "Northwind";
>
> MSSQL_CONNECT($hostname,$username,$password) or DIE("DATABASE FAILED TO
> RESPOND.");
> mssql_select_db($dbName) or DIE("Table unavailable");
>
> $query = "SELECT * FROM Employees";
>
> $result = MSSQL_QUERY($query);
>
> $number = MSSQL_NUM_ROWS($result);
>
> $i=0;
>
> if ($number == 0) :
>  print "No data?";
> elseif ($number > 0) :
>  print "Data:";
>  while ($i < $number) :
>   $name = mssql_result($result,$i,"Name");
>   print $name;
>   print "";
>   $i++;
>  endwhile;
> endif;
> ?>
>
>
> I modified it to grab information from Northwind's Employee table.
>
> I didn't know Unicode was something that was defined.  I will try to make
a
> sample database with 'more simple' database fields to see if that works.
I
> just wanted to do a quick test to grab data.  I see it'll take me a little
> longer to learn MSSQL.
>
> Thanks!
>
>
> william
>
>
> --
> William Fong - [EMAIL PROTECTED]
> Phone: 626.968.6424 x210  |  Fax: 626.968.6877
> Wireless #: 805.490.7732|  Wireless E-mail: [EMAIL PROTECTED]
>
>
>
>
> - Original Message -
> From: "Oliver Cronk" <[EMAIL PROTECTED]>
> To: "Php-Db ML" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
> Sent: Thursday, January 31, 2002 3:19 PM
> Subject: [PHP-DB] Re: MSSQL Query - Unicode data in a Unicode-only
collation
> or ntext data cannot be sent
>
>
> > Hi there,
> >
> > PHP4.0.6 on IIS / Windows 2000 works fine with SQL Server 2000 (I have
> teste
> > this quite throughly) I don't know about unicode fields however as I
> don't/
> > haven't used them in any of my databases.  I know that varchar fields
have
> a
> > few issues (can't retrieve more that 255 characters, you have to use
text
> > fields instead - which aren't queryable).
> >
> > What are you using to connect to MS-SQL? The MSSQL PHP library functions
I
> > hope (NOT ODBC its much slower IMO).  Why are you using Apache on Win32
> may
> > I ask(is it for apache functionality you can't get with IIS?)?
> >
> > Whats the query that you are sending in your test.php script?
> >
> > Cheers
> >
> > Ollie
> >
> > <[EMAIL PROTECTED]> wrote in message
> > news:<[EMAIL PROTECTED]>...
> > > Getting this error:
> > >
> > > Warning: MS SQL message: Unicode data in a Unicode-only collation or
> ntext
> > data cannot be sent to clients using DB-Library (such as ISQL) or ODBC
> > version 3.7 or earlier. (severity 16) in C:\webroot\test.php on line 13
> > >
> > > Warning: MS SQL: Query failed in C:\webroot\test.php on line 13
> > >
> > > Warning: Supplied argument is not a valid MS SQL-result resource in
> > C:\webroot\test.php on line 15
> > >
> > > ---
> > >
> > > Using Windows 2000 Server with Apache 1.3.23 and PHP4.0 with SQL
Server
> > 2000.  Any ideas?  PHP's site didn't mention anything about SQL Server
> 2000.
> > >
> > > Thanks!
> > >
> > > will
> > >
> >
> >
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> >
> >
>
>



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Re: MSSQL Query - Unicode data in a Unicode-only collation or ntext data cannot be sent

2002-01-31 Thread William Fong

Hi Ollie,

Thank you for your reply.

I was mistaken.  I am using PHP 4.1.1 loaded as a CGI.  I am using Apache
because I am from a Solaris/Linux background, and I know how to use it
better.  I don't feel comfortable enough with IIS to secure it down (with
all that NIMDA and CodeRed floating around).  Our company is going to
implement SQL Server 2000, so I want to try it out.

I used the sample PHP script from PHP's Web site to connect.  Here is the
code:

 0) :
 print "Data:";
 while ($i < $number) :
  $name = mssql_result($result,$i,"Name");
  print $name;
  print "";
  $i++;
 endwhile;
endif;
?>


I modified it to grab information from Northwind's Employee table.

I didn't know Unicode was something that was defined.  I will try to make a
sample database with 'more simple' database fields to see if that works.  I
just wanted to do a quick test to grab data.  I see it'll take me a little
longer to learn MSSQL.

Thanks!


william


--
William Fong - [EMAIL PROTECTED]
Phone: 626.968.6424 x210  |  Fax: 626.968.6877
Wireless #: 805.490.7732|  Wireless E-mail: [EMAIL PROTECTED]




- Original Message -
From: "Oliver Cronk" <[EMAIL PROTECTED]>
To: "Php-Db ML" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Thursday, January 31, 2002 3:19 PM
Subject: [PHP-DB] Re: MSSQL Query - Unicode data in a Unicode-only collation
or ntext data cannot be sent


> Hi there,
>
> PHP4.0.6 on IIS / Windows 2000 works fine with SQL Server 2000 (I have
teste
> this quite throughly) I don't know about unicode fields however as I
don't/
> haven't used them in any of my databases.  I know that varchar fields have
a
> few issues (can't retrieve more that 255 characters, you have to use text
> fields instead - which aren't queryable).
>
> What are you using to connect to MS-SQL? The MSSQL PHP library functions I
> hope (NOT ODBC its much slower IMO).  Why are you using Apache on Win32
may
> I ask(is it for apache functionality you can't get with IIS?)?
>
> Whats the query that you are sending in your test.php script?
>
> Cheers
>
> Ollie
>
> <[EMAIL PROTECTED]> wrote in message
> news:<[EMAIL PROTECTED]>...
> > Getting this error:
> >
> > Warning: MS SQL message: Unicode data in a Unicode-only collation or
ntext
> data cannot be sent to clients using DB-Library (such as ISQL) or ODBC
> version 3.7 or earlier. (severity 16) in C:\webroot\test.php on line 13
> >
> > Warning: MS SQL: Query failed in C:\webroot\test.php on line 13
> >
> > Warning: Supplied argument is not a valid MS SQL-result resource in
> C:\webroot\test.php on line 15
> >
> > ---
> >
> > Using Windows 2000 Server with Apache 1.3.23 and PHP4.0 with SQL Server
> 2000.  Any ideas?  PHP's site didn't mention anything about SQL Server
2000.
> >
> > Thanks!
> >
> > will
> >
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] renaming uploaded files

2002-01-31 Thread Jose Maria Sala

Hi php developers:

I have created a website for a house renting company with an administration
tool. Using this tool, managers can add, modify and delete data in a mysql
database.

They can also upload some pictures of the houses they rent. The way i do
this is by taking them to the list of houses, making them select one and
next they go to a form. In this form they upload files to a certain folder
in the server.

What i would like to do is auto rename the file with a name composed by
IDNUMBER + NUMBER OF PICTURE (ex. if ID of that house is 345 image name
would be 34501.gif, 34502.gif, 34503.gif,...)

I think you got the idea. Any help would be greatly appreciated.

thx in advance



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] Re: MSSQL Query - Unicode data in a Unicode-only collation or ntext data cannot be sent

2002-01-31 Thread Oliver Cronk

Hi there,

PHP4.0.6 on IIS / Windows 2000 works fine with SQL Server 2000 (I have teste
this quite throughly) I don't know about unicode fields however as I don't/
haven't used them in any of my databases.  I know that varchar fields have a
few issues (can't retrieve more that 255 characters, you have to use text
fields instead - which aren't queryable).

What are you using to connect to MS-SQL? The MSSQL PHP library functions I
hope (NOT ODBC its much slower IMO).  Why are you using Apache on Win32 may
I ask(is it for apache functionality you can't get with IIS?)?

Whats the query that you are sending in your test.php script?

Cheers

Ollie

<[EMAIL PROTECTED]> wrote in message
news:<[EMAIL PROTECTED]>...
> Getting this error:
>
> Warning: MS SQL message: Unicode data in a Unicode-only collation or ntext
data cannot be sent to clients using DB-Library (such as ISQL) or ODBC
version 3.7 or earlier. (severity 16) in C:\webroot\test.php on line 13
>
> Warning: MS SQL: Query failed in C:\webroot\test.php on line 13
>
> Warning: Supplied argument is not a valid MS SQL-result resource in
C:\webroot\test.php on line 15
>
> ---
>
> Using Windows 2000 Server with Apache 1.3.23 and PHP4.0 with SQL Server
2000.  Any ideas?  PHP's site didn't mention anything about SQL Server 2000.
>
> Thanks!
>
> will
>



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] Ensuring users don't overwrite each other (NOT a newbie question)

2002-01-31 Thread Oliver Cronk


Hi there, currently writing an e-CRM system for an intranet using PHP on
Win32 and MS-SQL.  This system needs to be scalable but more importantly
there will be anything up to 400 users (unlikely, but the max amount) using
the same records (updating information about customers etc) and I worry that
whilst one user has a form open (via one of my PHP scripts) that another
user could also be making changes to the same record and if they post it
before the other one they could overwite each others changes.  For info:
database is normalised to 3NF so that side of things should be okay.

I have thought of a couple of solutions:

Row Locking when a user has a record - and if another user wants to use that
record PHP tells them its in use.  But if the forst user doesn't make any
changes how will the db know to unlock the row and there might be potential
deadlock issues.  Also I'm not sure of the SQL for row locking (do you use a
SELECT with a ROWLOCK hint?).

Another idea was to have a log or temp table - that would get written into
when ever some opens a record but this has the same issues as the first
solution I think.

An another idea is T-SQL and transactions but I'm not sure if that will
solve the problem (and I've never used T-SQL before - therefore I'm not sure
of its capabilities)
eg:
When the script is started by the first user (to bring up the existing
record) perhaps a transaction is started (if they can persist between
batches?):

$tranname = "@tran".$id;
$sqlstr = "TRANSACTION $tranname

SELECT rows from CASES
WHERE id = $id
GO

/* maybe find the date / time from a system table sp_something of the last
time the row was modified?? */

START TRANSACTION $tranname
GO
";

But that probably won't work thinking about it (and looking at the stupid
senseless code I have written above) The transcation probably need to be
around the update SQL doesn't it?  And then do a rollback if it finds
another user has updated lately?  And then reload the data and send it back
to the form for the user to check (then they can update - after checking the
other users data?)

Anybody have a solution /views on this?  Anybody had to fix a similar
problem?  Or is all this paranoia (will the DB handle this problem on it
own? - I very much doubt that last comment!)

Any help would be most appreciated, I don't need all of the PHP code just
the concepts will do (I have been using PHP/MS-SQL for a while) or some
example T-SQL if you think thats the solution I should go for.

Thanks very much in advance...

Oliver Cronk













-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] how to reverse a hudge multidimensional array?

2002-01-31 Thread DL Neil

Ca va Etienne,

> well in fact i think i haven t be very clear with the goal i need to get.
> let me detail this to you frm the beginning to the end...

=the goal is still not clear to me, and if you want to critique this response, or ask 
a further question, it
would help me to know what on earth we are talkinga bout with "naffaire", "ncpt", and 
the system being
constructed... I've tried to work with this information on a theoretical basis, but it 
makes the job more
difficult, not to know what we're actually working with!

=I do (now) see that you were not wanting to invert the array, but to perform a pivot 
table analysis.

> i ve a table as follows:
>
> naffaire   |   ncpte
> 1|   3
> 2|   5
> 7|   9
> 5|   6
> 2|   5
> 6|   9
> 4|   2
> 1|   3
> 4|   2
> 7|   9
> 4|   2
> 9|   7
> 7|   9
> 4|   2
> 5|   6
> 4|   2
> ... and 1 million lines like that...
>
> naffaire and ncpte are linked : there can only be one ncpte for a naffaire,
> if you find a 7 as naffaire with 9 as ncpte all the lines containing 7 as
> naffaire will have 9 as ncpte. BUT the opposite of this relation is not true
> : a ncpte can be associated with different naffaire. (as you can see in the
> previous example at the lines 3, 6, 10...
>
> what i do with this table is a count on the number of couple of
> naffaire/ncpte and the only parameter return with my query is the count (not
> the naffaire or the ncpte...), no matter the datas, i juste need to work
> with their occurences...

=if a particular naffair value has a one-to-one relationship with a particular ncpte 
value, then naffaire implie
ncpte and there is no need to consider them as 'couples' - only need to deal with 
naffaire.

=to count the number of occurences of each naffair value (couple):

SELECT naffair, COUNT(*) AS suite
  FROM tbl
  # no need for a WHERE clause because we're looking at the entire tbl
  GROUP BY naffair   # to control the COUNT()

> well, now for the examle detail previously the query gives me
>
> RESULT OF TABLE WHERE
> THE QUERY  THE QUERY IS DONE
>
>  count(*)  naffaire   |
> ncpte
>  2 1
> |   3
>  2 2
> |   5
>  3 7
> |   9
>  2 5
> |   6
>  2 2
> |   5
>  1 6
> |   9
>  5 4
> |   2
>  2 1
> |   3
>  5 4
> |   2
>  3 7
> |   9
>  5 4
> |   2
>  1 9
> |   7
>  3 7
> |   9
>  5 4
> |   2
>  2 5
> |   6
>  5 4
> |   2
> ... and 1 million lines like that...

=and I trust that the SQL above yields the same result (I haven't tested it in any 
way). The naffair value and
the number of times it appears in the table.

> So i get a 2 dimension array with only one column and 1 million rows...
> the fact is what i need is to count the occurrences for each result in this
> array.
> So for the same example we would get :
> occurrence of 1 : 2
> occurrence of 2 : 6
> occurrence of 3 : 3
> occurrence of 4 : null
> occurrence of 5 : 5
> ...

=so now you want to know how many naffair values appear in the table a specific number 
of times/how many naffair
values share the same occurence rate/frequency.

=you could feed the MySQL result set 'suite' column straight into your existing PHP 
array and function (as
below)...

> to do this in an array there's an easy and light way : array_count_values.
> the problem is that this function only works on the first dimension of the
> array.
> That s why i have to return my column of result into a line
> I did it with this loop:
>
> while($row = mysql_fetch_array($result)) {
> array_push($suite, $row["count(*)"]);
> }
>
> It works fine... of course and then i make the array count 

Re: [PHP-DB] Re: Date operations.

2002-01-31 Thread DL Neil

Frank,

As yet no response from Garry, but I wanted to ask:
You already have DateTable set up (presumably), so extending its application into a 
relationship with the
breeding table is no big deal. Given that one suggestion was that Garry could consider 
storing monthly
statistics in another table (from breeding), and thus saves processing each time/only 
needs to update once per
month and presumably only for the month just passed; wouldn't it make sense FOR HIM to 
combine the two
functions? Initially create the MonthlyStats table to contain only year and month data 
(which can be related to
'drive' date-oriented SELECTing), and then update/populate each month's row as and 
when the stats become
available. It might also offer opportunities to simplify the processing outlined below.

Your thoughts?
=dn


- Original Message -
From: "Frank Flynn" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: 30 January 2002 17:05
Subject: [PHP-DB] Re: Date operations.


> Gary,
>
> You have a right to be confused - this problem is short but it is about as
> complex as they get.  Still I have a solution for you, also short and you'll
> (hopefully) find it elegant.  I found it interesting...
>
> The thing is we will create a Cartesian product on purpose - this is
> something they tell people learning SQL to avoid (and usually they are not
> helpful) but here it is the only to get a daily average since you don't have
> daily records of your pairs just a start and stop date.
>
> I was looking at the problem from the child point of view in my first post
> (easier since children only have a single birthday).  I'll use your problem
> now.
>
> We will keep the DateTable and use your 'breeding' table but I will change
> the 'paired' and 'split' columns to int (you don't need to do this but it
> will make thing easier - some DBMS's will always put a time stamp in a Date
> field and this does screw thing up - it makes it harder to join on them).
>
> So we have:
>
>   breeding
>  ---
>rec   SMALLINT PRIMARY KEY
>sire  SMALLINT
>dam   SMALLINT
>pairedINT
>split INT
>num_offspring INT
>
> And
>
>   DateTable
>  
>dayID   INT PRIMARY KEY
>myDate  DATE
>month   INT
>yearINT
>quarter INT
>
>  /* and as discussed any other date related columns */
>
>
> > I need to count how many pairs were breeding
> > on a given day, and then average over the month.
>
> OK - fasten you seat belt :-0
>
> SELECT count(*), myDate
>   FROM breeding, DateTable
>   WHERE paired >= dayID
>AND split <= dayID
>AND month = 2
>AND year = 2001
>   GROUP BY myDay
>   ORDER BY myDay
>
> /* you could have just as easily used a start and stop date */
> /* myDay >= "2/1/2001" and myDate < "3/1/2001" */
>
> This will give you output something like this (the total per day):
>   5  Feb 1, 2001
>   5  Feb 2, 2001
>   5  Feb 3, 2001
>   5  Feb 4, 2001
>   5  Feb 5, 2001
>   6  Feb 6, 2001
>   6  Feb 7, 2001
>   6  Feb 8, 2001
>   6  Feb 9, 2001
>   6  Feb 10, 2001
>   6  Feb 11, 2001
> ... And so on ...
>
>
> To get the average per month I'd use a temporary table (a table you create
> just for this report or that is always there but empty except during this
> report)
>
> /* start with an empty table */
> CREATE TABLE TotalByDay
> ( total INT,
>   dayID INT)
>
> /* --- or --- */
>
> TRUNCATE TABLE TotalByDay
>
> /* now fill it... */
> /* notice it the same SQL but I've gone back to */
> /* dayID (the INT) not the full date and I've done */
> /* the whole year so we can average per month */
>
> INSERT INTO TotalByDay
> SELECT count(*), dayID
>   FROM breeding, DateTable
>   WHERE paired >= dayID
>AND split <= dayID
>AND year = 2001
>   GROUP BY dayID
>   ORDER BY dayID
>
>
> /* OK almost there ...  Now to average by month */
>
> SELECT ave(total), month, year
>   FROM TotalByDay, DateTable
>   WHERE TotalByDay.dayID = DateTable.dayID
>   GROUP BY month
>   ORDER BY month
>
>
> Now you've got output like
>
>  5  1 2001
>  6  2 2001
>  6  3 2001
>  7  4 2001
>  12  5 2001
>  11  6 2001
>  11  7 2001
>  7  8 2001
>  7  9 2001
>  9  10 2001
>  9  11 2001
>  9  12 2001
>
> From here you convert the month INT back into a name.
>
> Feel free to writ back with any questions (it's headdy stuff) also I don't
> have a mySQL db handy to check the syntax against - hopefully I've
> remembered everything correctly.  The concept is sound, we do this all the
> time.
>
> The "got ya's" are the DateTable must be full (don't fill it to the end of
> this year and forget about it - next year your reports will be wrong)
>
> Frank
>
>
> >
> > Ouch, I'm getting a bit lost. I need to count how many pairs were breeding
> > on a given day, and then average over the month. Playing with mysql I get
> > for say the 1st day of the year:
> >
> > select count(*) from breeding
> >  where TO_DAYS(paired) <= TO_DAYS('2002-1-1')
> >  AND TO_DAYS('2002-1-1') <= TO_DAYS(split);
> >

[PHP-DB] phpMyAdmin Problem....

2002-01-31 Thread SpyProductions Support Team


I just added phpMyAdmin to a new Apache Server, and I'm getting this error:

cannot load MySQL extension,
please check PHP Configuration.

I did some research on the web, but couldn't come up with a solution to this
error and couldn't find anyone listing it.

Does anyone know if this is a problem with conf.inc.php in phpMyAdmin or
with the MySQL set up in PHP on the server?

Any suggestions from there?

Thanks,

-Mike



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] NULL Values

2002-01-31 Thread Zach Curtis

I have a loop process that reads a record out of a flat file, stores the
data for a given record in an array, writes the record to the db, resets the
data in the array, then iterates again thru the loop. Not every record has a
value for each field. For example,

Not every record has a value for the field "cus034a". Since this is numeric
type data, I do not want the value in the db to be "0" if there is no value
for the field (it should be NULL).

# partial table definition
cus034a TINYINT UNSIGNED NULL,
sat01 TINYINT UNSIGNED NULL,

What I try to do is set the array to NULL values before iterating the loop
again. However, if I do this and the next record does not have a value for
"cus034a", the value in the db still ends up being "0".

$data_array["cus034a"] = NULL;
$data_array["sat01"] = NULL;

I must be doing something wrong?

Thank you.


Zach Curtis
POPULUS


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] how to reverse a hudge multidimensional array?

2002-01-31 Thread Andrés Felipe Hernández


This seems quite familiar for me.  Does this has to do whit chaos?

Anyway, i think i'm getting the idea, but it would be a better to see the
whole code.  (at least for me)

good luck,
andrés

>thx again for helping me

>In fact i think the solution you gave me isn t not much faster as the while
>loop i use for the moment...
>and the execution speed is my only problem...

>well in fact i think i haven t be very clear with the goal i need to get.
>let me detail this to you frm the beginning to the end...




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Connection class

2002-01-31 Thread jas

Well it was acutally so that I can create a content management system for my
employer.  Another gentleman helped me with it and it is working great I
simply created a file *.php with all my connection commands then did a
require on the page(s) that needed to query the db to pull information about
what is currently inserted into different fields.  My NEW problem has to do
with getting my INSERT statements to overwrite the distinctive fields when
storing updates etc.  I am looking into how to accomplish this at the
moment.  Sorry again for posting the same question a few times, it seems my
email editor choked.  =)  Thanks again.
Jas
"Rick Emery" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> huh?
>
> You open the connection once for the page and then you CAN make multiple
> queries to it from the same page.  Why are you trying to create a class to
> do this (unless it's simply an intellectual exercise to create a class)?
>
>
> -Original Message-
> From: jas [mailto:[EMAIL PROTECTED]]
> Sent: Saturday, January 26, 2002 12:08 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] Connection class
>
>
> Ok well I am in a little over my head with a connection class that I can
use
> over and over for multiple queries against a mysql db on one page.  I have
> read a few tutorials on the subject of how to use class files but I still
> dont understand php enough to know how to make a connection class that
> simply allows me to connect to a mysql database once the page loads and
> keeps the connection to run multiple queries on the same page.  HELP!!!
> Thanks again in advance...
> Jas
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] Strange re-include/crash problem with Oracle (OCI8)

2002-01-31 Thread Hans Zaunere



Hello,

I have PHP 4.0.6 compiled as an Apache 1.3.20 module with OCI and MySQL
on RedHat 6.2.  Things work nicely, except for the following situation:

When connecting to the remote Oracle server, if the server happens to be
down or unavail, I get, what appears to be, re-inclusion, even though I
use require_once().  For example I get this thrown on the screen:

Warning: Constant sid already defined in Unknown on line 0

Warning: Cannot send session cache limiter - headers already sent
(output started at /usr/local/apache/htdocs:65) in Unknown on line 0

Warning: Constant godroot already defined in
/usr/local/apache/htdocs/base.inc.php on line 3

Warning: Constant servername already defined in
/usr/local/apache/htdocs/base.inc.php on line 5


The error then continues with all my top-level defines() in
base.inc.php.  I have session.auto_start=1 and session.use_cookies=1 in
php.ini.  Additionally, the error I get from Oracle is:

ORA-03113: end-of-file on communication channel


Although this is the error I get recently, I have found that this
problem also occurs with other various connection-type Oracle errors.
Additionally, a look at Apache's error_log shows:

[Thu Jan 31 08:03:02 2002] [notice] child pid 20749 exit signal
Segmentation fault (11)
[Thu Jan 31 08:04:16 2002] [notice] child pid 20757 exit signal
Segmentation fault (11)
[Thu Jan 31 08:04:20 2002] [notice] child pid 20753 exit signal
Segmentation fault (11)

Although if I hit the refresh button, all the Warning: messages go
away.  If Oracle is still down, the normal Oracle message is shown, as
expected.  So in other words, this only happens right after trying to
load the page for the first time with Oracle being down for one reason
or another.

Any help or explanation would be great, as the end-user doesn't like
seeing all the Warnings, as opposed to:  Oracle Database Down.   If
anymore info or clarification is needed, please don't hesitate to ask.

Thank you,

Hans


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] Connection class

2002-01-31 Thread Rick Emery

huh?

You open the connection once for the page and then you CAN make multiple
queries to it from the same page.  Why are you trying to create a class to
do this (unless it's simply an intellectual exercise to create a class)?


-Original Message-
From: jas [mailto:[EMAIL PROTECTED]]
Sent: Saturday, January 26, 2002 12:08 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Connection class


Ok well I am in a little over my head with a connection class that I can use
over and over for multiple queries against a mysql db on one page.  I have
read a few tutorials on the subject of how to use class files but I still
dont understand php enough to know how to make a connection class that
simply allows me to connect to a mysql database once the page loads and
keeps the connection to run multiple queries on the same page.  HELP!!!
Thanks again in advance...
Jas



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] 2 Questions... INSERT and searching records....

2002-01-31 Thread Rick Emery

 Remove the \"\".

Next, whenever you have a problem with a query, print mysql_error() as part
of your die() statement.  Finally, print your $sql to ensure that it
contains what you expect.

-Original Message-
From: Todd Williamsen [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 31, 2002 1:05 PM
To: 'Rick Emery'; [EMAIL PROTECTED]
Subject: RE: [PHP-DB] 2 Questions... INSERT and searching records


I pulled that code right out of her book...same thing

-Original Message-
From: Rick Emery [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, January 31, 2002 1:02 PM
To: 'Todd Williamsen'; [EMAIL PROTECTED]
Subject: RE: [PHP-DB] 2 Questions... INSERT and searching records


And the problem is...

You are trying to insert 8 values into 7 fields.  You begin your VALUES
with
"", but there is not field specified for it.

Don't blame Meloni here until you've proven her wrong.

-Original Message-
From: Todd Williamsen [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 31, 2002 12:43 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] 2 Questions... INSERT and searching records


It seems that my insert statement doesn't want to cooperate..  I used
the
same format as in Julie Meloni's book.  I know, sometimes, her code
doesn't
always work either.

here it is:

$sql = "INSERT INTO Jobs (id, Industry, Other, JobTitle, Description,
Location, Date)
 VALUES
 (\"\",
 \"$id\", \"$Industry\", \"$Other\", \"$JobTitle\", \"$Description\",
\"$Location\", \"$Date\")";
 $result = @mysql_query($sql) or die("OOPS!!  Couldn't Execute Query!");
 ?>

its not the whole code block... it dies and executes the "OOPS!!
Couldn't
Execute Query!" statement.
what is wrong... anybody?  Bueller?



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] 2 Questions... INSERT and searching records....

2002-01-31 Thread Todd Williamsen

I pulled that code right out of her book...same thing

-Original Message-
From: Rick Emery [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, January 31, 2002 1:02 PM
To: 'Todd Williamsen'; [EMAIL PROTECTED]
Subject: RE: [PHP-DB] 2 Questions... INSERT and searching records


And the problem is...

You are trying to insert 8 values into 7 fields.  You begin your VALUES
with
"", but there is not field specified for it.

Don't blame Meloni here until you've proven her wrong.

-Original Message-
From: Todd Williamsen [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 31, 2002 12:43 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] 2 Questions... INSERT and searching records


It seems that my insert statement doesn't want to cooperate..  I used
the
same format as in Julie Meloni's book.  I know, sometimes, her code
doesn't
always work either.

here it is:

$sql = "INSERT INTO Jobs (id, Industry, Other, JobTitle, Description,
Location, Date)
 VALUES
 (\"\",
 \"$id\", \"$Industry\", \"$Other\", \"$JobTitle\", \"$Description\",
\"$Location\", \"$Date\")";
 $result = @mysql_query($sql) or die("OOPS!!  Couldn't Execute Query!");
 ?>

its not the whole code block... it dies and executes the "OOPS!!
Couldn't
Execute Query!" statement.
what is wrong... anybody?  Bueller?



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] 2 Questions... INSERT and searching records....

2002-01-31 Thread Rick Emery

And the problem is...

You are trying to insert 8 values into 7 fields.  You begin your VALUES with
"", but there is not field specified for it.

Don't blame Meloni here until you've proven her wrong.

-Original Message-
From: Todd Williamsen [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 31, 2002 12:43 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] 2 Questions... INSERT and searching records


It seems that my insert statement doesn't want to cooperate..  I used the
same format as in Julie Meloni's book.  I know, sometimes, her code doesn't
always work either.

here it is:

$sql = "INSERT INTO Jobs (id, Industry, Other, JobTitle, Description,
Location, Date)
 VALUES
 (\"\",
 \"$id\", \"$Industry\", \"$Other\", \"$JobTitle\", \"$Description\",
\"$Location\", \"$Date\")";
 $result = @mysql_query($sql) or die("OOPS!!  Couldn't Execute Query!");
 ?>

its not the whole code block... it dies and executes the "OOPS!!  Couldn't
Execute Query!" statement.
what is wrong... anybody?  Bueller?



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] 2 Questions... INSERT and searching records....

2002-01-31 Thread Jason Wong

On Friday 01 February 2002 02:42, Todd Williamsen wrote:
> It seems that my insert statement doesn't want to cooperate..  I used the
> same format as in Julie Meloni's book.  I know, sometimes, her code doesn't
> always work either.
>
> here it is:
>
> $sql = "INSERT INTO Jobs (id, Industry, Other, JobTitle, Description,
> Location, Date)
>  VALUES
>  (\"\",
>  \"$id\", \"$Industry\", \"$Other\", \"$JobTitle\", \"$Description\",
> \"$Location\", \"$Date\")";
>  $result = @mysql_query($sql) or die("OOPS!!  Couldn't Execute Query!");
>  ?>
>
> its not the whole code block... it dies and executes the "OOPS!!  Couldn't
> Execute Query!" statement.
> what is wrong... anybody?  Bueller?


Try using single quotes:

 $sql = "INSERT INTO Jobs (id, Industry, Other, JobTitle, Description,
 Location, Date)
  VALUES
  ('',
  '$id', '$Industry', '$Other', '$JobTitle', '$Description',
 '$Location', '$Date')";



-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk

/*
To fear love is to fear life, and those who fear life are already three
parts dead.
-- Bertrand Russell
*/

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] Re: 2 Questions... INSERT and searching records....

2002-01-31 Thread Todd Williamsen

OOps... second question...

I wanted to do a search of text documents that are inserted into the
database.

1. What is the best data type for large amounts of text, like 2000
characters.  I thought BLOB, but I could be wrong...

2.  Within the above text, I wanted to search via keywords.  How would I do
that?


"Todd Williamsen" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> It seems that my insert statement doesn't want to cooperate..  I used the
> same format as in Julie Meloni's book.  I know, sometimes, her code
doesn't
> always work either.
>
> here it is:
>
> $sql = "INSERT INTO Jobs (id, Industry, Other, JobTitle, Description,
> Location, Date)
>  VALUES
>  (\"\",
>  \"$id\", \"$Industry\", \"$Other\", \"$JobTitle\", \"$Description\",
> \"$Location\", \"$Date\")";
>  $result = @mysql_query($sql) or die("OOPS!!  Couldn't Execute Query!");
>  ?>
>
> its not the whole code block... it dies and executes the "OOPS!!  Couldn't
> Execute Query!" statement.
> what is wrong... anybody?  Bueller?
>
>



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] 2 Questions... INSERT and searching records....

2002-01-31 Thread Todd Williamsen

It seems that my insert statement doesn't want to cooperate..  I used the
same format as in Julie Meloni's book.  I know, sometimes, her code doesn't
always work either.

here it is:

$sql = "INSERT INTO Jobs (id, Industry, Other, JobTitle, Description,
Location, Date)
 VALUES
 (\"\",
 \"$id\", \"$Industry\", \"$Other\", \"$JobTitle\", \"$Description\",
\"$Location\", \"$Date\")";
 $result = @mysql_query($sql) or die("OOPS!!  Couldn't Execute Query!");
 ?>

its not the whole code block... it dies and executes the "OOPS!!  Couldn't
Execute Query!" statement.
what is wrong... anybody?  Bueller?



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] DB Connections

2002-01-31 Thread Paul Burney

on 1/26/02 1:21 AM, jas at [EMAIL PROTECTED] appended the following bits
to my mbox:

> Ok, I am having a hard time coming up with a mysql connection class that
> simply allows me to setup a require(db_connection.inc) at the top of my php
> pages that allows a consistent connection to the mysql db and allows
> multiple queries thoughout the php page in question.  I have read a few
> tutorials on it and as of yet they all seem to go over my head.  If someone
> could give me some more insight into this area I would greatly appriciate
> it.

I don't think you really need a connection class, per se.  What you want to
do is write the connection code for the database once and then be able to
use it in all of your pages, correct.

How about this:

db_connection.php


Then in each file, at the top:


And you would call your queries like this:

$query = 'SELECT au FROM pb WHERE alchemy!="junk_science"';
$res = mysql_query($query, $dbh);

>From there you need to use the fetch_row/array functions as described in the
PHP manual.

If not using MySQL, change the "connect" call to the appropriate function.

The above assumes that you are just talking to tables in one database.  If
using more databases, put the select_db call in the individual files.

Also, if your db_connection.php file isn't in the same directory as the
files requiring it, use an absolute location or put the file in your include
path.

HTH.

Paul






-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] MySQL Connections

2002-01-31 Thread jas

Ok how can I find some good resources on how to create a db connection class
that doesnt go over my head?  I need to be able to connect to a mysql
database as the page loads and thoughout the page run 6 separate queries on
different fields.  please help!
jas



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] DB Connections

2002-01-31 Thread Gurhan Ozen

Jas...
What errors are you getting? What do you have inside your db_connection.inc
file? Do you have the path for db_connection.inc inside the require()
function correct?
  Give us more insights to be able to find out what the problem is..

Gurhan

-Original Message-
From: jas [mailto:[EMAIL PROTECTED]]
Sent: Saturday, January 26, 2002 1:21 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] DB Connections


Ok, I am having a hard time coming up with a mysql connection class that
simply allows me to setup a require(db_connection.inc) at the top of my php
pages that allows a consistent connection to the mysql db and allows
multiple queries thoughout the php page in question.  I have read a few
tutorials on it and as of yet they all seem to go over my head.  If someone
could give me some more insight into this area I would greatly appriciate
it.
Jas



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] Re: Selct & show certain num records ?

2002-01-31 Thread Alan McFarlane

$table_name = "my_table";
$timestamp_field = "date_posted"; /* or something similar */
$max_records = 5;

$sql = sprintf("SELECT * FROM %s ORDER BY %s DESC LIMIT %d", $table_name,
$timestamp_field, $max_records):

$result = mysql_query($sql);

/* ... */

Dave Carrera <[EMAIL PROTECTED]> wrote in message
000601c1aa2c$84eb4a60$f94a27d9@authorised">news:000601c1aa2c$84eb4a60$f94a27d9@authorised...
> Hi All
>
> I know this has been covered here before but can someone please remind
> me how to selct just the 5 latest records in my db and show them in list
> form.
>
> Just like phpbuilder.com dose
>
> I thank you in advance for repeating this information.
>
> Dave C :-)
>
>



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] Re: session vars between two host servers

2002-01-31 Thread John Lim

Your solution sounds good. That's what I use too.

<[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
>
> Problem: hosts "http://www."; and "https://secure."; of the same domain need
> to work with the same browser session_id.  This is a
> login/authenticate/redirect scenario.  In this case the session data store
> is a common MySQL database, so the issues of /tmp sharing, NFS, etc. are
set
> aside.  My platform is Apache 1.3.22 and RH Linux 7.1.
>
> What PHP v4.1.x method of exchanging the session_id and session_name is
most
> secure, most effective, and generally makes good soup?
>
> I've had some success with initial tests in appending
> '?PHPSESSID=29AE490...' to the URL and link hrefs, but that really seems
> ugly and unnecessary. hopefully there's a better way!?
>
> This question seems to get asked a lot in the archives but there doesn't
> seem to be a "guideline" resolution.
>
> PLEASE and THANK YOU!
> RF.
>
>
>
>
>



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] DB Connections

2002-01-31 Thread jas

Ok, I am having a hard time coming up with a mysql connection class that
simply allows me to setup a require(db_connection.inc) at the top of my php
pages that allows a consistent connection to the mysql db and allows
multiple queries thoughout the php page in question.  I have read a few
tutorials on it and as of yet they all seem to go over my head.  If someone
could give me some more insight into this area I would greatly appriciate
it.
Jas



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] Connection class

2002-01-31 Thread jas

Ok well I am in a little over my head with a connection class that I can use
over and over for multiple queries against a mysql db on one page.  I have
read a few tutorials on the subject of how to use class files but I still
dont understand php enough to know how to make a connection class that
simply allows me to connect to a mysql database once the page loads and
keeps the connection to run multiple queries on the same page.  HELP!!!
Thanks again in advance...
Jas



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] DB Connection Class

2002-01-31 Thread jas

Ok, I hate to ask this again but I am having a hard time developing a
connection class to be reused.  I need to be able to just connect to the
database for several pages because I have multiple queries per page.
Unfortunately I do not know enough about php to effictively do this.  I have
read a few tutorials on the subject but they keep going way over my head, I
need a simple to understand method of reusing a connection for each query.
Please help! Thanks in advance!
Jas



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] Adding to an empty field

2002-01-31 Thread Rick Emery

First, you cannot have something called: 

That is, array[answer] is illegal and ignored.  you can use:


Then, search through $array[] for values.

Help us to help you...post your HTML and your code.  We promise not to steal
it and use it ourselves 

-Original Message-
From: Alex Francis [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 31, 2002 10:27 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Adding to an empty field


Still having problems

$array[answer] is passed from a previous page with this page.

Answer: 

Submit
Answer");?>
Have tried changing to array[$answer] on both pages without any luck.

Changed the code to:
$query = "UPDATE submissions SET answers = \"".$array[$answer]."\" where id
= \"$id\"";
and added the following:
 echo mysql_affected_rows();
affected rows returns 0 although query returns the correct id


Alex Francis
Cameron Design
35, Drumillan Hill
Greenock PA16 0XD

Tel 01475 798106
[EMAIL PROTECTED]
http://www.camerondesign.co.uk

This message is sent in confidence for the addressee only. It may contain
legally privileged information.
Unauthorised recipients are requested to preserve this confidentiality and
to advise the sender
immediately of any error in transmission.
Rick Emery <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> What is $array[answer].  Should that be $array[$answer] ?
>
> Second, change to:
> $query = 'UPDATE submissions SET answers = \"".$array[$answer]."\" where
id
> = \"$id\"";
>
> Ya gotta quote that text.
>
> -Original Message-
> From: Alex Francis [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, January 31, 2002 8:07 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] Adding to an empty field
>
>
> I have an empty field in a mysql database table which needs to have text
> inserted when  my client answers an email. The code is as follows
>
>
> $query = 'UPDATE submissions SET answers = "$array[answer]" where id =
"$id"
> ';
>  // $query = $query . " where id = $id ";
>
>  // echo ("The query is: $query\n");
>
> if (mysql_db_query ($dbname, $query, $link)){
>   echo ("The answer was successfully inserted!\n");
>  } else {
>   echo ("The answer could not be inserted!" . mysql_error () . "\n");
>  }
>
>
>  mysql_close ($link);
>
> The query seems to work alright, no errors showing up and "The answer was
> successfully inserted!" displayed. However, the table is not updated and I
> cannot see why. The same happens on another page when I try to insert a
'Y'.
> This script was copied from a third page which works alright.
>
> I hope someone can help. I am going mad!!!.
> --
> Alex Francis
> Cameron Design
> 35, Drumillan Hill
> Greenock PA16 0XD
>
> Tel 01475 798106
> [EMAIL PROTECTED]
> http://www.camerondesign.co.uk
>
> This message is sent in confidence for the addressee only. It may contain
> legally privileged information.
> Unauthorised recipients are requested to preserve this confidentiality and
> to advise the sender
> immediately of any error in transmission.
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Adding to an empty field

2002-01-31 Thread Alex Francis

Still having problems

$array[answer] is passed from a previous page with this page.

Answer: 

Submit
Answer");?>
Have tried changing to array[$answer] on both pages without any luck.

Changed the code to:
$query = "UPDATE submissions SET answers = \"".$array[$answer]."\" where id
= \"$id\"";
and added the following:
 echo mysql_affected_rows();
affected rows returns 0 although query returns the correct id


Alex Francis
Cameron Design
35, Drumillan Hill
Greenock PA16 0XD

Tel 01475 798106
[EMAIL PROTECTED]
http://www.camerondesign.co.uk

This message is sent in confidence for the addressee only. It may contain
legally privileged information.
Unauthorised recipients are requested to preserve this confidentiality and
to advise the sender
immediately of any error in transmission.
Rick Emery <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> What is $array[answer].  Should that be $array[$answer] ?
>
> Second, change to:
> $query = 'UPDATE submissions SET answers = \"".$array[$answer]."\" where
id
> = \"$id\"";
>
> Ya gotta quote that text.
>
> -Original Message-
> From: Alex Francis [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, January 31, 2002 8:07 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] Adding to an empty field
>
>
> I have an empty field in a mysql database table which needs to have text
> inserted when  my client answers an email. The code is as follows
>
>
> $query = 'UPDATE submissions SET answers = "$array[answer]" where id =
"$id"
> ';
>  // $query = $query . " where id = $id ";
>
>  // echo ("The query is: $query\n");
>
> if (mysql_db_query ($dbname, $query, $link)){
>   echo ("The answer was successfully inserted!\n");
>  } else {
>   echo ("The answer could not be inserted!" . mysql_error () . "\n");
>  }
>
>
>  mysql_close ($link);
>
> The query seems to work alright, no errors showing up and "The answer was
> successfully inserted!" displayed. However, the table is not updated and I
> cannot see why. The same happens on another page when I try to insert a
'Y'.
> This script was copied from a third page which works alright.
>
> I hope someone can help. I am going mad!!!.
> --
> Alex Francis
> Cameron Design
> 35, Drumillan Hill
> Greenock PA16 0XD
>
> Tel 01475 798106
> [EMAIL PROTECTED]
> http://www.camerondesign.co.uk
>
> This message is sent in confidence for the addressee only. It may contain
> legally privileged information.
> Unauthorised recipients are requested to preserve this confidentiality and
> to advise the sender
> immediately of any error in transmission.
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] left joins and mysql

2002-01-31 Thread Rick Emery

First, don't try to force JOIN to do something that is is not designed to
do.  Use WHERE to restrict your query.

Try:

SELECT t.team_name,t.flight_id,p.player_fname,p.player_lname

FROM team t 
LEFT JOIN player p ON 
t.team_id=p.player_team_id 

WHERE  t.flight_id=p.player_flight_id && p.player_status='captain'

ORDER by t.flight_id

-Original Message-
From: tom hilton [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 31, 2002 8:27 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] left joins and mysql


Hi,

I am trying to do a left join on a "master" table, but I don't want to pull
all the records from this table.  Can anyone tell me the syntax for using a
WHERE or equivalent on the master table before left joining the slave table?
Is this possible, or do I have to pull all the records from the master?  I
have a table called "team" that is the master, I want to join a table called
"player" on it, but I only want teams that belong to one particular league
(flight_id), not all teams (there are eight flights in the "team" table).
Below is the basic syntax I am using now, and it is pulling all the teams
from the team table, not just the teams where flight_id=1.  Is there
someplace after the "join" that I can restrict "team" records using a WHERE
statement?  Sorry if this is confusing.

$big_join=mysql_query

SELECT team.team_name,team.flight_id,player.player_fname,player.player_lname

FROM team left join player on team.flight_id=1 and
team.team_id=player.player_team_id and
team.flight_id=player.player_flight_id and player.player_status='captain'

ORDER by team.flight_id

or die("no friggin way")




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] Adding to an empty field

2002-01-31 Thread Rick Emery

What is $array[answer].  Should that be $array[$answer] ?

Second, change to:
$query = 'UPDATE submissions SET answers = \"".$array[$answer]."\" where id
= \"$id\"";

Ya gotta quote that text.

-Original Message-
From: Alex Francis [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 31, 2002 8:07 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Adding to an empty field


I have an empty field in a mysql database table which needs to have text
inserted when  my client answers an email. The code is as follows


$query = 'UPDATE submissions SET answers = "$array[answer]" where id = "$id"
';
 // $query = $query . " where id = $id ";

 // echo ("The query is: $query\n");

if (mysql_db_query ($dbname, $query, $link)){
  echo ("The answer was successfully inserted!\n");
 } else {
  echo ("The answer could not be inserted!" . mysql_error () . "\n");
 }


 mysql_close ($link);

The query seems to work alright, no errors showing up and "The answer was
successfully inserted!" displayed. However, the table is not updated and I
cannot see why. The same happens on another page when I try to insert a 'Y'.
This script was copied from a third page which works alright.

I hope someone can help. I am going mad!!!.
--
Alex Francis
Cameron Design
35, Drumillan Hill
Greenock PA16 0XD

Tel 01475 798106
[EMAIL PROTECTED]
http://www.camerondesign.co.uk

This message is sent in confidence for the addressee only. It may contain
legally privileged information.
Unauthorised recipients are requested to preserve this confidentiality and
to advise the sender
immediately of any error in transmission.



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] Adding to an empty field

2002-01-31 Thread Rick Emery

What is $array[answer].  Should that be $array[$answer] ?

-Original Message-
From: Alex Francis [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 31, 2002 8:07 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Adding to an empty field


I have an empty field in a mysql database table which needs to have text
inserted when  my client answers an email. The code is as follows


$query = 'UPDATE submissions SET answers = "$array[answer]" where id = "$id"
';
 // $query = $query . " where id = $id ";

 // echo ("The query is: $query\n");

if (mysql_db_query ($dbname, $query, $link)){
  echo ("The answer was successfully inserted!\n");
 } else {
  echo ("The answer could not be inserted!" . mysql_error () . "\n");
 }


 mysql_close ($link);

The query seems to work alright, no errors showing up and "The answer was
successfully inserted!" displayed. However, the table is not updated and I
cannot see why. The same happens on another page when I try to insert a 'Y'.
This script was copied from a third page which works alright.

I hope someone can help. I am going mad!!!.
--
Alex Francis
Cameron Design
35, Drumillan Hill
Greenock PA16 0XD

Tel 01475 798106
[EMAIL PROTECTED]
http://www.camerondesign.co.uk

This message is sent in confidence for the addressee only. It may contain
legally privileged information.
Unauthorised recipients are requested to preserve this confidentiality and
to advise the sender
immediately of any error in transmission.



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] left joins and mysql

2002-01-31 Thread tom hilton

Hi,

I am trying to do a left join on a "master" table, but I don't want to pull
all the records from this table.  Can anyone tell me the syntax for using a
WHERE or equivalent on the master table before left joining the slave table?
Is this possible, or do I have to pull all the records from the master?  I
have a table called "team" that is the master, I want to join a table called
"player" on it, but I only want teams that belong to one particular league
(flight_id), not all teams (there are eight flights in the "team" table).
Below is the basic syntax I am using now, and it is pulling all the teams
from the team table, not just the teams where flight_id=1.  Is there
someplace after the "join" that I can restrict "team" records using a WHERE
statement?  Sorry if this is confusing.

$big_join=mysql_query

SELECT team.team_name,team.flight_id,player.player_fname,player.player_lname

FROM team left join player on team.flight_id=1 and
team.team_id=player.player_team_id and
team.flight_id=player.player_flight_id and player.player_status='captain'

ORDER by team.flight_id

or die("no friggin way")




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Adding to an empty field

2002-01-31 Thread Miles Thompson

Assume query looks OK when you echo it? You're not seeing a literal "$id", 
are you?
Does an id exist for $id? Is it numeric or char?
Check mysql_affected_rows() - what does it return?

Miles Thompson

At 02:07 PM 1/31/2002 +, Alex Francis wrote:
>I have an empty field in a mysql database table which needs to have text
>inserted when  my client answers an email. The code is as follows
>
>
>$query = 'UPDATE submissions SET answers = "$array[answer]" where id = "$id"
>';
>  // $query = $query . " where id = $id ";
>
>  // echo ("The query is: $query\n");
>
>if (mysql_db_query ($dbname, $query, $link)){
>   echo ("The answer was successfully inserted!\n");
>  } else {
>   echo ("The answer could not be inserted!" . mysql_error () . "\n");
>  }
>
>
>  mysql_close ($link);
>
>The query seems to work alright, no errors showing up and "The answer was
>successfully inserted!" displayed. However, the table is not updated and I
>cannot see why. The same happens on another page when I try to insert a 'Y'.
>This script was copied from a third page which works alright.
>
>I hope someone can help. I am going mad!!!.
>--
>Alex Francis
>Cameron Design
>35, Drumillan Hill
>Greenock PA16 0XD
>
>Tel 01475 798106
>[EMAIL PROTECTED]
>http://www.camerondesign.co.uk
>
>This message is sent in confidence for the addressee only. It may contain
>legally privileged information.
>Unauthorised recipients are requested to preserve this confidentiality and
>to advise the sender
>immediately of any error in transmission.
>
>
>
>--
>PHP Database Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] Adding to an empty field

2002-01-31 Thread Alex Francis

I have an empty field in a mysql database table which needs to have text
inserted when  my client answers an email. The code is as follows


$query = 'UPDATE submissions SET answers = "$array[answer]" where id = "$id"
';
 // $query = $query . " where id = $id ";

 // echo ("The query is: $query\n");

if (mysql_db_query ($dbname, $query, $link)){
  echo ("The answer was successfully inserted!\n");
 } else {
  echo ("The answer could not be inserted!" . mysql_error () . "\n");
 }


 mysql_close ($link);

The query seems to work alright, no errors showing up and "The answer was
successfully inserted!" displayed. However, the table is not updated and I
cannot see why. The same happens on another page when I try to insert a 'Y'.
This script was copied from a third page which works alright.

I hope someone can help. I am going mad!!!.
--
Alex Francis
Cameron Design
35, Drumillan Hill
Greenock PA16 0XD

Tel 01475 798106
[EMAIL PROTECTED]
http://www.camerondesign.co.uk

This message is sent in confidence for the addressee only. It may contain
legally privileged information.
Unauthorised recipients are requested to preserve this confidentiality and
to advise the sender
immediately of any error in transmission.



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Using actual variable values after retreiving from db

2002-01-31 Thread Shooter

would unset() help @ all ? 

as in unset($thevariables) or do u need the variables ? 

Neil
- Original Message - 
From: Matthew Walden <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, January 31, 2002 10:34 PM
Subject: [PHP-DB] Using actual variable values after retreiving from db


> Hi,
> 
> I used to store SQL code for a transaction 
> directly in the PHP script which used it.  It was 
> stored as a string.  However, now I want to store 
> it in the database and assign it to the same 
> string that held it before.  Not very clear, so 
> heres an example :
> 
> Before:
> 
> $sql_variable = "select whatever from table";
> 
> Now:
> 
> $sql_variable = getSQL("whatever");
> 
> However, because the SQL contains variables which 
> were filled at run time, it does not parse the 
> variables when it assigns the string to the 
> variable name.  So I get errors because when the 
> SQL runs on the database it runs as :
> 
> select * from $table_name, 
> 
> rather than
> 
> select * from whatever
> 
> Hope I have explained this OK.  Are there any 
> solutions?  For example, force it to parse a 
> string for variables and assign their values 
> again?
> 
> Thanks in advance
> 
> Matt
> 
> -
> This mail sent through UK Online webmail
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] Using actual variable values after retreiving from db

2002-01-31 Thread Matthew Walden

Hi,

I used to store SQL code for a transaction 
directly in the PHP script which used it.  It was 
stored as a string.  However, now I want to store 
it in the database and assign it to the same 
string that held it before.  Not very clear, so 
heres an example :

Before:

$sql_variable = "select whatever from table";

Now:

$sql_variable = getSQL("whatever");

However, because the SQL contains variables which 
were filled at run time, it does not parse the 
variables when it assigns the string to the 
variable name.  So I get errors because when the 
SQL runs on the database it runs as :

select * from $table_name, 

rather than

select * from whatever

Hope I have explained this OK.  Are there any 
solutions?  For example, force it to parse a 
string for variables and assign their values 
again?

Thanks in advance

Matt

-
This mail sent through UK Online webmail

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] OK all you SQL gurus...

2002-01-31 Thread Mike Maltese

I'm trying to figure out a way to do a more efficient join on four tables.
The main table is products, with the other tables being common options for
the products. It's pretty well normalized, but am I doing these joins
properly or is there a more efficient way? This looks pretty ugly to me.

-

$q = "SELECT man.name as brand, category.proper as propername, products.*
  FROM manufacturers as man, products, category, type
  WHERE products.catid = category.catid AND man.manid = products.manid AND
type.type_id = products.type_id AND category.name = '".$category."'";

 if (isset($type)) {
$q .= " AND type.type = '".$type."'";
 }
-

Any suggestions, or am I ok on this?

Much thanks,
Mike



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]