Re: [PHP-DB] Help Needed with malfunctioning query

2006-02-25 Thread Murray @ PlanetThoughtful

On 26/02/2006 3:03 PM, Chris Payne wrote:

Hi there everyone,
 
This line of code USED TO WORK but now it gives me a Coudln't Execute Query

error:
 
$query2 = "SELECT word,def,photo MATCH(word,def) AGAINST ('$txtsearchword'

IN BOOLEAN MODE) AS m FROM dictionary WHERE MATCH(word,def) AGAINST
('$txtsearchword' IN BOOLEAN MODE) LIMIT $offset, $item_perpage";

I tried it with a basic $query2 = "SELECT * FROM dictionary"; to make sure
it wasn't something else that was broke and this is the problem above, it
used to work great and now it's on a live site after working great for 6
months and it suddenly doesn't work and I haven't touched anything !!!  the
server hasn't been updated so it's not that as it also does the same on my
local dev machine here, the only thing that happened was my co-worker did a
global find and replace with dreamweaver but that's all and I can't
personally see anything wrong with the above though I could be looking too
hard.
  


Should there be a comma between 'photo' and 'MATCH(word, def) etc'?

As in:
$query2 = "SELECT word,def,photo, MATCH(word,def) AGAINST 
('$txtsearchword' IN BOOLEAN MODE) AS m FROM dictionary WHERE 
MATCH(word,def) AGAINST ('$txtsearchword' IN BOOLEAN MODE) LIMIT 
$offset, $item_perpage";



Much warmth,

planetthoughtful
---
"Lost in thought"
http://www.planetthoughtful.org

"Urban legends, superstitions, ghost
stories and folklore"
http://www.ulblog.org

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



RE: [PHP-DB] HTML Tables in PHP...

2005-09-25 Thread Murray @ PlanetThoughtful
> How can I give a   with all of it's parameters in PHP in
> each
> of the cells there is a variable that gives me the data back but I can't
> get
> the table to show as it always gives me either this error "Parse error:
> parse error, unexpected T_LNUMBER, expecting ',' or ';' in
> C:\FoxServ\www\Dad\proofing\index.php on line 41" or this one when I don't
> put in the quotes "Parse error: parse error, unexpected '<', expecting ','
> or ';' in C:\FoxServ\www\Dad\proofing\index.php on line 41".

Hi Daryl,

Put double-quotes around the entire string, and use single-quotes around the
table property values etc. Something similar to:

echo "


Some stuff

";

Also, in the code you've posted you don't have a closing double-quote and
semi-colon at the end of:

> $nachricht="The licence doesn't exist please contact us!

This probably should be:

$nachricht="The licence doesn't exist please contact us!";

Much warmth,

Murray
---
"Lost in thought..."
http://www.planetthoughtful.org

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



RE: [PHP-DB] Highlighting data selected from one table that appear in another

2005-09-01 Thread Murray @ PlanetThoughtful
> mysql 4.0.25
> php 4.3.1
> 
> I seem to be unable to solve this problem without some help.
> 
> A webpage is to list all the clients in a  mysql " Client" table.  Each
> client has an an allocated clid.
> 
> Those clients who are listed, identified by their allocated clid, in a
> "Transactions" are to be highlighted in different ways according to
> progress of the transaction, the progress being determined on whether
> date values have been inserted into various fields.
> 
> Since mysql select joining the tables lists only the clients whose
> appear in both tables.
> 
> I have been attempting to create a temporary table inserting the data
> from "Client" and "Transactions"  and selecting from that but not
> successfully yet. But is this the way to go about it.
> 
> The scale is an anticipated 1000 clients per month of which an
> anticipated 800 will involve transactions
> 
> Louise

Hi Louise,

You should take a look at the LEFT JOIN syntax for SELECT statements.

http://dev.mysql.com/doc/mysql/en/join.html

Basically, you want 'all the results from table_a, and the relevant results
from table_b where table_a and table_b match.' You achieve this via using a
LEFT JOIN.

Regards,

Murray
---
"Lost in thought..."
http://www.planetthoughtful.org

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



RE: [PHP-DB] Need help with a tricky query

2005-05-20 Thread Murray @ PlanetThoughtful
> > SELECT g. * , concat( ref.fname,  ' ', ref.lname )  AS ref, concat(
> > ar1.fname,  ' ', ar1.lname )  AS ar1, concat( ar2.fname,  ' ', ar2.lname
> )
> > AS ar2, concat( fourth.fname,  ' ', fourth.lname )  AS fourth
> > FROM ( ( ( ( ( ( ( ( games g
> > RIGHT  OUTER  JOIN games_referees ref_ass ON ( g.id = ref_ass.gnum )  )
> > RIGHT  OUTER  JOIN people ref ON ( ref.login = ref_ass.referee )  )
> > RIGHT  OUTER  JOIN games_referees ar1_ass ON ( g.id = ar1_ass.gnum )  )
> > RIGHT  OUTER  JOIN people ar1 ON ( ar1.login = ar1_ass.referee )  )
> > RIGHT  OUTER  JOIN games_referees ar2_ass ON ( g.id = ar2_ass.gnum )  )
> > RIGHT  OUTER  JOIN people ar2 ON ( ar2.login = ar2_ass.referee )  )
> > RIGHT  OUTER  JOIN games_referees fourth_ass ON ( g.id = fourth_ass.gnum
> )
> > )
> > RIGHT  OUTER  JOIN people fourth ON ( fourth.login = fourth_ass.referee
> )
> > )
> > WHERE ref_ass.position =1 AND ar1_ass.position =2 AND ar2_ass.position
> =3
> > AND fourth_ass.position =4 AND g.date =  '2004-09-25'
> >
> > Any help would be greatly appreciated.
> 
> Hi Andy,
> 
> If no-one manages to find a solution for you right away, could you please
> supply some pseudo-data from the tables you are working with. Also, which
> db
> server application and version are you working with?
> 
> I'm sure a solution can be found, but I for one would be closer to helping
> you find it if I had a better idea of the structure of the tables involved
> and the data they contain.

One relatively simple way of dealing with a situation like this, presuming
that your tables look something like:

[games]
Recid, gameid, gamedesc, gamedate
1, 1, 'Game 1', '2005-01-01 00:00:00'
2, 2, 'Game 2', '2005-01-01 00:00:00'
3, 3, 'Game 3', '2005-01-02 00:00:00'
4, 4, 'Game 4', '2005-01-03 00:00:00'

[refs]
Recid, gameid, refname
1, 1, 'ref 1'
2, 1, 'ref 2'
3, 1, 'ref 3'
4, 2, 'ref 4'
5, 2, 'ref 5'
6, 2, 'ref 6'
7, 2, 'ref 7'
8, 3, 'ref 1'
9, 3, 'ref 7'
10, 3, 'ref 8'
11, 4, 'ref 8'

...would be to use the following query:

select g.gameid, g.gamedate, g.gamedesc, group_concat(r.refname order by
r.refname) from games g join refs r on g.gameid = r.gameid group by r.gameid

This makes use of mysql's group_concat() aggregate function to produce a
recordset like:

Gameid, gamedate, gamedesc, reflist
1, '2005-01-01 00:00:00', 'Game 1', 'ref 1,ref 2,ref 3'
2, '2005-01-01 00:00:00', 'Game 2', 'ref 4,ref 5,ref 6,ref 7'
3, '2005-01-02 00:00:00', 'Game 3', 'ref 1,ref 7,ref 8'
4, '2005-01-03 00:00:00', 'Game 4', 'ref 8'

Then you would simply use PHP's explode() function on the reflist field of
each record to populate an array with the names of the referees of each
game.

Note: I believe group_concat() is specific to MySQL and is only available in
versions 4.1.x and above.

Hope this is of some help.

Murray

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



RE: [PHP-DB] Need help with a tricky query

2005-05-20 Thread Murray @ PlanetThoughtful
> I'm trying to write a query that pulls details on a game record, as well
> as
> the officials assigned to the game (up to 4 officials may be assigned to
> each game, but that's not always the case).
> 
> Game details are in the games table, and assignments are in the
> games_referees table (which I alias as referee,ar1,ar2, and fourth).
> 
> Ultimately, I want all the games for a given date, and the referees
> assigned
> to them.  Below is the query I'm working with so far.  In its current
> state,
> it returns results only when a full crew is assigned to the game (referee,
> ar1,ar2, fourth).  The query is below:
> 
> SELECT g. * , concat( ref.fname,  ' ', ref.lname )  AS ref, concat(
> ar1.fname,  ' ', ar1.lname )  AS ar1, concat( ar2.fname,  ' ', ar2.lname )
> AS ar2, concat( fourth.fname,  ' ', fourth.lname )  AS fourth
> FROM ( ( ( ( ( ( ( ( games g
> RIGHT  OUTER  JOIN games_referees ref_ass ON ( g.id = ref_ass.gnum )  )
> RIGHT  OUTER  JOIN people ref ON ( ref.login = ref_ass.referee )  )
> RIGHT  OUTER  JOIN games_referees ar1_ass ON ( g.id = ar1_ass.gnum )  )
> RIGHT  OUTER  JOIN people ar1 ON ( ar1.login = ar1_ass.referee )  )
> RIGHT  OUTER  JOIN games_referees ar2_ass ON ( g.id = ar2_ass.gnum )  )
> RIGHT  OUTER  JOIN people ar2 ON ( ar2.login = ar2_ass.referee )  )
> RIGHT  OUTER  JOIN games_referees fourth_ass ON ( g.id = fourth_ass.gnum )
> )
> RIGHT  OUTER  JOIN people fourth ON ( fourth.login = fourth_ass.referee )
> )
> WHERE ref_ass.position =1 AND ar1_ass.position =2 AND ar2_ass.position =3
> AND fourth_ass.position =4 AND g.date =  '2004-09-25'
> 
> Any help would be greatly appreciated.

Hi Andy,

If no-one manages to find a solution for you right away, could you please
supply some pseudo-data from the tables you are working with. Also, which db
server application and version are you working with?

I'm sure a solution can be found, but I for one would be closer to helping
you find it if I had a better idea of the structure of the tables involved
and the data they contain.

Regards,

Murray

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



RE: [PHP-DB] database synchronization

2005-05-12 Thread Murray @ PlanetThoughtful

 
I have web based application running on php and mysql and installed on
multiple sites. The data on those sites need to be synchronized (to have
same data on every site after insert/update/delete action in each site).
Currently im using an ftp server to handle synchronization, im using batch
script to export and import data running on each site to the ftp server. but
it still is a tedious job that requires constant monitoring, i need to have
some kind of synchronization agent that can be installed on each site. Is
there any tools for that? 



SQLYog Enterprise has inbuilt MySQL synchronization. It's not free, however,
and may not suit your purposes.

I use it to keep my local development db current (or current as at the end
of each day) with record content from our production db without losing
structural changes I've made to local tables while working on new
functionality.

May be worth taking a look at: http://www.sqlyog.com

Murray

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



RE: [PHP-DB] Need some help

2005-05-11 Thread Murray @ PlanetThoughtful
> Sorry but this isn't working.  The variable $ttl_price is a calculation in
> my first script.  It stores the value of $Total_Price for all items.  I am
> trying to pass that to a new page.  It isn't a form that I'm working with,
> do I need to make it a form?  I would greatly appreciate any help you
> could
> offer.

The $_POST[] superglobal is only available to a page directly following a
page with a form on it, when the form's method set to 'POST'.

Id $ttl_price a single value or an array?

If you are not using a form, you could possibly pass the value on the query
string, then use $_GET[] in your target page to retrieve the value from the
query string. This doesn't require the presence of a form on your
originating page.

Otherwise, you could also use sessions to put the value into a session
cookie and then retrieve it from the target page, using the $_SESSION
superglobal.

How are you moving from the page in which the calculation is done to the
page in which you need the calculation? Ie, do you click on a button, a
link, do you redirect to the page etc?

Much warmth,

Murray 

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



RE: [PHP-DB] Institute

2004-11-09 Thread Murray @ PlanetThoughtful
> May you pls. suggest me a good institute for learning PHP AND MYSQL in and
> around Delhi or Noida (INDIA). preferably Noida.

I don't know what the availability of training is like in your area, but if
you find training difficult to find, there are several good textbooks that
take you from beginner to intermediate level in PHP / MySQL programming.

In particular, I thought "PHP and MySQL Development"
(http://www.amazon.com/exec/obidos/tg/detail/-/0672326728/qid=1099987465/sr=
1-3/ref=sr_1_3/102-3608246-4128963?v=glance&s=books) was particularly good,
but others on the list may be able to recommend more appropriate textbooks.

Book like this, coupled with the ability to ask questions in this and MySQL
lists, make a great way to learn the language / environment.

Much warmth,

Murray
http://www.planetthoughtful.org

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



RE: [PHP-DB] mysql_query

2004-10-12 Thread Murray @ PlanetThoughtful
Hi,

Unless you have 'register globals' on, are you retrieving the value of the
variables passed by your form from the $_GET or $_POST super variables
(whichever is appropriate)?

In other words, at the top of the page that is performing your insert query,
do you have lines such as:

$ime = $_GET['ime']; // (or, if your form is POSTing the data, $ime =
$_POST['ime'];)

>From what limited information you've included below it seems that perhaps
you aren't retrieving these values prior to attempting to insert them into
the table.

Please ignore this if your installation of PHP is running with 'register
globals' on.

Much warmth,

Murray

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of
[EMAIL PROTECTED]
Sent: Tuesday, 12 October 2004 10:15 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] mysql_query

hello,

I have a begining question.
I've got simple html form and php script, but insert doesn' t work. What is 
wrong in my insert mysql_query?

mysql_query( "insert into obiskovalci (ime, priimek, ulica, hstevilka, 
pstevilka, posta) values('$ime', '$priimek', '$ulica', '$hstevilka', 
'$pstevilka', '$posta')");

There is also id, which is auto_increment. After fill form and press Submit,
id 
is writen in table, but there is no other inputs. Nothing, except "id".

thanks for answers
BR, Balo

-- 
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] RE: [PHP] Lost in query... Trying to get output from query....

2004-10-11 Thread Murray @ PlanetThoughtful
Hi,

You need to loop through the returned recordset and use the returned
result(s).

Instead of:

$admin_get_options_result =
mysql_fetch_assoc($admin_get_options_results_reference);

Try:

While ($admin_get_options_result =
mysql_fetch_assoc($admin_get_options_results_reference)){

echo " The api# ".$admin_get_options_result["adminpageid"]."
allows you to ".$admin_get_options_result["description"].", and uses the
file ".$admin_get_options_result["filename"]."";
}

Mysql_free_result($admin_get_options_results_reference);

Hope this helps...

Much warmth,

Murray


-Original Message-
From: GH [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, 12 October 2004 12:59 AM
To: PHP General; [EMAIL PROTECTED]
Subject: [PHP] Lost in query... Trying to get output from query

Greetings:

 I am having a problem with trying to get data out of my mySql database.

I run my query which works fine and everything... 

I use: 

$admin_get_options_query_text = "Select * from adminpage";

$admin_get_options_results_reference =
mysql_query($admin_get_options_query_text,$db_access) or die("Admin
Get Options: ". mysql_error());

$admin_get_options_result =
mysql_fetch_assoc($admin_get_options_results_reference);


-

When I run the query in mysql directly the results are. 

mysql> Select * from adminpage;
+-++
--+
| adminpageid | file_name  | description
|
+-++
--+
| 101 | nycalertstatus.php | Change New York City Threat Alert
Status |
+-++
--+
1 row in set (0.00 sec)



my problem is that I would like to get that output into my php
codeI would like to have something that goes like this for each
record..

The api# $adminpageid allows you to $description, and uses the file
#file_name


can anyone please assist.

-- 
PHP General 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] Help: First Time Form with Sessions

2004-10-08 Thread Murray @ PlanetThoughtful
Hi Stuart,

session_start() has to be the first actual codeline in your page.

So:




Etc...

On the page  you're receiving the error on, move "session_start()" to the
first line executed in the script.

Much warmth,

Murray
http://www.planetthoughtful.org
Building a thoughtful planet,
One quirky comment at a time.


-Original Message-
From: Stuart Felenstein [mailto:[EMAIL PROTECTED] 
Sent: Saturday, 9 October 2004 1:57 AM
To: Bastien Koert; [EMAIL PROTECTED]
Subject: RE: [PHP-DB] Help: First Time Form with Sessions

See interspersed:
--- Bastien Koert <[EMAIL PROTECTED]> wrote:

> Hi Stu
> 
> 1. why not check it on every page, then if it fails
> the user won't need to 
> make it to the end and then have to go back to the
> beginning to fix 
> something minor.
> 
> 2. You could use hidden fields to pass the data back
> and for or just use a 
> session, otherwise the variables expire on that page

I think I'm stuck on sessions now :) .  So if there
were 3 pages and then a final 4th page where the
transactions to the database take place - without
passing the session variables around , they will still
be available on the 4th page ?

3 - Now I've run into an error: 
Warning: session_start(): Cannot send session cookie -
headers already sent by (output started at
/home/lurkkcom/public_html/Multi2Return.php:2) in
/home/lurkkcom/public_html/Multi2Return.php on line 3

Warning: session_start(): Cannot send session cache
limiter - headers already sent (output started at
/home/lurkkcom/public_html/Multi2Return.php:2) in
/home/lurkkcom/public_html/Multi2Return.php on line 3

On first page: 
I have session_start();

And on "Multi2Return.php" I have session_start();

I thought to continue session you need to put the
session_start function on each page.  If I remove
though , I get nothing.

Stuart

-- 
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] Recursively determine parent records?

2004-10-05 Thread Murray @ PlanetThoughtful
 

Hi All,

 

I have recordset that contains a hierarchical representation of records
where a record's [parentid] field contains the recid of the record 'above'
the current record.

 

A representation might look like this:

 

Recid, parentid, title

 

1, 0, Top level record

2, 0, Another top level record

3, 1, A record under the top level record

4, 3, Another level

5, 2, A record under the second top level record

 

If I have currently retrieved the record with recid of 4, I want to work out
the 'chain' of records that lead back to the top level record it has been
created under.

 

In this instance, that chain would look like:

 

4, 3, Another level

3, 1, A record under the top level record

1, 0, Top level record

 

I'm wondering if anyone can help me work out how to achieve this?

 

Many thanks in advance!

 

Much warmth,

 

Murray

  http://www.planetthoughtful.org

Building a thoughtful planet,

One quirky comment at a time.