RE: [PHP] Re: [NEWMAN] make an "if" or "else if" statement from mysql.

From: Date: Wed, 20 Mar 2002 12:15:09 +0000
Subject: RE: [PHP] Re: [NEWMAN] make an "if" or "else if" statement from mysql.
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-89318@lists.php.net to get a copy of this message
Try if(mysql_num_rows($sql_result)) instead of "db_num_rows." Hope this helps. Brian Drexler -----Original Message----- From: Philip J. Newman [mailto:newmanpj@philipsdomain.com] Sent: Wednesday, March 20, 2002 7:09 AM To: Philip J. Newman; Julio Nobrega Trabalhando Cc: php-general@lists.php.net Subject: Re: [PHP] Re: [NEWMAN] make an "if" or "else if" statement from mysql. $sql = "SELECT accessIP FROM access ORDER BY accessID DESC"; $sql_result = mysql_query($sql, $connection) or die ("Could not get Query"); if (db_num_rows() > 0) { // Update view where ip = visitor_ip } else { // Normal insert $sql = "INSERT INTO access (accessID, accessIP, accessDNS, accessTIME, accessUPDATE, accessVIEW) VALUES ('', '$proxy_ip', '$proxy_dns', '$add_date', NOW(NULL), '0')"; $result = mysql_query($sql); } this gives me Fatal error: Call to undefined function: db_num_rows() in d:\hosting\crushme\index.php on line 20 anyone helo me fix this ----- Original Message ----- From: "Philip J. Newman" <newmanpj@philipsdomain.com> To: "Julio Nobrega Trabalhando" <inerte@hotmail.com> Cc: <php-general@lists.php.net> Sent: Wednesday, March 20, 2002 8:46 AM Subject: Re: [PHP] Re: [NEWMAN] make an "if" or "else if" statement from mysql. > if (db_num_rows() > 0) { > > mysql_query("UPDATE access SET access VIEW= accessVIEW+1 WHERE accessIP > = accessIP"); // Update view where ip = visitor_ip > > } else { > > $sql = "INSERT INTO access > (accessID, accessIP, > accessDNS, > accessTIME, accessUPDATE, > accessVIEW) VALUES ('', '$proxy_ip', > '$proxy_dns', '$add_date', NOW(NULL), '0')"; > $result = mysql_query($sql); > > } > > if (db_num_rows() > 0) { <= WHERE DOSE THIS VERABLE COME FROM? > > ----- Original Message ----- > From: "Julio Nobrega Trabalhando" <inerte@hotmail.com> > To: <php-general@lists.php.net> > Sent: Wednesday, March 20, 2002 8:45 AM > Subject: [PHP] Re: [NEWMAN] make an "if" or "else if" statement from mysql. > > > > Select before to see if exists: > > > > if (db_num_rows() > 0) { > > // Update view where ip = visitor_ip > > } else { > > // Normal insert > > } > > > > -- > > > > Julio Nobrega. > > > > Um dia eu chego lá: > > http://sourceforge.net/projects/toca > > > > Ajudei? Salvei? Que tal um presentinho? > > > > http://www.submarino.com.br/wishlistclient.asp?wlid=664176742884 > > > > > > "Philip J. Newman" <newmanpj@philipsdomain.com> wrote in message > > news:003401c1cf85$1afe54c0$0401a8c0@philip... > > I have a log of IP numbers that come to WEBSITE A > > > > $sql = "INSERT INTO access > > (accessID, accessIP, > > accessDNS, > > accessTIME, accessUPDATE, > > accessVIEW) VALUES ('', '$proxy_ip', > > '$proxy_dns', '$add_date', NOW(NULL), '0')"; > > > > This has worked well, how ever when someone comes back with the same > > "accessIP" then I would like then "accessVIEW" aadds a +1 to the > > value. > > > > I would like help to create this .. > > > > > > if (!$remote_addr) <- if the ip that they are using is the same as one in > > the table then update the record and use the accessID for that record. > > > > else if there isn't that $remote_addr in the table then it is added. > > > > I have yet to start on the code, so would some direction. > > > > Philip J. Newman > > PhilipNZ :: Design Solutions > > http://www.philipnz.com/ > > info@philipnz.com > > ICQ# 20482482 > > +64 25 6144012 > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#89318) next »