[PHP-DB] Re: Error is SQL(works in phpMyAdmin)

2002-07-27 Thread JJ Harrison

Here is one line of my new query:
INSERT INTO article_keyword (aid,keyword,weight) VALUES (3, 'gases',
13.42282);

I get the same error:

You have an error in your SQL syntax near '; INSERT INTO article_keyword
(aid,keyword,weight) VALUES (3, 'gases', 13.42282)' at line 1


--
JJ Harrison
[EMAIL PROTECTED]
www.tececo.com



- Original Message -
From: Joni Järvinen [EMAIL PROTECTED]
To: JJ Harrison [EMAIL PROTECTED]
Sent: Saturday, July 27, 2002 3:26 PM
Subject: Re: [PHP-DB] Error is SQL(works in phpMyAdmin)


 Hi.

 The correct way is:

 INSERT INTO table VALUES (to what colums) 'data';

 Try reading PHP manual from mysql_query and from mySQL manual the INSERT
 statements format.

 HTH.

 -Joni

 - Original Message -
 From: JJ Harrison [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Saturday, July 27, 2002 6:07 AM
 Subject: [PHP-DB] Error is SQL(works in phpMyAdmin)


  I do my SQL in phpMyAdmin or at the command line and it works fine.
 
  When I try and do my query through PHP I get this(Source to show there
are
  no br etc in it):
 
  Query failed: INSERT INTO article_keyword VALUES (3, 'earth', 8.94855);
  INSERT INTO article_keyword VALUES (3, 'gases', 13.42282);
  INSERT INTO article_keyword VALUES (3, 'called', 8.94855);
  INSERT INTO article_keyword VALUES (3, 'atmosphere', 17.89709);
  INSERT INTO article_keyword VALUES (3, 'allows', 4.47427);
  INSERT INTO article_keyword VALUES (3, 'light', 6.71141);
  INSERT INTO article_keyword VALUES (3, 'pass', 4.47427);
  INSERT INTO article_keyword VALUES (3, 'absorbed', 4.47427);
  INSERT INTO article_keyword VALUES (3, 'earth\'s', 8.94855);
  INSERT INTO article_keyword VALUES (3, 'and', 26.84564);
  INSERT INTO article_keyword VALUES (3, 'converted', 4.47427);
  INSERT INTO article_keyword VALUES (3, 'heat', 4.47427);
  INSERT INTO article_keyword VALUES (3, 'energy.', 4.47427);
  INSERT INTO article_keyword VALUES (3, 'energy', 6.71141);
  INSERT INTO article_keyword VALUES (3, 'natural', 4.47427);
  INSERT INTO article_keyword VALUES (3, 'greenhouse', 29.08277);
  INSERT INTO article_keyword VALUES (3, 'effect', 6.71141);
  INSERT INTO article_keyword VALUES (3, 'car', 6.71141);
  INSERT INTO article_keyword VALUES (3, 'temperature', 6.71141);
  INSERT INTO article_keyword VALUES (3, 'inside', 4.47427);
  INSERT INTO article_keyword VALUES (3, '200', 4.47427);
  INSERT INTO article_keyword VALUES (3, 'years', 4.47427);
  INSERT INTO article_keyword VALUES (3, 'population', 4.47427);
  INSERT INTO article_keyword VALUES (3, 'six', 4.47427);
  INSERT INTO article_keyword VALUES (3, 'increase', 8.94855);
  INSERT INTO article_keyword VALUES (3, 'gas', 4.47427);
  INSERT INTO article_keyword VALUES (3, 'carbon', 4.47427);
  INSERT INTO article_keyword VALUES (3, 'concentrations', 4.47427);
  INSERT INTO article_keyword VALUES (3, 'temperatures', 4.47427);
  INSERT INTO article_keyword VALUES (3, 'lower', 6.71141);
  INSERT INTO article_keyword VALUES (3, 'causing', 4.47427);
  INSERT INTO article_keyword VALUES (3, 'warming', 8.94855);
  INSERT INTO article_keyword VALUES (3, 'our', 4.47427);
  INSERT INTO article_keyword VALUES (3, '(the', 4.47427);
  INSERT INTO article_keyword VALUES (3, 'troposphere)', 4.47427);
  INSERT INTO article_keyword VALUES (3, 'climate', 4.47427);
  INSERT INTO article_keyword VALUES (3, 'change', 4.47427);
  INSERT INTO article_keyword VALUES (3, 'ozone', 4.47427);
  brYou have an error in your SQL syntax near ';
  INSERT INTO article_keyword VALUES (3, 'gases', 13.42282);
  INSERT INTO article' at line 1
 
  why is it so?
 
 
  --
  JJ Harrison
  [EMAIL PROTECTED]
  www.tececo.com
 
 
 
  --
  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] select from two tables

2002-07-27 Thread Barry Rumsey

I have the following code:
$query = SELECT * FROM xoops_album,xoops_artist WHERE
xoops_album.artist_id = xoops_artist.artist_id; 
 $albumby = mysql_query($query) or die(Select Failed!);
 
echotdcenter;
if (mysql_num_rows($albumr)) {
while ($album = mysql_fetch_array($albumr))
{ 
echo ($album[album]);
echoi by ; echo ($albumby[xoops_artist.artist]); echoibr;
}
   echo /center/td;
}
What I'm trying to do is select the album title from one table ( this
works ok ) and get the artist name from another table ( this is the part
I can't get to work ).  I believe it has something to do with the code
above as the rest works ok. The result I end up with is below:
 
Waterloo by ( this is where I want to put the artist name)
 
 
Thanks for in help in advance.



RE: [PHP-DB] select from two tables

2002-07-27 Thread Herman Verkade


Well, I'm just a beginner myself, but I would say that:

 echoi by ; echo ($albumby[xoops_artist.artist]); echoibr;

should at least be:

 echoi by ; echo ($album[xoops_artist.artist]); echoibr;

or even:

 echoi by ; echo ($album[artist]); echoibr;

Hope this helps,

Herman

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




RE: [PHP-DB] select from two tables

2002-07-27 Thread Barry Rumsey

Ok I tired this but it did not help, but thank you.

-Original Message-
From: Herman Verkade [mailto:[EMAIL PROTECTED]] 
Sent: Sunday, 28 July 2002 1:18 a.m.
To: 'Barry Rumsey'
Cc: [EMAIL PROTECTED]
Subject: RE: [PHP-DB] select from two tables


Well, I'm just a beginner myself, but I would say that:

 echoi by ; echo ($albumby[xoops_artist.artist]); echoibr;

should at least be:

 echoi by ; echo ($album[xoops_artist.artist]); echoibr;

or even:

 echoi by ; echo ($album[artist]); echoibr;

Hope this helps,

Herman


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




Re: [PHP-DB] Error is SQL(works in phpMyAdmin)

2002-07-27 Thread Cornelia Boenigk

Hi

 You have an error in your SQL syntax near ';

^

As far as I know MySQL doesn't require a trailing *;* at the end of
the query.

Regards
Conni


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




Re: [PHP-DB] select from two tables

2002-07-27 Thread Cornelia Boenigk

Hi Barry

 $query = SELECT * FROM xoops_album,xoops_artist WHERE
 xoops_album.artist_id = xoops_artist.artist_id;

If you only need two fields, it is not necessary to retrieve all
fields

$query = SELECT  xoops_album.album, xoops_artist.artist
FROM xoops_album, xoops_artist
WHERE xoops_album.artist_id = xoops_artist.artist_id;

$albumby = mysql_query($query) or die(Select Failed!);


Your resultset contains then the only two required fields.

echotdcenter;
if (mysql_num_rows($albumr)) {
while ($album = mysql_fetch_array($albumr))   {
echo $album[album] iby $album[artist] /ibr;   // new
line
}
   echo /center/td;
 }

Hope it helps
Conni



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




Re: [PHP-DB] Error is SQL(works in phpMyAdmin)

2002-07-27 Thread JJ Harrison

It turns out phpMyAdmin actually splits up the queries and does them
singaly.


--
JJ Harrison
[EMAIL PROTECTED]
www.tececo.com

Cornelia Boenigk [EMAIL PROTECTED] wrote in message
00ef01c23580$2ed210c0$7f54fea9@zwerg98">news:00ef01c23580$2ed210c0$7f54fea9@zwerg98...
 Hi

  You have an error in your SQL syntax near ';

 ^

 As far as I know MySQL doesn't require a trailing *;* at the end of
 the query.

 Regards
 Conni




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




[PHP-DB] Re: SQL order by queries

2002-07-27 Thread David Robley

In article [EMAIL PROTECTED], 
[EMAIL PROTECTED] says...
 Can you d arithmetic division on two fields in an ORDER BY??
 
 eg
 SELECT * FROM table_name ORDER BY field1 / field2 DESC
 
 Can it be done?

Probably would work - give it a try :-) If you want to use the value you 
are ordering on, try 

ELECT * FROM table_name ORDER BY field1 / field2 AS something DESC

then you can retrieve the reuslt of the division as $something.

Cheers
-- 
David Robley
Temporary Kiwi!

Quod subigo farinam

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




[PHP-DB] Pulling a data from array of checkboxes

2002-07-27 Thread V Sharapov

I am passing a value of checkboxes in a form to a new page like this (see 
example here: http://www.gibsonusa.com/test/check/)
In a new page how can I pull the data from a MySQL database according to 
each value I passed from a previous page? In other words: Assume that the 
value of a checkbox equal to the ID of the record in a database. The value 
of checkbox 1 (for example) is 12345 and the value of checkbox2 is 67890. 
After passing those values to a new page how can I pull the rest of the 
information from a database for those values?




_
Chat with friends online, try MSN Messenger: http://messenger.msn.com


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




Re: [PHP-DB] Pulling a data from array of checkboxes

2002-07-27 Thread Cornelia Boenigk

Hi

 In a new page how can I pull the data from a MySQL database
according to
 each value I passed from a previous page?

Not tested, just an idea;-)

For example
$chk[0] contains 12345, the value of checkbox1
$chk[1] contains 67890, the value of checkbox2 and so on.

?php
foreach($chk as $key = $val) {
$sql = SELECT field1, field2 ... from yourtable WHERE ID = $val;
$res = mysql_query($sql);
if ($res) {
$row = mysql_fetch_row($res);
// do something with the data in the retrieved row
}
}

Greetings
Conni




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