RE: [PHP-DB] Check data exists in MySQL

2002-11-21 Thread Adam Royle
Sorry about previous post (some stupid shortcut key made it send)

Your row:

$sql = INSERT INTO count VALUES('$dept', '$deptsub', '0');

should be:

$sql = INSERT INTO count VALUES('$dept', '$deptsub', '0');

You missed the double quotes.

Adam




--- Original Message ---

Hi,

for some reason i'm getting an error when I try to run this query:
__

  $sql=SELECT num FROM count where dept='$dept' AND deptsub='$deptsub';
  $page_count = mysql_query($sql,$db);

  # If does not exist in the database, insert a new entry
  if (!mysql_num_rows($page_count)){
$sql = INSERT INTO count VALUES('$dept', '$deptsub', '0');
$result = mysql_query($sql,$db);
  }

  #Update the count in the database
  $page_count = $page_count + 1;
  $sql=UPDATE count SET num='$page_count' WHERE dept='$dept' AND
deptsub='$deptsub';
  $result = mysql_query($sql, $db);
__

My table looks like this:
  count:
 dept VARCHAR(32)
 deptsub VARCHAR(32)
 num INT(10)
__

I'm getting the following error message:
  Parse error: parse error in /home/./public_html/public/index.php on
line 25
(Which is the line: $sql=UPDATE count...)


Any thoughts would b most helpful.
Thanks,
Gav




Re: [PHP-DB] Check data exists in MySQL

2002-11-20 Thread Tatang Widyanto
 if (!$page_count){
   $sql = INSERT INTO count VALUES('$var1', '$var2', '0');
 }
 

 if (!mysql_num_rows($page_count)){
   $sql = INSERT INTO count VALUES('$var1', '$var2', '0');
 }


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




RE: [PHP-DB] Check data exists in MySQL

2002-11-20 Thread Gavin Amm
Hi,

for some reason i'm getting an error when I try to run this query:
__

  $sql=SELECT num FROM count where dept='$dept' AND deptsub='$deptsub';
  $page_count = mysql_query($sql,$db);

  # If does not exist in the database, insert a new entry
  if (!mysql_num_rows($page_count)){
$sql = INSERT INTO count VALUES('$dept', '$deptsub', '0');
$result = mysql_query($sql,$db);
  }

  #Update the count in the database
  $page_count = $page_count + 1;
  $sql=UPDATE count SET num='$page_count' WHERE dept='$dept' AND
deptsub='$deptsub';
  $result = mysql_query($sql, $db);
__

My table looks like this:
  count:
 dept VARCHAR(32)
 deptsub VARCHAR(32)
 num INT(10)
__

I'm getting the following error message:
  Parse error: parse error in /home/./public_html/public/index.php on
line 25
(Which is the line: $sql=UPDATE count...)


Any thoughts would b most helpful.
Thanks,
Gav


-Original Message-
From: Tatang Widyanto [mailto:[EMAIL PROTECTED]]
Sent: Thursday, 21 November 2002 3:33 PM
To: PHP Database
Subject: Re: [PHP-DB] Check data exists in MySQL


 if (!$page_count){
   $sql = INSERT INTO count VALUES('$var1', '$var2', '0');
 }
 

 if (!mysql_num_rows($page_count)){
   $sql = INSERT INTO count VALUES('$var1', '$var2', '0');
 }


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


This e-mail and any attachments are intended solely for the named addressee,
are confidential and may contain legally privileged information. 

The copying or distribution of them or of any information they contain, by
anyone other than the addressee, is prohibited. If you received this e-mail
in error, please notify us immediately by return e-mail or telephone +61 2
9413 2944 and destroy the original message. Thank you. 

As Email is subject to viruses we advise that all Emails and any attachments
should be scanned by an up to-date Anti Virus programme automatically by
your system. It is the responsibility of the recipient to ensure that all
Emails and any attachments are cleared of Viruses before opening. KSG can
not accept any responsibility for viruses that maybe contained here in.
Please advise KSG by return Email if you believe any Email sent by our
system may contain a virus. It should be noted that most Anti Virus
programmes can not scan encrypted file attachments (example - documents
saved with a password). Thus extra care should be taken when opening these
files. 

Liability limited by the Accountants Scheme, approved under the Professional
Standards Act 1994 (NSW). 



Level 4 
54 Neridah StreetPO Box 1290 
CHATSWOOD   NSW   2067   CHATSWOOD   NSW   2057 


Ph: +61 2 9413 2944  Fax: +61 2 9413 9901

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




Re: [PHP-DB] Check data exists in MySQL

2002-11-20 Thread Tatang Widyanto
 
   $sql=SELECT num FROM count where dept='$dept' AND
deptsub='$deptsub';

 begin of replace --
   $result = mysql_query($sql,$db);
   $page_count = mysql_num_rows($result);
   # If does not exist in the database, insert a new entry

   if (!$page_count){

-- end of replace 
 $sql = INSERT INTO count VALUES('$dept', '$deptsub', '0');
 $result = mysql_query($sql,$db);
   }

   #Update the count in the database
   $page_count = $page_count + 1;
   $sql=UPDATE count SET num='$page_count' WHERE dept='$dept' AND
deptsub='$deptsub';
   $result = mysql_query($sql, $db);

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