Re: [PHP-DB] Correct Syntax?

2015-10-30 Thread chimurenga chimurenga
make vehicle licence the unique key

On 14 Oct 2015 00:28, "Karl DeSaulniers"  wrote:
>
> Quick question. Is this viable in MySQL?
>
> UNIQUE KEY `Vehicle_Name`
(`Vehicle_Make`+`Vehicle_Model`+`Vehicle_Style`+`Vehicle_License`)
>
> TIA
>
> Best,
>
> Karl DeSaulniers
> Design Drumm
> http://designdrumm.com
>
>
>


Re: [PHP-DB] Correct Syntax?

2015-10-13 Thread Roberto Spadim
instead of +, use ",'

2015-10-13 20:21 GMT-03:00 Karl DeSaulniers :

> Quick question. Is this viable in MySQL?
>
> UNIQUE KEY `Vehicle_Name`
> (`Vehicle_Make`+`Vehicle_Model`+`Vehicle_Style`+`Vehicle_License`)
>
> TIA
>
> Best,
>
> Karl DeSaulniers
> Design Drumm
> http://designdrumm.com
>
>
>
>


-- 
Roberto Spadim
SPAEmpresarial - Software ERP
Eng. Automação e Controle


Re: [PHP-DB] SQL syntax

2013-01-15 Thread Amit Tandon
SELECT orderid
FROM ORDERS_TABLE
WHERE orderstatus IN ( 'Cancelled', 'New', 'Denied',
'Expired' , 'Failed' , 'Pending' , 'Refunded' , 'Reversed' , 'Under Review'
, 'Voided') AND orderdate  '.mysqli_real_escape_string($
yesterday);

Another option would be to use either  of these functions

   - 
Find-in-sethttp://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_find-in-set.
   This is useful if your data type is SET/ENUM type
   - 
Fieldhttp://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_field


On Tue, Jan 15, 2013 at 2:59 PM, Karl DeSaulniers k...@designdrumm.comwrote:

 SELECT orderid
 FROM ORDERS_TABLE
 WHERE orderstatus = 'Cancelled' OR (orderstatus = ('New'
 OR 'Denied' OR 'Expired' OR 'Failed' OR 'Pending' OR 'Refunded' OR
 'Reversed' OR 'Under Review' OR 'Voided') AND orderdate 
 '.mysqli_real_escape_string($**yesterday).');





regds
amit

The difference between fiction and reality? Fiction has to make sense.


Re: [PHP-DB] SQL syntax

2013-01-15 Thread Karl DeSaulniers


On Jan 15, 2013, at 5:25 AM, Amit Tandon wrote:


SELECT orderid
   FROM ORDERS_TABLE
   WHERE orderstatus IN ( 'Cancelled', 'New', 'Denied',
'Expired' , 'Failed' , 'Pending' , 'Refunded' , 'Reversed' , 'Under  
Review'

, 'Voided') AND orderdate  '.mysqli_real_escape_string($
yesterday);

Another option would be to use either  of these functions

  - Find-in-sethttp://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_find-in-set 
.

  This is useful if your data type is SET/ENUM type
  - Fieldhttp://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_field 




On Tue, Jan 15, 2013 at 2:59 PM, Karl DeSaulniers k...@designdrumm.com 
wrote:



SELECT orderid
   FROM ORDERS_TABLE
   WHERE orderstatus = 'Cancelled' OR (orderstatus =  
('New'

OR 'Denied' OR 'Expired' OR 'Failed' OR 'Pending' OR 'Refunded' OR
'Reversed' OR 'Under Review' OR 'Voided') AND orderdate 
'.mysqli_real_escape_string($**yesterday).');






regds
amit

The difference between fiction and reality? Fiction has to make  
sense.



I am wanting Cancelled to be without a date check, but thanks for the  
suggestion.

I will try the IN option.

Thank you.

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com


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



Re: [PHP-DB] SELECT syntax

2011-10-13 Thread Karl DeSaulniers

Or something like this?
SELECT * FROM `Bible_trivia` WHERE answer=`answer`;
Then match the results to trivia_answer_1 in php to see if correct.

if($trivia_answer_1 == $results) {
... do this
}

or a switch

switch ($results) {
case $trivia_answer_1:
... do this
case $trivia_answer_2
... do this

Best,
Karl

On Oct 12, 2011, at 11:04 PM, Amit Tandon wrote:


SELECT `trivia_answer_`answer`` FROM `Bible_trivia`


Karl DeSaulniers
Design Drumm
http://designdrumm.com


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



Re: [PHP-DB] SELECT syntax

2011-10-13 Thread Karl DeSaulniers

Heh,
Thanks Karthik. Not my post.. :)
But your solution looks dead on..

Here you go Ron. Try this one.

Best,
Karl


On Oct 13, 2011, at 2:42 AM, Karthik S wrote:


Try this,

select
CASE answer
 when 1 then trivia_answer_1
 when 2 then trivia_answer_2
 when 3 then trivia_answer_3
 when 4 then trivia_answer_4
END as trivia_answers
from bible_trivia_table

On Thu, Oct 13, 2011 at 1:02 PM, Karl DeSaulniers k...@designdrumm.com 
 wrote:

Or something like this?
SELECT * FROM `Bible_trivia` WHERE answer=`answer`;
Then match the results to trivia_answer_1 in php to see if correct.

if($trivia_answer_1 == $results) {
... do this
}

or a switch

switch ($results) {
   case $trivia_answer_1:
   ... do this
   case $trivia_answer_2
   ... do this

Best,
Karl


On Oct 12, 2011, at 11:04 PM, Amit Tandon wrote:

SELECT `trivia_answer_`answer`` FROM `Bible_trivia`

Karl DeSaulniers
Design Drumm
http://designdrumm.com



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




Karl DeSaulniers
Design Drumm
http://designdrumm.com



RE: [PHP-DB] SELECT syntax

2011-10-12 Thread Toby Hart Dyke

Not terribly elegant, but this should work:

SELECT `trivia_answer_1` AS `trivia_answer` FROM `Bible_trivia` WHERE `answer`=1
UNION
SELECT `trivia_answer_2` AS `trivia_answer` FROM `Bible_trivia` WHERE `answer`=2
UNION
SELECT `trivia_answer_3` AS `trivia_answer` FROM `Bible_trivia` WHERE `answer`=3
UNION
SELECT `trivia_answer_4` AS `trivia_answer` FROM `Bible_trivia` WHERE 
`answer`=4;

I have to say that it's likely that your design may not be the most optimal. 
What happens if you want 5 answers? Or 6?

  Toby


-Original Message-
From: Ron Piggott [mailto:ron.pigg...@actsministries.org] 
Sent: Wednesday, October 12, 2011 3:25 PM
To: php-db@lists.php.net
Subject: [PHP-DB] SELECT syntax


In my Bible_Trivia table I have the columns

`trivia_answer_1`, `trivia_answer_2`, `trivia_answer_3`, `trivia_answer_4`, 
`answer`

`answer` is an integer always with a value of 1 to 4. Is there a way to use the 
value of `answer` to only select the correct trivia answer?

This doesn’t work, but this is the idea I am trying to achieve:

SELECT `trivia_answer_`answer`` FROM `Bible_trivia`

Thanks in advance,

Ron



www.TheVerseOfTheDay.info 


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



Re: [PHP-DB] SELECT syntax

2011-10-12 Thread Jack van Zanen
Hi

In Oracle (and maybe others) you can use


select case
when answer=1
then trivia_answer_1
when answer=2
then trivia_answer_2
when answer=3
then trivia_answer_3
when answer=4
then trivia_answer_4
else null
end answer
from bible_trivia_table
OR

You can select all of them and process in PHP, should not be too hard to
come up with a couple of lines of code to display only 1 variable  based on
the value of variable 5. Overhead should be pretty minimal as well
You'll be writing something to display a value anyway


Jack van Zanen

-
This e-mail and any attachments may contain confidential material for the
sole use of the intended recipient. If you are not the intended recipient,
please be aware that any disclosure, copying, distribution or use of this
e-mail or any attachment is prohibited. If you have received this e-mail in
error, please contact the sender and delete all copies.
Thank you for your cooperation


On Thu, Oct 13, 2011 at 6:24 AM, Ron Piggott ron.pigg...@actsministries.org
 wrote:


 In my Bible_Trivia table I have the columns

 `trivia_answer_1`, `trivia_answer_2`, `trivia_answer_3`, `trivia_answer_4`,
 `answer`

 `answer` is an integer always with a value of 1 to 4. Is there a way to use
 the value of `answer` to only select the correct trivia answer?

 This doesn’t work, but this is the idea I am trying to achieve:

 SELECT `trivia_answer_`answer`` FROM `Bible_trivia`

 Thanks in advance,

 Ron



 www.TheVerseOfTheDay.info http://www.theverseoftheday.info/



Re: [PHP-DB] SELECT syntax

2011-10-12 Thread Amit Tandon
select casehttp://dev.mysql.com/doc/refman/5.0/en/control-flow-functions.html
works in mysql also

regds
amit

The difference between fiction and reality? Fiction has to make sense.


On Thu, Oct 13, 2011 at 3:26 AM, Jack van Zanen j...@vanzanen.com wrote:

 Hi

 In Oracle (and maybe others) you can use


 select case
 when answer=1
 then trivia_answer_1
 when answer=2
 then trivia_answer_2
 when answer=3
 then trivia_answer_3
 when answer=4
 then trivia_answer_4
 else null
 end answer
 from bible_trivia_table
 OR

 You can select all of them and process in PHP, should not be too hard to
 come up with a couple of lines of code to display only 1 variable  based on
 the value of variable 5. Overhead should be pretty minimal as well
 You'll be writing something to display a value anyway


 Jack van Zanen

 -
 This e-mail and any attachments may contain confidential material for the
 sole use of the intended recipient. If you are not the intended recipient,
 please be aware that any disclosure, copying, distribution or use of this
 e-mail or any attachment is prohibited. If you have received this e-mail in
 error, please contact the sender and delete all copies.
 Thank you for your cooperation


 On Thu, Oct 13, 2011 at 6:24 AM, Ron Piggott 
 ron.pigg...@actsministries.org
  wrote:

 
  In my Bible_Trivia table I have the columns
 
  `trivia_answer_1`, `trivia_answer_2`, `trivia_answer_3`,
 `trivia_answer_4`,
  `answer`
 
  `answer` is an integer always with a value of 1 to 4. Is there a way to
 use
  the value of `answer` to only select the correct trivia answer?
 
  This doesn’t work, but this is the idea I am trying to achieve:
 
  SELECT `trivia_answer_`answer`` FROM `Bible_trivia`
 
  Thanks in advance,
 
  Ron
 
 
 
  www.TheVerseOfTheDay.info http://www.theverseoftheday.info/
 



Re: [PHP-DB] SELECT syntax

2011-10-12 Thread Amit Tandon
another 
examplehttp://mysql-tips.blogspot.com/2005/04/mysql-select-case-example.html

regds
amit

The difference between fiction and reality? Fiction has to make sense.


On Thu, Oct 13, 2011 at 9:34 AM, Amit Tandon att...@gmail.com wrote:

 select 
 casehttp://dev.mysql.com/doc/refman/5.0/en/control-flow-functions.html 
 works in mysql also
 
 regds
 amit

 The difference between fiction and reality? Fiction has to make sense.



 On Thu, Oct 13, 2011 at 3:26 AM, Jack van Zanen j...@vanzanen.com wrote:

 Hi

 In Oracle (and maybe others) you can use


 select case
 when answer=1
 then trivia_answer_1
 when answer=2
 then trivia_answer_2
 when answer=3
 then trivia_answer_3
 when answer=4
 then trivia_answer_4
 else null
 end answer
 from bible_trivia_table
 OR

 You can select all of them and process in PHP, should not be too hard to
 come up with a couple of lines of code to display only 1 variable  based
 on
 the value of variable 5. Overhead should be pretty minimal as well
 You'll be writing something to display a value anyway


 Jack van Zanen

 -
 This e-mail and any attachments may contain confidential material for the
 sole use of the intended recipient. If you are not the intended recipient,
 please be aware that any disclosure, copying, distribution or use of this
 e-mail or any attachment is prohibited. If you have received this e-mail
 in
 error, please contact the sender and delete all copies.
 Thank you for your cooperation


 On Thu, Oct 13, 2011 at 6:24 AM, Ron Piggott 
 ron.pigg...@actsministries.org
  wrote:

 
  In my Bible_Trivia table I have the columns
 
  `trivia_answer_1`, `trivia_answer_2`, `trivia_answer_3`,
 `trivia_answer_4`,
  `answer`
 
  `answer` is an integer always with a value of 1 to 4. Is there a way to
 use
  the value of `answer` to only select the correct trivia answer?
 
  This doesn’t work, but this is the idea I am trying to achieve:
 
  SELECT `trivia_answer_`answer`` FROM `Bible_trivia`
 
  Thanks in advance,
 
  Ron
 
 
 
  www.TheVerseOfTheDay.info http://www.theverseoftheday.info/
 





Re: [PHP-DB] Query syntax error?

2011-01-13 Thread jose
you have renamed places_data table to 'a'

2011/1/13 Harvey har...@harveyk.com:
 Hello,

 I have a query on a page that used to work fine, but is now generating an
 error.

 I assume that the version of php or mysql was updated on the webhost server
 or something like that?

 Here is the query:

 select count(places_data.place_id) as areacount, boroughs.borough_name as
 boroname, area.area_name as areaname, area.area_id as areaid
 from places_data a
 inner join boroughs b on a.area_fid = b.area_id
 inner join area c on c.borough_fid = b.borough_id
 where places_data.on_off_fid = 2
  . $cat_query . 
 group by c.area_name
 order by b.borough_name ASC, c.area_name ASC

 And here is the error message:

 Unknown column 'places_data.place_id' in 'field list'

 But place_id is a field in places_data table.

 Any ideas?

 Thanks!

 Harvey


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



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



RE: [PHP-DB] Query syntax error?

2011-01-13 Thread Harvey
Thanks, I got it working now, had to use the a/b/c thing a few times


-Original Message-
From: jose [mailto:jojap...@gmail.com] 
Sent: Thursday, January 13, 2011 9:52 AM
Cc: php-db@lists.php.net
Subject: Re: [PHP-DB] Query syntax error?

you have renamed places_data table to 'a'

2011/1/13 Harvey har...@harveyk.com:
 Hello,

 I have a query on a page that used to work fine, but is now generating an
 error.

 I assume that the version of php or mysql was updated on the webhost
server
 or something like that?

 Here is the query:

 select count(places_data.place_id) as areacount, boroughs.borough_name as
 boroname, area.area_name as areaname, area.area_id as areaid
 from places_data a
 inner join boroughs b on a.area_fid = b.area_id
 inner join area c on c.borough_fid = b.borough_id
 where places_data.on_off_fid = 2
  . $cat_query . 
 group by c.area_name
 order by b.borough_name ASC, c.area_name ASC

 And here is the error message:

 Unknown column 'places_data.place_id' in 'field list'

 But place_id is a field in places_data table.

 Any ideas?

 Thanks!

 Harvey


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



RE: [PHP-DB] UPDATE syntax

2007-12-13 Thread Gary Wardell
Hi,

I'm a beginner at PHP and MySql but a long time MS SQL server user.

Maybe it should be `advertisements`.`displayed` instead?

I just did a test and my Query browser doesn't like `interestcodes.id` but 
likes `interestcodes`.`id`.  Notice the quotes
(accents) on each side to the period.

Gary

 -Original Message-
 From: Ron Piggott [mailto:[EMAIL PROTECTED]
 Sent: Thu, December 13, 2007 7:20 PM
 To: php-db@lists.php.net
 Subject: [PHP-DB] UPDATE syntax


 Can anyone see something wrong with this syntax?

 UPDATE `advertisements` INNER JOIN `advertisements_rate_plans` ON
 `advertisements.rate_plan` = `advertisements_rate_plans.reference` SET
 `advertisements.displayed` = 0 WHERE `advertisements.start_date` =
 '2007-12-13' AND `advertisements.end_date` = '2007-12-13' AND
 `advertisements.approved` =1 AND `advertisements.paid` =1 AND
 `advertisements.displayed` =1 AND `advertisements_rate_plans.type` =2

 I am getting this error message:

 #1054 - Unknown column 'advertisements.displayed' in 'field list'

 There is a column called displayed in table advertisements.

 I am on the
 http://dev.mysql.com/doc/refman/5.0/en/update.html page and
 I am missing something.

 Ron

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



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



RE: [PHP-DB] UPDATE syntax

2007-12-13 Thread TG

Sorry, I didn't read the whole post, but wanted to point something out:
`interestcodes`.`id` is valid
interestcodes.id is valid
`interestcodes.id` is going to try to find a column named itnerestcodes.id 
somewhere with no table association.

The backticks/single-quotes/whatever-you-wanna-call-them are used to be 
explicit with a name.

-TG


- Original Message -
From: Gary Wardell [EMAIL PROTECTED]
To: php-db@lists.php.net
Date: Thu, 13 Dec 2007 19:33:57 -0500
Subject: RE: [PHP-DB] UPDATE syntax

 Hi,
 
 I'm a beginner at PHP and MySql but a long time MS SQL server user.
 
 Maybe it should be `advertisements`.`displayed` instead?
 
 I just did a test and my Query browser doesn't like `interestcodes.id` but 
 likes `interestcodes`.`id`.  Notice the quotes
 (accents) on each side to the period.
 
 Gary

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



Re: [PHP-DB] Query syntax

2007-09-15 Thread TG

SELECT * FROM table
WHERE listing_type LIKE '%$listing_type%'
AND (listing_approved = '1' OR listing_approved = '2')
ORDER BY name ASC

(notice the parentheses around the OR part of the clause)

or you can do this...

SELECT * FROM table
WHERE listing_type LIKE '%$listing_type%'
AND listing_approved IN ('1', '2')
ORDER BY name ASC

Good luck!

-TG

- Original Message -
From: ron.php [EMAIL PROTECTED]
To: php-db@lists.php.net
Date: Sat, 15 Sep 2007 15:04:59 -0400
Subject: [PHP-DB] Query syntax

 $query=SELECT * FROM table WHERE listing_type LIKE '%$listing_type%' AND  
 listing_approved = '1' OR listing_approved = '2' ORDER BY name ASC;
 
 My question is how can I search for records where listing_approved has a 
 value of either 1 or 2 (while in the same search I am searching for 
 listing_type --- ie other variables)
 
 Ron
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 

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



Re: [PHP-DB] Verifying syntax executed correctly

2006-10-17 Thread Chris

Ron Piggott (PHP) wrote:

If I give this command through PHP to mySQL

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( Unable to select database);
$query = UPDATE `table` SET `last_activity_field` = '$current_date'
WHERE `reference` = '$account_reference' LIMIT 1;;
mysql_query($query);
mysql_close();

is there a way to know if it executed successfully?


Two ways.

Firstly:

$result = mysql_query($query);
if (!$result) {
  echo Bad Query or something!:  . mysql_error() . br/;
}

will tell you quickly whether the query worked at all.

Secondly php.net/mysql_affected_rows will tell you how many rows that 
query changed.


Lastly I hope that's just an example otherwise you will have problems 
with sql injection.


You can either validate your data before (ie make sure current_date only 
contains what you expect) or change


$query = UPDATE `table` SET `last_activity_field` = '$current_date'
WHERE `reference` = '$account_reference' LIMIT 1;;

to use either mysql_escape_string or mysql_real_escape_string:

$query = UPDATE `table` SET `last_activity_field` = ' . 
mysql_escape_string($current_date) . '
WHERE `reference` = ' . mysql_escape_string($account_reference) . ' 
LIMIT 1;;


Depending on which version of php you have (RTM).

--
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP-DB] Verifying syntax executed correctly

2006-10-17 Thread Niel Archer
Hi

All of the MySQL functions you used, return FALSE on failure.

Niel

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



RE: [PHP-DB] Verifying syntax executed correctly

2006-10-17 Thread Bastien Koert


mysql_query($query) or die(mysql_error);

will give an error and stop the script if there is an issue, this also can 
work for the mysql_select_db


bastien


From: Ron Piggott (PHP) [EMAIL PROTECTED]
Reply-To: [EMAIL PROTECTED]
To: PHP DB php-db@lists.php.net
Subject: [PHP-DB] Verifying syntax executed correctly
Date: Tue, 17 Oct 2006 22:35:28 -0400


If I give this command through PHP to mySQL

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( Unable to select database);
$query = UPDATE `table` SET `last_activity_field` = '$current_date'
WHERE `reference` = '$account_reference' LIMIT 1;;
mysql_query($query);
mysql_close();

is there a way to know if it executed successfully?

Ron


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



Re: [PHP-DB] EXISTS syntax for SELECT INTO?

2006-10-11 Thread Chris

Tony Grimes wrote:

I have a script that creates a table copy using SELECT INTO, but I want it
to check if the new table already exists first. Does SQL support the EXISTS
keyword for SELECT INTO statements (I'm running PG7)?

If not, is there another way to do it in SQL? I'd rather not do it
programmatically.


You could probably do it with a subquery:

select into table1 from table2 where not in (select id from table1);

Hopefully that gets you started :)

--
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP-DB] If syntax

2005-10-02 Thread Jeffrey

See below...

Ron Piggott wrote:


Take a look at my if ( ) syntax line below.  I am wondering if I have it
wrong in same way.  What I am trying to achieve is if the alias the user
enters is already found in the database I want the words Alias already in
use to be shown on the screen; otherwise Unique alias to be shown on the
screen.

PRESENTLY alias already in use is what comes up all the time.

Ron


mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( Unable to select database);
$query=SELECT * FROM tablename WHERE alias LIKE '$alias%';

if (mysql_query($query))

{

echo Alias already in use;

} else {

echo Unique alias;

mysql_close();

}

 

Whether or not there are any matches, you will always have a database 
query - hence mysql_query($query) will always produce something


Instead you need to see if there are any  matches to your variable.

Also, SELECT * FROM [some_table] is tremendously inefficient when you 
only need to count results. You are basically calling up every result in 
your entire table just to see if a single column entry matches a variable.


I would suggest something like..

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( Unable to select database);
$query=SELECT alias FROM tablename WHERE alias LIKE '$alias%' LIMIT 1;

$result=(mysql_query($query))

if (mysql_num_rows($result)==1)

{

echo Alias already in use;

} else {

echo Unique alias;

mysql_close();

}
Good luck,

Jeffrey

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



RE: [PHP-DB] If syntax

2005-10-02 Thread Bastien Koert
you need to check the num of rows returned, since the query always(if it 
works) returns true



$result = mysql_query($query);
if (($result)(mysql_num_rows($result)==1))

{

echo Alias already in use;

} else {

echo Unique alias;

mysql_close();

}



Bastien



From: Ron Piggott [EMAIL PROTECTED]
Reply-To: Ron Piggott [EMAIL PROTECTED]
To: PHP DB php-db@lists.php.net
Subject: [PHP-DB] If syntax
Date: Sat, 1 Oct 2005 22:28:46 -0500

Take a look at my if ( ) syntax line below.  I am wondering if I have it
wrong in same way.  What I am trying to achieve is if the alias the user
enters is already found in the database I want the words Alias already in
use to be shown on the screen; otherwise Unique alias to be shown on the
screen.

PRESENTLY alias already in use is what comes up all the time.

Ron


mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( Unable to select database);
$query=SELECT * FROM tablename WHERE alias LIKE '$alias%';

if (mysql_query($query))

{

echo Alias already in use;

} else {

echo Unique alias;

mysql_close();

}

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



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



RE: [PHP-DB] If syntax

2005-10-02 Thread RaJeSh VeNkAtA

think this is wrong ... as it gives unique alias even if the query is not
executed ..


rajesh


On Sun, 2 Oct 2005, Bastien Koert wrote:

you need to check the num of rows returned, since the query always(if it 
works) returns true



$result = mysql_query($query);
if (($result)(mysql_num_rows($result)==1))

{

echo Alias already in use;

} else {

echo Unique alias;

mysql_close();

}



Bastien



From: Ron Piggott [EMAIL PROTECTED]
Reply-To: Ron Piggott [EMAIL PROTECTED]
To: PHP DB php-db@lists.php.net
Subject: [PHP-DB] If syntax
Date: Sat, 1 Oct 2005 22:28:46 -0500

Take a look at my if ( ) syntax line below.  I am wondering if I have it
wrong in same way.  What I am trying to achieve is if the alias the user
enters is already found in the database I want the words Alias already in
use to be shown on the screen; otherwise Unique alias to be shown on the
screen.

PRESENTLY alias already in use is what comes up all the time.

Ron


mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( Unable to select database);
$query=SELECT * FROM tablename WHERE alias LIKE '$alias%';

if (mysql_query($query))

{

echo Alias already in use;

} else {

echo Unique alias;

mysql_close();

}

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






--
*

You wouldn't know an OS if it hit you in the face ...

Linux Baby !

*

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



RE: [PHP-DB] If syntax

2005-10-02 Thread Mitchell, David
Please PMJI, but I'm new to PHP but have a little experience with databases, 
and I have a question:
 
Is there a particular reason that LIKE is used in the query?  Let's say you had 
the contrived alias value in the table, 'a', and one wanted to add the 
alias, '' (or fewer 'a's).  Wouldn't the query misreport that the alias, 
'', already exists?
 
I'm assuming that the number of characters in the alias can vary by some range 
(e.g., 3 to 10 characters), and that:
  SELECT alias FROM tablename WHERE alias LIKE '$alias%' LIMIT 1;

becomes:
  SELECT alias FROM tablename WHERE alias LIKE '%' LIMIT 1;

at execution-time.
 
Regards,
Dave

-Original Message- 
From: Jeffrey [mailto:[EMAIL PROTECTED] 
Sent: Sun 10/2/2005 3:32 AM 
To: 
Cc: PHP DB 
Subject: Re: [PHP-DB] If syntax



See below...

Ron Piggott wrote:

Take a look at my if ( ) syntax line below.  I am wondering if I have 
it
wrong in same way.  What I am trying to achieve is if the alias the 
user
enters is already found in the database I want the words Alias 
already in
use to be shown on the screen; otherwise Unique alias to be shown 
on the
screen.

PRESENTLY alias already in use is what comes up all the time.

Ron


mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( Unable to select database);
$query=SELECT * FROM tablename WHERE alias LIKE '$alias%';

if (mysql_query($query))

{

echo Alias already in use;

} else {

echo Unique alias;

mysql_close();

}

 

Whether or not there are any matches, you will always have a database
query - hence mysql_query($query) will always produce something

Instead you need to see if there are any  matches to your variable.

Also, SELECT * FROM [some_table] is tremendously inefficient when you
only need to count results. You are basically calling up every result in
your entire table just to see if a single column entry matches a 
variable.

I would suggest something like..

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( Unable to select database);
$query=SELECT alias FROM tablename WHERE alias LIKE '$alias%' LIMIT 1;

$result=(mysql_query($query))

 if (mysql_num_rows($result)==1)

{

echo Alias already in use;

} else {

echo Unique alias;

mysql_close();

}
Good luck,

Jeffrey

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php 
 
NOTICE: This E-mail may contain confidential information. If you are not
the addressee or the intended recipient please do not read this E-mail
and please immediately delete this e-mail message and any attachments
from your workstation or network mail system. If you are the addressee
or the intended recipient and you save or print a copy of this E-mail,
please place it in an appropriate file, depending on whether
confidential information is contained in the message.

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



RE: [PHP-DB] If syntax

2005-10-02 Thread Mitchell, David
Actually, if I had spent more time thinking about it, I could have come up with 
an example less contrived than the alias, ''.  Let's say the first entry in 
the table is the alias, 'williamson.'  Based on the current query, there can be 
no:
 
  'williams'
  'william'
  'willi'
  'will'
 
My previously stated assumptions still apply.  Of course, if the first entry is 
'will,' there could be a 'willi,' etc.
 
Regards,
Dave
 

-Original Message- 
From: Mitchell, David 
Sent: Sun 10/2/2005 11:11 AM 
To: php-db@lists.php.net 
Cc: 
Subject: RE: [PHP-DB] If syntax



Please PMJI, but I'm new to PHP but have a little experience with 
databases, and I have a question:

Is there a particular reason that LIKE is used in the query?  Let's say 
you had the contrived alias value in the table, 'a', and one wanted to add 
the alias, '' (or fewer 'a's).  Wouldn't the query misreport that the 
alias, '', already exists?

I'm assuming that the number of characters in the alias can vary by 
some range (e.g., 3 to 10 characters), and that:
  SELECT alias FROM tablename WHERE alias LIKE '$alias%' LIMIT 1;

becomes:
  SELECT alias FROM tablename WHERE alias LIKE '%' LIMIT 1;

at execution-time.

Regards,
Dave

-Original Message-
From: Jeffrey [mailto:[EMAIL PROTECTED]
Sent: Sun 10/2/2005 3:32 AM
To:
Cc: PHP DB
Subject: Re: [PHP-DB] If syntax
   
   

See below...
   
Ron Piggott wrote:
   
Take a look at my if ( ) syntax line below.  I am wondering if 
I have it
wrong in same way.  What I am trying to achieve is if the 
alias the user
enters is already found in the database I want the words 
Alias already in
use to be shown on the screen; otherwise Unique alias to be 
shown on the
screen.

PRESENTLY alias already in use is what comes up all the time.

Ron


mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( Unable to select 
database);
$query=SELECT * FROM tablename WHERE alias LIKE '$alias%';

if (mysql_query($query))

{

echo Alias already in use;

} else {

echo Unique alias;

mysql_close();

}



Whether or not there are any matches, you will always have a 
database
query - hence mysql_query($query) will always produce something
   
Instead you need to see if there are any  matches to your 
variable.
   
Also, SELECT * FROM [some_table] is tremendously inefficient 
when you
only need to count results. You are basically calling up every 
result in
your entire table just to see if a single column entry matches 
a variable.
   
I would suggest something like..
   
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( Unable to select 
database);
$query=SELECT alias FROM tablename WHERE alias LIKE '$alias%' 
LIMIT 1;
   
$result=(mysql_query($query))
   
 if (mysql_num_rows($result)==1)
   
{
   
echo Alias already in use;
   
} else {
   
echo Unique alias;
   
mysql_close();
   
}
Good luck,
   
Jeffrey
   
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

NOTICE: This E-mail may contain confidential information. If you are not
the addressee or the intended recipient please do not read this E-mail
and please immediately delete this e-mail message and any attachments
from your workstation or network mail system. If you are the addressee
or the intended recipient and you save or print a copy of this E-mail,
please place it in an appropriate file, depending on whether
confidential information is contained in the message

RE: [PHP-DB] If syntax

2005-10-02 Thread Bastien Koert

true, i suppose,

A better example would be

$result = mysql_query($query);
if ($result){
 if (mysql_num_rows($result)0)
 {

   echo Alias already in use;

 } else {

   echo Unique alias;
 }
}else{

 echo  db error:.mysql_error();
}
mysql_close();



bastien


From: RaJeSh VeNkAtA [EMAIL PROTECTED]
To: Bastien Koert [EMAIL PROTECTED]
CC: [EMAIL PROTECTED], php-db@lists.php.net
Subject: RE: [PHP-DB] If syntax
Date: Sun, 2 Oct 2005 22:25:16 +0530 (IST)

think this is wrong ... as it gives unique alias even if the query is not
executed ..


rajesh


On Sun, 2 Oct 2005, Bastien Koert wrote:

you need to check the num of rows returned, since the query always(if it 
works) returns true



$result = mysql_query($query);
if (($result)(mysql_num_rows($result)==1))

{

echo Alias already in use;

} else {

echo Unique alias;

mysql_close();

}



Bastien



From: Ron Piggott [EMAIL PROTECTED]
Reply-To: Ron Piggott [EMAIL PROTECTED]
To: PHP DB php-db@lists.php.net
Subject: [PHP-DB] If syntax
Date: Sat, 1 Oct 2005 22:28:46 -0500

Take a look at my if ( ) syntax line below.  I am wondering if I have it
wrong in same way.  What I am trying to achieve is if the alias the user
enters is already found in the database I want the words Alias already 
in
use to be shown on the screen; otherwise Unique alias to be shown on 
the

screen.

PRESENTLY alias already in use is what comes up all the time.

Ron


mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( Unable to select database);
$query=SELECT * FROM tablename WHERE alias LIKE '$alias%';

if (mysql_query($query))

{

echo Alias already in use;

} else {

echo Unique alias;

mysql_close();

}

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






--
*

You wouldn't know an OS if it hit you in the face ...

Linux Baby !

*

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



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



Re: [PHP-DB] If syntax

2005-10-01 Thread RaJeSh VeNkAtA

i think for unique alias u have keep

alias='$alias' ??

and also if statement  will always be true as the mysql statement is 
always correct and will be executed .
U have to check the result of query for whether there 
r ne aliases or not ...



On Sat, 1 Oct 2005, Ron Piggott wrote:


Take a look at my if ( ) syntax line below.  I am wondering if I have it
wrong in same way.  What I am trying to achieve is if the alias the user
enters is already found in the database I want the words Alias already in
use to be shown on the screen; otherwise Unique alias to be shown on the
screen.

PRESENTLY alias already in use is what comes up all the time.

Ron


mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( Unable to select database);
$query=SELECT * FROM tablename WHERE alias LIKE '$alias%';

if (mysql_query($query))

{

echo Alias already in use;

} else {

echo Unique alias;

mysql_close();

}




--
*

You wouldn't know an OS if it hit you in the face ...

Linux Baby !

*

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



Re: [PHP-DB] MySql syntax error using PHPWiki

2004-06-10 Thread Mikhail U. Petrov
Hi!
You missed table definition:
 ... FROM my_table where ...


Wednesday, June 9, 2004, 12:57:02 PM, PHPDiscuss wrote:

PPNaml Greetings,

PPNaml I'm trying to set up a PHPWiki using Apache 2.0.49, PHP 4.3.7, PEAR 4.1.0,
PPNaml and PHPWiki 1.3.10.

PPNaml I get this error when trying to load index.php:

PPNaml C:\Program Files\Apache
PPNaml Group\Apache2\htdocs\lib\WikiDB\backend\PearDB.php:778: Fatal[256]:
PPNaml wikidb_backend_mysql: fatal database error

PPNaml DB Error: syntax error 
PPNaml (SELECT sess_data FROM WHERE sess_id='8e7d43511c4184e42da9ed552e431332'
PPNaml [nativecode=You have an error in your SQL syntax. Check the manual that
PPNaml corresponds to your MySQL server version for the right syntax to use near
PPNaml 'WHERE sess_id='8e7d43511c4184e42da9ed552e431332'' at line 1])

PPNaml It seems that the SQL syntax is incorrect as no table is included in the
PPNaml SQL statement. Is it something to do with adding a 'prefix' = '', line
PPNaml to $DBParams in index.php? Is it something else entirely?

PPNaml Any help is appreciated.

PPNaml James.



-- 
Best regards,
Mikhail U. Petrov
mailto:[EMAIL PROTECTED]

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



RE: [PHP-DB] Oracle syntax

2004-06-10 Thread Marie Osypian

It can be found here:

http://us3.php.net/manual/en/ref.oracle.php

MAO
-Original Message-
From: Rafi Sheikh [mailto:[EMAIL PROTECTED] 
Sent: Thursday, June 10, 2004 9:33 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Oracle syntax


Hi list.  I am a newbie and would like to ask if anyone could give me
the proper syntax for connecting with oracle DB.  For example with MySQL
it is: mysql_connect..., mysql_query... For MS SQL Server:
mssql_connect..., mssql_query...


What would be for oracle?

TIA

RS


This e-mail, including attachments, may include confidential and/or
proprietary information, and may be used only by the person or entity to
which it is addressed. If the reader of this e-mail is not the intended
recipient or his or her authorized agent, the reader is hereby notified
that any dissemination, distribution or copying of this e-mail is
prohibited. If you have received this e-mail in error, please notify the
sender by replying to this message and delete this e-mail immediately.

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

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



Re: [PHP-DB] Oracle syntax

2004-06-10 Thread Christopher Jones
Rafi Sheikh wrote:
Hi list.  I am a newbie and would like to ask if anyone could give me the
proper syntax for connecting with oracle DB.  For example with MySQL it is:
mysql_connect..., mysql_query...
For MS SQL Server:
mssql_connect..., mssql_query...
There are various examples in the PHP documentation of the oci8 functions
at http://www.php.net/manual/en/ref.oci8.php  (The oci8 functions are preferred to 
the
older oracle functions)
There are a couple of Oracle-PHP FAQ's on 
http://otn.oracle.com/tech/opensource/index.html.
For a specific connection example see 
http://otn.oracle.com/tech/opensource/php_faq.html#CONNECT
Chris
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] sql syntax error

2003-01-29 Thread 1LT John W. Holmes

- Original Message -
From: Addison Ellis [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, January 28, 2003 10:46 PM
Subject: [PHP-DB] sql syntax error


 hello,
 i can not pinpoint this. your time and help is very much
 appreciated. best, addison

 Error:
   id=, HTTP_POST_VARS=Array, key=, value=, category=, subcategory=,
 [EMAIL PROTECTED]
 Error in query: insert into ads values

(year,make,model,color,mileage,condition,price,other,contact,next_,,created)
 values ('',,NOW()),Error:You have an error in your SQL syntax near
 'created) values ('',,NOW())' at line 1

 Code:
 else
   {
  foreach($HTTP_POST_VARS as $column_name = $column_value)

  $column_names .= $column_name . ',';
  $column_values .= '$column_values',;

  $query = insert into ads values ($column_names,created)
values ($column_values,NOW());
  $result = mysql_query($query)
 or die (Error in query: $query,Error:
.mysql_error());
  }

Try this:

foreach($HTTP_POST_VARS as $column_name = $column_value)
{
  $column_names .= $column_name . ',';
  $column_values .= '$column_value',;
 }
  $query = insert into ads values ($column_names created)
values ($column_values NOW());
  $result = mysql_query($query)
 or die (Error in query: $query,Error:
.mysql_error());

I still don't think it's going to work for you. do you really have a column
called 'next_' in your table? It's probably the button you pressed to submit
the form, which is in HTTP_POST_VARS, but I don't see a reason it would be
in your table...

---John Holmes...


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




Re: [PHP-DB] search syntax

2002-07-21 Thread Tony

Try break up the query, like:

WHERE (column1 LIKE '%$search%' OR column2 LIKE '%$search%' OR column3 LIKE
'%$search%') AND ...

Tony S. Wu


Matthew K. Gold at [EMAIL PROTECTED] wrote:

 hi everyone,
 
 I'm writing the code to make my mysql database searchable.  I can search two
 columns, but I seem to have problems when I try to search three.
 
 In the SELECT statement, this WHERE statement works:  WHERE column1 OR
 column2 LIKE '%$search%' AND...
 
 This WHERE statement doesn't work:  WHERE column1 OR column2 OR column3 LIKE
 '%$search%' AND ...
 
 I'm obviously having a syntax problem...Thanks in advance for your help.
 And in case any of this is confusing, I'll include the real code below.
 
 Thanks,
 
 Matt
 
 
 $get_data = select course.CourseNumber, course.CourseTitle,
 concat(prof.ProfFName, \ \, prof.ProfLName), instit.InstitName,
 disc.DiscName, course.Format from course, disc, instit, prof where
 course.CourseTitle or course.CourseDesc or disc.DiscName like '%$search%'
 and course.DiscID = disc.DiscID and course.InstitID = instit.InstitID and
 course.ProfID = prof.ProfID order by $orderby;
 
 
 
 
 




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




Re: [PHP-DB] search syntax

2002-07-21 Thread Matthew K. Gold

Great--it works now.  Thanks very much, Tony.  I appreciate your help.

best,

Matt

- Original Message -
From: Tony [EMAIL PROTECTED]
To: Matthew K. Gold [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Monday, July 22, 2002 1:01 AM
Subject: Re: [PHP-DB] search syntax


 Try break up the query, like:

 WHERE (column1 LIKE '%$search%' OR column2 LIKE '%$search%' OR column3
LIKE
 '%$search%') AND ...

 Tony S. Wu


 Matthew K. Gold at [EMAIL PROTECTED] wrote:

  hi everyone,
 
  I'm writing the code to make my mysql database searchable.  I can search
two
  columns, but I seem to have problems when I try to search three.
 
  In the SELECT statement, this WHERE statement works:  WHERE column1 OR
  column2 LIKE '%$search%' AND...
 
  This WHERE statement doesn't work:  WHERE column1 OR column2 OR column3
LIKE
  '%$search%' AND ...
 
  I'm obviously having a syntax problem...Thanks in advance for your help.
  And in case any of this is confusing, I'll include the real code below.
 
  Thanks,
 
  Matt
 
 
  $get_data = select course.CourseNumber, course.CourseTitle,
  concat(prof.ProfFName, \ \, prof.ProfLName), instit.InstitName,
  disc.DiscName, course.Format from course, disc, instit, prof where
  course.CourseTitle or course.CourseDesc or disc.DiscName like
'%$search%'
  and course.DiscID = disc.DiscID and course.InstitID = instit.InstitID
and
  course.ProfID = prof.ProfID order by $orderby;
 
 
 
 
 





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




RE: [PHP-DB] Mysql syntax error - phpMyAdmin ??

2002-07-10 Thread Ryan Jameson (USA)

desc is a key word. :-\

-Original Message-
From: Michael Zornek [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, July 10, 2002 10:50 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Mysql syntax error - phpMyAdmin ??


I was using phpMyAdmin to do an export from one machine to another and on
import I got an error:

 Error
 
 SQL-query :  
 
 CREATE TABLE hospital (
 id smallint(5) unsigned NOT NULL auto_increment,
 heath_system_id smallint(5) unsigned default NULL,
 name_long tinytext NOT NULL,
 name_short tinytext,
 logo_file_loc text,
 desc text,
 photo text,
 address1 tinytext,
 address2 tinytext,
 city tinytext,
 state tinytext,
 zip smallint(5) unsigned zerofill default NULL,
 phone tinytext,
 repay_percent tinyint(3) unsigned default NULL,
 url text,
 job_page_url text,
 num_nurses smallint(5) unsigned default NULL,
 active enum('yes','no') NOT NULL default 'yes',
 number_of_beds smallint(5) unsigned NOT NULL default '0',
 type tinytext NOT NULL,
 PRIMARY KEY  (id),
 KEY zip (zip)
 ) TYPE=MyISAM
 
 MySQL said: 
 
 You have an error in your SQL syntax near 'desc text,
 photo text,
 address1 tinytext,
 address2 tinytext,
 city ti' at line 7

What's the problem??? My db seems to find on the other machine?

~ Mike
-- 
Mike Zornek | Project Leader
Apple Student Developers
The Insanely Great Site with the Insanely Long URL
http://www.applestudentdevelopers.org

Personal Site: 
http://www.mikezornek.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




RE: [PHP-DB] Mysql syntax error - phpMyAdmin ??

2002-07-10 Thread Ryan Jameson (USA)

Try [desc]

-Original Message-
From: Ryan Jameson (USA) 
Sent: Wednesday, July 10, 2002 10:51 AM
To: [EMAIL PROTECTED]
Subject: RE: [PHP-DB] Mysql syntax error - phpMyAdmin ??


desc is a key word. :-\

-Original Message-
From: Michael Zornek [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, July 10, 2002 10:50 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Mysql syntax error - phpMyAdmin ??


I was using phpMyAdmin to do an export from one machine to another and on
import I got an error:

 Error
 
 SQL-query :  
 
 CREATE TABLE hospital (
 id smallint(5) unsigned NOT NULL auto_increment,
 heath_system_id smallint(5) unsigned default NULL,
 name_long tinytext NOT NULL,
 name_short tinytext,
 logo_file_loc text,
 desc text,
 photo text,
 address1 tinytext,
 address2 tinytext,
 city tinytext,
 state tinytext,
 zip smallint(5) unsigned zerofill default NULL,
 phone tinytext,
 repay_percent tinyint(3) unsigned default NULL,
 url text,
 job_page_url text,
 num_nurses smallint(5) unsigned default NULL,
 active enum('yes','no') NOT NULL default 'yes',
 number_of_beds smallint(5) unsigned NOT NULL default '0',
 type tinytext NOT NULL,
 PRIMARY KEY  (id),
 KEY zip (zip)
 ) TYPE=MyISAM
 
 MySQL said: 
 
 You have an error in your SQL syntax near 'desc text,
 photo text,
 address1 tinytext,
 address2 tinytext,
 city ti' at line 7

What's the problem??? My db seems to find on the other machine?

~ Mike
-- 
Mike Zornek | Project Leader
Apple Student Developers
The Insanely Great Site with the Insanely Long URL
http://www.applestudentdevelopers.org

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




Re: [PHP-DB] Mysql syntax error - phpMyAdmin ??

2002-07-10 Thread Chip Atkinson

I can't say for sure, but perhaps desc is a reserved word, short for
describe.  What happens if you say something like description?

Chip
On Wed, 10 Jul 2002, Michael Zornek wrote:

 I was using phpMyAdmin to do an export from one machine to another and on
 import I got an error:

  Error
 
  SQL-query :
 
  CREATE TABLE hospital (
  id smallint(5) unsigned NOT NULL auto_increment,
  heath_system_id smallint(5) unsigned default NULL,
  name_long tinytext NOT NULL,
  name_short tinytext,
  logo_file_loc text,
  desc text,
  photo text,
  address1 tinytext,
  address2 tinytext,
  city tinytext,
  state tinytext,
  zip smallint(5) unsigned zerofill default NULL,
  phone tinytext,
  repay_percent tinyint(3) unsigned default NULL,
  url text,
  job_page_url text,
  num_nurses smallint(5) unsigned default NULL,
  active enum('yes','no') NOT NULL default 'yes',
  number_of_beds smallint(5) unsigned NOT NULL default '0',
  type tinytext NOT NULL,
  PRIMARY KEY  (id),
  KEY zip (zip)
  ) TYPE=MyISAM
 
  MySQL said:
 
  You have an error in your SQL syntax near 'desc text,
  photo text,
  address1 tinytext,
  address2 tinytext,
  city ti' at line 7

 What's the problem??? My db seems to find on the other machine?

 ~ Mike
 --
 Mike Zornek | Project Leader
 Apple Student Developers
 The Insanely Great Site with the Insanely Long URL
 http://www.applestudentdevelopers.org

 Personal Site:
 http://www.mikezornek.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




Re: [PHP-DB] Mysql syntax error - phpMyAdmin ??

2002-07-10 Thread Martin Clifford

DESC is a reserved word in SQL, standing for Descending Order.  That is why you can't 
use it as a table column name.

HTH

Martin

 Michael Zornek [EMAIL PROTECTED] 07/10/02 12:49PM 
I was using phpMyAdmin to do an export from one machine to another and on
import I got an error:

 Error
 
 SQL-query :  
 
 CREATE TABLE hospital (
 id smallint(5) unsigned NOT NULL auto_increment,
 heath_system_id smallint(5) unsigned default NULL,
 name_long tinytext NOT NULL,
 name_short tinytext,
 logo_file_loc text,
 desc text,
 photo text,
 address1 tinytext,
 address2 tinytext,
 city tinytext,
 state tinytext,
 zip smallint(5) unsigned zerofill default NULL,
 phone tinytext,
 repay_percent tinyint(3) unsigned default NULL,
 url text,
 job_page_url text,
 num_nurses smallint(5) unsigned default NULL,
 active enum('yes','no') NOT NULL default 'yes',
 number_of_beds smallint(5) unsigned NOT NULL default '0',
 type tinytext NOT NULL,
 PRIMARY KEY  (id),
 KEY zip (zip)
 ) TYPE=MyISAM
 
 MySQL said: 
 
 You have an error in your SQL syntax near 'desc text,
 photo text,
 address1 tinytext,
 address2 tinytext,
 city ti' at line 7

What's the problem??? My db seems to find on the other machine?

~ Mike
-- 
Mike Zornek | Project Leader
Apple Student Developers
The Insanely Great Site with the Insanely Long URL
http://www.applestudentdevelopers.org 

Personal Site: 
http://www.mikezornek.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




RE: [PHP-DB] Mysql syntax error - phpMyAdmin ??

2002-07-10 Thread Ryan Jameson (USA)

Sorry, [desc] won't work either. :-(





-Original Message-
From: Chip Atkinson [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, July 10, 2002 10:54 AM
To: Michael Zornek
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Mysql syntax error - phpMyAdmin ??


I can't say for sure, but perhaps desc is a reserved word, short for
describe.  What happens if you say something like description?

Chip
On Wed, 10 Jul 2002, Michael Zornek wrote:

 I was using phpMyAdmin to do an export from one machine to another and on
 import I got an error:

  Error
 
  SQL-query :
 
  CREATE TABLE hospital (
  id smallint(5) unsigned NOT NULL auto_increment,
  heath_system_id smallint(5) unsigned default NULL,
  name_long tinytext NOT NULL,
  name_short tinytext,
  logo_file_loc text,
  desc text,
  photo text,
  address1 tinytext,
  address2 tinytext,
  city tinytext,
  state tinytext,
  zip smallint(5) unsigned zerofill default NULL,
  phone tinytext,
  repay_percent tinyint(3) unsigned default NULL,
  url text,
  job_page_url text,
  num_nurses smallint(5) unsigned default NULL,
  active enum('yes','no') NOT NULL default 'yes',
  number_of_beds smallint(5) unsigned NOT NULL default '0',
  type tinytext NOT NULL,
  PRIMARY KEY  (id),
  KEY zip (zip)
  ) TYPE=MyISAM
 
  MySQL said:
 
  You have an error in your SQL syntax near 'desc text,
  photo text,
  address1 tinytext,
  address2 tinytext,
  city ti' at line 7

 What's the problem??? My db seems to find on the other machine?

 ~ Mike
 --
 Mike Zornek | Project Leader
 Apple Student Developers
 The Insanely Great Site with the Insanely Long URL
 http://www.applestudentdevelopers.org

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




Re: [PHP-DB] Mysql syntax error - phpMyAdmin ??

2002-07-10 Thread Jason Wong

On Thursday 11 July 2002 01:00, Ryan Jameson (USA) wrote:
 Sorry, [desc] won't work either. :-(

Try `desc`.

But it's best not to use 'desc' at all, it will save you confusion in the long 
run.

-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *


/*
People humiliating a salami!
*/


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




Re: [PHP-DB] Mysql syntax error - phpMyAdmin ??

2002-07-10 Thread Michael Zornek

Twas 7/10/02 12:55 PM, when Martin Clifford [EMAIL PROTECTED] said:

 DESC is a reserved word in SQL, standing for Descending Order.  That is why
 you can't use it as a table column name.

Ok, that makes sence - thanks!

Although I find it a bit curious that building the DB in phpMyAdmin let me
do it, yet base MySQL will not.

Should I report it to the phpMyAdmin team?

~ Mike
-- 
Mike Zornek | Project Leader
Apple Student Developers
The Insanely Great Site with the Insanely Long URL
http://www.applestudentdevelopers.org

Personal Site: 
http://www.mikezornek.com


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




Re: [PHP-DB] Mysql syntax error - phpMyAdmin ??

2002-07-10 Thread Gurhan Ozen

Hi,
No you should not report it to anyone. Reserved words can be used as column
names in MySQL (although you shouldn't) provided that they are surrounded by
backticks. When you do it in phpMyAdmin, phpMYAdmin is putting everything
inside backticks , so that this problem won't be encountered.
See:
http://www.mysql.com/doc/L/e/Legal_names.html

Gurhan

- Original Message -
From: Michael Zornek [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, July 10, 2002 1:30 PM
Subject: Re: [PHP-DB] Mysql syntax error - phpMyAdmin ??


 Twas 7/10/02 12:55 PM, when Martin Clifford [EMAIL PROTECTED] said:

  DESC is a reserved word in SQL, standing for Descending Order.  That is
why
  you can't use it as a table column name.

 Ok, that makes sence - thanks!

 Although I find it a bit curious that building the DB in phpMyAdmin let me
 do it, yet base MySQL will not.

 Should I report it to the phpMyAdmin team?

 ~ Mike
 --
 Mike Zornek | Project Leader
 Apple Student Developers
 The Insanely Great Site with the Insanely Long URL
 http://www.applestudentdevelopers.org

 Personal Site:
 http://www.mikezornek.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




Re: [PHP-DB] Need syntax for conditional in recordset loop

2001-07-17 Thread Dobromir Velev

Hi,
You could use something like

#start
do
  {
  echo tr;
  $fields=odbc_num_fields($data2);
  for($i=3 ; $i=$fields ; $i++)
echo td nowrap;
if (odbc_result($data2,$i) = 'SOX')
  echo a href='sox_page_url'.odbc_result($data2,$i)./a;
else
   echo odbc_result($data2,$i);
  echo /td/tr\n;
  } while(odbc_fetch_row($data2));
echo /table;
#end

The idea is to output one thing when the result matches your criteria and
another when it doesn't.

Hope this helps
Dobromir Velev

-Original Message-
From: John A DAVIS [EMAIL PROTECTED]
To: [EMAIL PROTECTED] [EMAIL PROTECTED]
Date: Tuesday, July 17, 2001 2:39 AM
Subject: [PHP-DB] Need syntax for conditional in recordset loop


How would I code IF .odbc_result($data2,$i) = 'SOX' THEN make it a link?
By link I mean that I want the word SOX highlited in blue and underlined
and referencing a webpage that explains SOX verbosefully. Don't know PHP IF
THEN syntax too well.


/* fill table with data */
do
  {
  echo tr;
  $fields=odbc_num_fields($data2);
  for($i=3 ; $i=$fields ; $i++)
  echo td nowrap.odbc_result($data2,$i)./td;
  echo /tr\n;
  } while(odbc_fetch_row($data2));
echo /table;

John A. Davis
Information Systems Specialist
OHD DWP
State of Oregon


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