[PHP-DB] PHP and XML

2002-08-13 Thread Bernard

Hi,

I am new to this list and I hope that it is the right place for a question
which is plaguing me:

I am using successfully the PHP XML-parser. But I have one problem.
I like to include html tags into the texts and I don't want them to be 
interpreted by the parser. But I can't prevent it. It tried lt; and rt;,
but they get interpreted as  and , and so I get an error message 
by the parser. I tried including the html stuff in comments, but then they
are completely lost, which is of course normal behaviour. I tried quoting with
backslash, e.g. \p\, but in vain as well.

I would be very happy and thankful, if anybody could help me.

Best wishes

Bernard


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




RE: [PHP-DB] PHP and XML

2002-08-13 Thread Hutchins, Richard

A question better suited for the php-general list, but check out:

http://www.php.net/manual/en/function.htmlspecialchars.php

and/or

http://www.php.net/manual/en/function.htmlentities.php

hth,
Rich

-Original Message-
From: Bernard [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, August 13, 2002 5:53 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] PHP and XML


Hi,

I am new to this list and I hope that it is the right place for a question
which is plaguing me:

I am using successfully the PHP XML-parser. But I have one problem.
I like to include html tags into the texts and I don't want them to be 
interpreted by the parser. But I can't prevent it. It tried lt; and rt;,
but they get interpreted as  and , and so I get an error message 
by the parser. I tried including the html stuff in comments, but then they
are completely lost, which is of course normal behaviour. I tried quoting
with
backslash, e.g. \p\, but in vain as well.

I would be very happy and thankful, if anybody could help me.

Best wishes

Bernard


-- 
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] Log Application Help...

2002-08-13 Thread NIPP, SCOTT V (SBCSI)

I have a Log Application that is fully functional, but I need to
change a behavior and can't quite figure out how.  This app has three pages,
one for entering new entries, one to display all entries for the last 5
days, and the final page allows updating of existing entries.  The problem I
am having is that the log display page displays the data ordered by date and
displays the oldest data first.  I want the data ordered this way, but I
would like it to default to the last page such that you see the most recent
entry first.  The log displays 10 entries per page, and I just want it to
default to displaying the last page rather than the first.  Below is what I
think are the pertinent sections of code.  Please let me know what you
think, and if you need more information or code.  Thanks in advance for the
assistance.

?php require_once('prod.lib.php'); ?
?php
$currentPage = $HTTP_SERVER_VARS[PHP_SELF];
$maxRows_entry = 10;
$pageNum_entry = 0;
if (isset($HTTP_GET_VARS['pageNum_entry'])) {
  $pageNum_entry = $HTTP_GET_VARS['pageNum_entry'];
}
$startRow_entry = $pageNum_entry * $maxRows_entry;

mysql_select_db($database, $Prod);
$query_entry = SELECT * FROM oncall WHERE TO_DAYS(NOW()) - TO_DAYS(ptime)
=5 ORDER BY 'ptime' ASC;
$query_limit_entry = sprintf(%s LIMIT %d, %d, $query_entry,
$startRow_entry, $maxRows_entry);
$entry = mysql_query($query_limit_entry, $Prod) or die(mysql_error());
$row_entry = mysql_fetch_assoc($entry);

if (isset($HTTP_GET_VARS['totalRows_entry'])) {
  $totalRows_entry = $HTTP_GET_VARS['totalRows_entry'];
} else {
  $all_entry = mysql_query($query_entry);
  $totalRows_entry = mysql_num_rows($all_entry);
}
$totalPages_entry = ceil($totalRows_entry/$maxRows_entry)-1;

$queryString_entry = ;
if (!empty($HTTP_SERVER_VARS['QUERY_STRING'])) {
  $params = explode(, $HTTP_SERVER_VARS['QUERY_STRING']);
  $newParams = array();
  foreach ($params as $param) {
if (stristr($param, pageNum_entry) == false  
stristr($param, totalRows_entry) == false) {
  array_push($newParams, $param);
}
  }
  if (count($newParams) != 0) {
$queryString_entry =  . implode(, $newParams);
  }
}
$queryString_entry = sprintf(totalRows_entry=%d%s, $totalRows_entry,
$queryString_entry);
?

...  A bunch of HTML formatting snipped out...

  ?php } while ($row_entry = mysql_fetch_assoc($entry)); ?
/tableRecords ?php echo ($startRow_entry + 1) ? to ?php echo
min($startRow_entry + $maxRows_entry, $totalRows_entry) ? of ?php echo
$totalRows_entry ? 
table border=0 width=50% align=center
  tr 
td width=23% align=center ?php if ($pageNum_entry  0) { // Show
if not first page ?
  a href=?php printf(%s?pageNum_entry=%d%s, $currentPage, 0,
$queryString_entry); ?First/a 
  ?php } // Show if not first page ? /td
td width=31% align=center ?php if ($pageNum_entry  0) { // Show
if not first page ?
  a href=?php printf(%s?pageNum_entry=%d%s, $currentPage, max(0,
$pageNum_entry - 1), $queryString_entry); ?Previous/a 
  ?php } // Show if not first page ? /td
td width=23% align=center ?php if ($pageNum_entry 
$totalPages_entry) { // Show if not last page ?
  a href=?php printf(%s?pageNum_entry=%d%s, $currentPage,
min($totalPages_entry, $pageNum_entry + 1), $queryString_entry);
?Next/a 
  ?php } // Show if not last page ? /td
td width=23% align=center ?php if ($pageNum_entry 
$totalPages_entry) { // Show if not last page ?
  a href=?php printf(%s?pageNum_entry=%d%s, $currentPage,
$totalPages_entry, $queryString_entry); ?Last/a 
  ?php } // Show if not last page ? /td
  /tr
/table

...Cut of the rest of the HTML junk...

Scott Nipp
Phone:  (214) 858-1289
E-mail:  [EMAIL PROTECTED]
Web:  http:\\ldsa.sbcld.sbc.com



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




[PHP-DB] Re: problem with php and unixODBC

2002-08-13 Thread Nick Gorham

Marten Lehmann wrote:
 Hello,
 
 my unixODBC-2.2.2 installation works fine. I tested the configuration 
 with a local and a remote ressource to a Sybase Adaptive Server Anywhere 
 database with isql (a testing tool of unixODBC). Thus the settings in 
 the odbc.ini and odbcinst.ini should be correct. But when I'm using 
 PHP-4.2.1 with unixODBC-support, I can connect to the local ressource 
 only, not to the remote-ressource, although it worked with isql. Do you 
 have any general ideas, why it doesn't work?
 
 Are there known issues about the unixODBC-implementation in php? PHP 
 always says unable to connect to server: database not found. But as I 
 told before, the odbc.ini settings are correct. It seems that php tries 
 to connect to a local server although in odbc.ini CommLinks-settings are 
 defined. Does maybe php don't receive the odbc.ini data correct? I 
 thought that it might be a permission problem, but I ran apache 1.3.26 
 (with php as module) with the same user to whom all the files and 
 databases belong and I got no positive result.

Hi,

I know its a little late, but I have only just been pointed to your 
posting, I would guess the error you are getting database not found is 
coming from the sybase driver, not the driver manager.

PHP doesn't get involved with the odbc.ini data, just the driver 
manager, but the sybase driver also needs to find its ini files, it 
doesn't get them from the driver manager ini file, but its own.

Can you first try using apache in single user mode, ie httpd -X, as the 
same user that can connect (say using isql) to the sybase driver, if one 
can connect, but the other not, I would then try

strace -o /tmp/stlog httpd -X

then try and connect and have a look (send me a copy if you want) of the 
log, it should show what files and drivers its trying to load.

---
Nick Gorham
Easysoft.


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




[PHP-DB] Oracle 7.3 Client on Windows NT

2002-08-13 Thread twm

Can the Oracle 7.3 client used on a Windows NT system with Apache?

I have tried adding the php_oracle.dll extension,  but I get an error
when I start Apache.

Thanks,
Tom



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




[PHP-DB] user authentication problem

2002-08-13 Thread chip . wiegand

I have this script which is giving me a couple of problems -
1 - I cannot use include ../connect.inc, I get headers already sent error
2 - I can use this script once, but if I try to reload the page to continue
testing I get error Unable to execute query. Clearing the browsers cache
does not help.

Any ideas what's going on here?

?
$auth = false; // Assume user is not authenticated
if (isset( $PHP_AUTH_USER )  isset($PHP_AUTH_PW)) {

 //Connect to MySQL
mysql_connect( 'localhost', 'autopilots', 'Xfm3dwj' )
or die ( 'Unable to connect to server.' );
//Select database on MySQL server
mysql_select_db( 'www2_simradusa_com' )
or die ( 'Unable to select database.' );

// Formulate the query
$sql = SELECT * FROM user WHERE
userid = '$PHP_AUTH_USER' AND
userpassword = '$PHP_AUTH_PW';
// Execute the query and put results in $result
$result = mysql_query( $sql );
if ( $result != false )
 { echo mysql_error(); }
 // Get number of rows in $result.
$num = mysql_numrows( $result );
if ( $num != 0 ) {
// A matching row was found - the user is authenticated.
$auth = true;
}
}
if ( ! $auth ) {
header( 'WWW-Authenticate: Basic realm=Private' );
header( 'HTTP/1.0 401 Unauthorized' );
echo 'Authorization Required.';
exit;
} else {
header( 'Location:
http://www.simradusa.com/auth_dealers/dealers_page.php' );
}
?

--
Chip Wiegand
Computer Services
Simrad, Inc
www.simradusa.com
[EMAIL PROTECTED]

There is no reason anyone would want a computer in their home.
 --Ken Olson, president, chairman and founder of Digital Equipment
Corporation, 1977
 (They why do I have 9? Somebody help me!)


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




Re: [PHP-DB] select distinct with all columns

2002-08-13 Thread leo g. divinagracia iii

you maybe using it the wrong way.  read the doc:


russ arbuthnot wrote:

 I have a mysql table named equipment with 11 columns named: id,
 staff_member, class, type, manufacturer, model, description, picture,
 created, modified, and published.

 I'm trying to write a select statement similar to this:

 SELECT DISTINCT type FROM equipement WHERE class = microphones;

 yet shows all 11 columns of the selected rows rather than just the
 type column.

 The only way I know how to show all the columns is to use SELECT *, or to
 list all the columns manually like SELECT id, type, class, ... etc.

 But when I tried doing this:

 SELECT DISTINCT type, id, staff_member, class, manufacturer, model,
 description, picture, created, modified, published FROM equipment WHERE
 class = microphones;

 I just got the exact same answer as if i would have done this:

 SELECT * FROM equipment WHERE class = microphones;

 so it didn't help.

 Can anyone offer a hint?
 Thanks,
 russ

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

--
Leo G. Divinagracia III
[EMAIL PROTECTED]



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




[PHP-DB] oops...Re: [PHP-DB] select distinct with all columns

2002-08-13 Thread leo g. divinagracia iii

oops, i accidentally sent it without finishing...

anyway, what i wanted to say was DISTINCT, at least how i learned it, was
working with rows instead of colums:

http://www.mysql.com/doc/en/DISTINCT_optimisation.html

is there a reason why you dont want to list the columns?

russ arbuthnot wrote:

 I have a mysql table named equipment with 11 columns named: id,
 staff_member, class, type, manufacturer, model, description, picture,
 created, modified, and published.

 I'm trying to write a select statement similar to this:

 SELECT DISTINCT type FROM equipement WHERE class = microphones;

 yet shows all 11 columns of the selected rows rather than just the
 type column.

 The only way I know how to show all the columns is to use SELECT *, or to
 list all the columns manually like SELECT id, type, class, ... etc.

 But when I tried doing this:

 SELECT DISTINCT type, id, staff_member, class, manufacturer, model,
 description, picture, created, modified, published FROM equipment WHERE
 class = microphones;

 I just got the exact same answer as if i would have done this:

 SELECT * FROM equipment WHERE class = microphones;

 so it didn't help.

 Can anyone offer a hint?
 Thanks,
 russ

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

--
Leo G. Divinagracia III
[EMAIL PROTECTED]



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




Re: [PHP-DB] Re: select distinct with all columns

2002-08-13 Thread russ arbuthnot

Perfect!
Thanks. I'm still trying to get a handle on the GROUP BY command. It's still a 
little bit like magic to me. And in the manual, they don't really show how to 
use it like the way I wanted to use it.
Thanks again,
russ

On Monday 12 August 2002 01:27 pm, Dan Koken wrote:
 SELECT *
 FROM equipement
 WHERE class = microphones
 GROUP BY type;

 Russ Arbuthnot wrote:
  I have a mysql table named equipment with 11 columns named: id,
  staff_member, class, type, manufacturer, model, description, picture,
  created, modified, and published.
 
  I'm trying to write a select statement similar to this:
 
  SELECT DISTINCT type FROM equipement WHERE class = microphones;
 
  yet shows all 11 columns of the selected rows rather than just the
  type column.
 
  The only way I know how to show all the columns is to use SELECT *, or to
  list all the columns manually like SELECT id, type, class, ... etc.
 
  But when I tried doing this:
 
  SELECT DISTINCT type, id, staff_member, class, manufacturer, model,
  description, picture, created, modified, published FROM equipment WHERE
  class = microphones;
 
  I just got the exact same answer as if i would have done this:
 
  SELECT * FROM equipment WHERE class = microphones;
 
  so it didn't help.
 
  Can anyone offer a hint?
  Thanks,
  russ



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




Re: [PHP-DB] odbc connect problem

2002-08-13 Thread salamander

Hi Chip,

Looks okay at first brush - I suspect your odbc.ini DSN config.
Have you been able to test your DSN outside the PHP environment?  e.g 
with the odbctest app that comes with iODBC?

Can you post your odbc.ini / DSN info?

 Warning: SQL error: [iODBC][Driver Manager]Specified driver could not be
 loaded, SQL state IM003 in
 SQLConnect in /usr/local/apache/htdocs/odbctest.php on line 16

My suspicions come from the test of this error - could not be loaded - 
so it's possible that your are specifying an invalid file, or there are 
permission issues on that file, etc.. either way, the contents of your 
odbc.ini might help.

Cheers,
Andrew


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




RE: [PHP-DB] Log Application Help...

2002-08-13 Thread Beau Lebens

Scott, can you just do it by sorting your query, then limiting the results
to 10?

ie.

SELECT * FROM tables WHERE somthing='1' ORDER BY date DESC LIMIT 10

should sort highest - lowest date (ie most recent, backwards) and give you
the top 10 results. then if you have the option of flipping thru blocks of
10 results you can just change the last bit to

LIMIT x,10

WHERE x is a starting point, then 10 obviously getting the next 10 entires.

HTH

Beau

// -Original Message-
// From: NIPP, SCOTT V (SBCSI) [mailto:[EMAIL PROTECTED]]
// Sent: Wednesday, 14 August 2002 12:07 AM
// To: '[EMAIL PROTECTED]'
// Subject: [PHP-DB] Log Application Help...
// 
// 
//  I have a Log Application that is fully functional, but I need to
// change a behavior and can't quite figure out how.  This app 
// has three pages,
// one for entering new entries, one to display all entries for 
// the last 5
// days, and the final page allows updating of existing 
// entries.  The problem I
// am having is that the log display page displays the data 
// ordered by date and
// displays the oldest data first.  I want the data ordered 
// this way, but I
// would like it to default to the last page such that you see 
// the most recent
// entry first.  The log displays 10 entries per page, and I 
// just want it to
// default to displaying the last page rather than the first.  
// Below is what I
// think are the pertinent sections of code.  Please let me 
// know what you
// think, and if you need more information or code.  Thanks in 
// advance for the
// assistance.
// 
// ?php require_once('prod.lib.php'); ?
// ?php
// $currentPage = $HTTP_SERVER_VARS[PHP_SELF];
// $maxRows_entry = 10;
// $pageNum_entry = 0;
// if (isset($HTTP_GET_VARS['pageNum_entry'])) {
//   $pageNum_entry = $HTTP_GET_VARS['pageNum_entry'];
// }
// $startRow_entry = $pageNum_entry * $maxRows_entry;
// 
// mysql_select_db($database, $Prod);
// $query_entry = SELECT * FROM oncall WHERE TO_DAYS(NOW()) - 
// TO_DAYS(ptime)
// =5 ORDER BY 'ptime' ASC;
// $query_limit_entry = sprintf(%s LIMIT %d, %d, $query_entry,
// $startRow_entry, $maxRows_entry);
// $entry = mysql_query($query_limit_entry, $Prod) or 
// die(mysql_error());
// $row_entry = mysql_fetch_assoc($entry);
// 
// if (isset($HTTP_GET_VARS['totalRows_entry'])) {
//   $totalRows_entry = $HTTP_GET_VARS['totalRows_entry'];
// } else {
//   $all_entry = mysql_query($query_entry);
//   $totalRows_entry = mysql_num_rows($all_entry);
// }
// $totalPages_entry = ceil($totalRows_entry/$maxRows_entry)-1;
// 
// $queryString_entry = ;
// if (!empty($HTTP_SERVER_VARS['QUERY_STRING'])) {
//   $params = explode(, $HTTP_SERVER_VARS['QUERY_STRING']);
//   $newParams = array();
//   foreach ($params as $param) {
// if (stristr($param, pageNum_entry) == false  
// stristr($param, totalRows_entry) == false) {
//   array_push($newParams, $param);
// }
//   }
//   if (count($newParams) != 0) {
// $queryString_entry =  . implode(, $newParams);
//   }
// }
// $queryString_entry = sprintf(totalRows_entry=%d%s, 
// $totalRows_entry,
// $queryString_entry);
// ?
// 
// ...  A bunch of HTML formatting snipped out...
// 
//   ?php } while ($row_entry = mysql_fetch_assoc($entry)); ?
// /tableRecords ?php echo ($startRow_entry + 1) ? to ?php echo
// min($startRow_entry + $maxRows_entry, $totalRows_entry) ? 
// of ?php echo
// $totalRows_entry ? 
// table border=0 width=50% align=center
//   tr 
// td width=23% align=center ?php if ($pageNum_entry 
//  0) { // Show
// if not first page ?
//   a href=?php printf(%s?pageNum_entry=%d%s, $currentPage, 0,
// $queryString_entry); ?First/a 
//   ?php } // Show if not first page ? /td
// td width=31% align=center ?php if ($pageNum_entry 
//  0) { // Show
// if not first page ?
//   a href=?php printf(%s?pageNum_entry=%d%s, 
// $currentPage, max(0,
// $pageNum_entry - 1), $queryString_entry); ?Previous/a 
//   ?php } // Show if not first page ? /td
// td width=23% align=center ?php if ($pageNum_entry 
// $totalPages_entry) { // Show if not last page ?
//   a href=?php printf(%s?pageNum_entry=%d%s, $currentPage,
// min($totalPages_entry, $pageNum_entry + 1), $queryString_entry);
// ?Next/a 
//   ?php } // Show if not last page ? /td
// td width=23% align=center ?php if ($pageNum_entry 
// $totalPages_entry) { // Show if not last page ?
//   a href=?php printf(%s?pageNum_entry=%d%s, $currentPage,
// $totalPages_entry, $queryString_entry); ?Last/a 
//   ?php } // Show if not last page ? /td
//   /tr
// /table
// 
// ...Cut of the rest of the HTML junk...
// 
// Scott Nipp
// Phone:  (214) 858-1289
// E-mail:  [EMAIL PROTECTED]
// Web:  http:\\ldsa.sbcld.sbc.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] results of mysql_fetch are returning the incorrect records

2002-08-13 Thread K. Lee

I have problems with mysql_fetch return the wrong records.  If I execute the
sql statement in mysql, I receive the correct results.  When I used
mysql_fetch function, it does not return the correct results.  Below is my
function and the format sql statement

function companiesByBusiness_ZipCode_BusinessOrContactName( $ctgyno,
$zipcode, $businessandcontactname ) {
 $sql = select company_no, name, contact, business_phone, mobile_phone,
services_desc, brief_bio, pager, address, city, state, zipcode,
picture_file, case ifnull(picture_file, 'No Picture') when 'No Picture' then
'b' else 'a' end pic_ind from company;
 if( $ctgyno != ALL) {
  $sql .=  where business_ctgy_no = $ctgyno;
  if( $zipcode !=  ) {
   $sql .=  and (zipcode like '.substr( $zipcode, 0, 3 ).%' and zipcode
!= '$zipcode');
  }
  if( $businessandcontactname !=  ) {
   $sql .=  and (name = '$businessandcontactname';
   $sql .=  or contact = '$businessandcontactname');

  }
  $sql .=  order by pic_ind, name, company_no;
 }

  $query = mysql_query( $sql ) or die( $sql.p.mysql_error() );

 //$numrows = mysql_num_rows( $query );
 while( $assoc = mysql_fetch_assoc( $query ) ) {
  $rows[] = $assoc;

sql statement:
select company_no, name, contact, business_phone, mobile_phone,
services_desc, brief_bio, pager, address, city, state, zipcode,
picture_file, case ifnull(picture_file, 'No Picture') when 'No Picture' then
'b' else 'a' end pic_ind from company where business_ctgy_no = 1 and
(zipcode like '276%' and zipcode != '27616') and (name = 'Gil Bryan' or
contact = 'Gil Bryan') order by pic_ind, name, company_no

It seems like it is ignoring the last condition, name = 'Gil Bryan' or
contact = 'Gil Bryan').  Any help is greatly appreciated.

 }

 return $rows;
}




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




[PHP-DB] Trying to delete

2002-08-13 Thread César Aracena

Hi all.

I have a small problem here. I have this full-PHP site working with a
MySQL db and came to a dead road when trying to delete a record from it
from the Administrator's page. I have PHP to make this decision after
the Administrator selected the record to delete and answered YES to the
¿Are you sure...? The last part will pass a hidden value of $editpic
which tells the deleting script which artid to delete from the db. This
is the code that does the deletion:

else if ($deleteyes)
{
$query = DELETE FROM saav_arts WHERE artid = '$editpic' LIMIT
1;
$result = mysql_query($query) or die (mysql_error());

if (!$result)
{
echo The Picture could NOT be deletedbr;
echo form action=\.$PHP_SELF.\ method=\post\;
echo input type=\submit\ name=\cancel\
value=\Back to Edition\;
echo /form;
}
else if ($result)
{
echo The Picture was deleted sucsesfullybr;
echo form action=\.$PHP_SELF.\ method=\post\;
echo input type=\submit\ name=\cancel\
value=\Back to Edition\;
echo /form;
}
}

Cesar Aracena
CE / MCSE+I
Neuquen, Argentina
+54.299.6356688
+54.299.4466621



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




[PHP-DB] Re: user authentication problem

2002-08-13 Thread David Robley

In article OF0E2E5A7E.4D05B60D-ON88256C14.006923D1-
[EMAIL PROTECTED], [EMAIL PROTECTED] says...
 I have this script which is giving me a couple of problems -
 1 - I cannot use include ../connect.inc, I get headers already sent error

Look for white space outside the ?php ? tags in connect.inc. A single 
space is enough to trigger the error.

-- 
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] Re: results of mysql_fetch are returning the incorrect records

2002-08-13 Thread David Robley

In article [EMAIL PROTECTED], [EMAIL PROTECTED] 
says...
 I have problems with mysql_fetch return the wrong records.  If I execute the
 sql statement in mysql, I receive the correct results.  When I used
 mysql_fetch function, it does not return the correct results.  Below is my
 function and the format sql statement
 
 function companiesByBusiness_ZipCode_BusinessOrContactName( $ctgyno,
 $zipcode, $businessandcontactname ) {
  $sql = select company_no, name, contact, business_phone, mobile_phone,
 services_desc, brief_bio, pager, address, city, state, zipcode,
 picture_file, case ifnull(picture_file, 'No Picture') when 'No Picture' then
 'b' else 'a' end pic_ind from company;
  if( $ctgyno != ALL) {
   $sql .=  where business_ctgy_no = $ctgyno;
   if( $zipcode !=  ) {
$sql .=  and (zipcode like '.substr( $zipcode, 0, 3 ).%' and zipcode
 != '$zipcode');
   }
   if( $businessandcontactname !=  ) {
$sql .=  and (name = '$businessandcontactname';
$sql .=  or contact = '$businessandcontactname');
 
   }
   $sql .=  order by pic_ind, name, company_no;
  }
 
   $query = mysql_query( $sql ) or die( $sql.p.mysql_error() );
 
  //$numrows = mysql_num_rows( $query );
  while( $assoc = mysql_fetch_assoc( $query ) ) {
   $rows[] = $assoc;
 
 sql statement:
 select company_no, name, contact, business_phone, mobile_phone,
 services_desc, brief_bio, pager, address, city, state, zipcode,
 picture_file, case ifnull(picture_file, 'No Picture') when 'No Picture' then
 'b' else 'a' end pic_ind from company where business_ctgy_no = 1 and
 (zipcode like '276%' and zipcode != '27616') and (name = 'Gil Bryan' or
 contact = 'Gil Bryan') order by pic_ind, name, company_no
 
 It seems like it is ignoring the last condition, name = 'Gil Bryan' or
 contact = 'Gil Bryan').  Any help is greatly appreciated.
 
  }
 
  return $rows;
 }

First, I'd suggest echoing $sql just before you send it to mysql to ensure 
that what you hope is there is actually there. Also, what are you 
returning from your function? Or how are you using the data gathered from 
your tables?

-- 
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] Re: Trying to delete

2002-08-13 Thread David Robley

In article 01c2433c$e2e3e4c0$e5c405c8@gateway, [EMAIL PROTECTED] 
says...
 Hi all.
 
 I have a small problem here. I have this full-PHP site working with a
 MySQL db and came to a dead road when trying to delete a record from it
 from the Administrator's page. I have PHP to make this decision after
 the Administrator selected the record to delete and answered YES to the
 =BFAre you sure...? The last part will pass a hidden value of $editpic
 which tells the deleting script which artid to delete from the db. This
 is the code that does the deletion:
 
 else if ($deleteyes)
 {
   $query =3D DELETE FROM saav_arts WHERE artid =3D '$editpic' LIMIT
 1;
   $result =3D mysql_query($query) or die (mysql_error());
 
   if (!$result)
   {
   echo The Picture could NOT be deletedbr;
   echo form action=3D\.$PHP_SELF.\ method=3D\post\;
   echo input type=3D\submit\ name=3D\cancel\
 value=3D\Back to Edition\;
   echo /form;
   }
   else if ($result)
   {
   echo The Picture was deleted sucsesfullybr;
   echo form action=3D\.$PHP_SELF.\ method=3D\post\;
   echo input type=3D\submit\ name=3D\cancel\
 value=3D\Back to Edition\;
   echo /form;
   }
 }
 
 Cesar Aracena
 CE / MCSE+I

You have made some wrong assumptions in your code here; it is quite 
possible that $result may be true but no entries have been deleted. You 
perhaps should look at the possibility of testing mysql_affected_rows to 
determine whether any rows have been updated/deleted.

WHERE artid = '$editpic' 

implies that you expect artd to be a text field of type char or 
varchar because you have enclosed the value that you are testing in single 
quotes; if artid is in fact an integer type, this query will not affect 
any rows, as the text value will never match an integer field value.

-- 
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] RE: [PHP] Re: Trying to delete

2002-08-13 Thread César Aracena

Thanks. I must apology as I made a mistake when writing the incoming
variable's name. I had it wrong so it would pass the variable but the
incoming script was looking for a variable that wasn't passed. In the
meantime, and now that I correct that, I'm still comparing artid to
'$artid' (with single quotes) and it does it well... it is an int(4)
field and now that you mention it... how is it possible?

C.

 -Original Message-
 From: David Robley [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, August 14, 2002 12:47 AM
 To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Subject: [PHP] Re: Trying to delete
 
 In article 01c2433c$e2e3e4c0$e5c405c8@gateway,
[EMAIL PROTECTED]
 says...
  Hi all.
 
  I have a small problem here. I have this full-PHP site working with
a
  MySQL db and came to a dead road when trying to delete a record from
it
  from the Administrator's page. I have PHP to make this decision
after
  the Administrator selected the record to delete and answered YES to
the
  =BFAre you sure...? The last part will pass a hidden value of
$editpic
  which tells the deleting script which artid to delete from the db.
This
  is the code that does the deletion:
 
  else if ($deleteyes)
  {
  $query =3D DELETE FROM saav_arts WHERE artid =3D '$editpic'
LIMIT
  1;
  $result =3D mysql_query($query) or die (mysql_error());
 
  if (!$result)
  {
  echo The Picture could NOT be deletedbr;
  echo form action=3D\.$PHP_SELF.\
method=3D\post\;
  echo input type=3D\submit\ name=3D\cancel\
  value=3D\Back to Edition\;
  echo /form;
  }
  else if ($result)
  {
  echo The Picture was deleted sucsesfullybr;
  echo form action=3D\.$PHP_SELF.\
method=3D\post\;
  echo input type=3D\submit\ name=3D\cancel\
  value=3D\Back to Edition\;
  echo /form;
  }
  }
 
  Cesar Aracena
  CE / MCSE+I
 
 You have made some wrong assumptions in your code here; it is quite
 possible that $result may be true but no entries have been deleted.
You
 perhaps should look at the possibility of testing mysql_affected_rows
to
 determine whether any rows have been updated/deleted.
 
 WHERE artid = '$editpic'
 
 implies that you expect artd to be a text field of type char or
 varchar because you have enclosed the value that you are testing in
single
 quotes; if artid is in fact an integer type, this query will not
affect
 any rows, as the text value will never match an integer field value.
 
 --
 David Robley
 Temporary Kiwi!
 
 Quod subigo farinam
 
 --
 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




[PHP-DB] RE: [PHP] Re: Trying to delete

2002-08-13 Thread Brad Bulger


On Wed, 14 Aug 2002, [iso-8859-1] César Aracena wrote:

 Thanks. I must apology as I made a mistake when writing the incoming
 variable's name. I had it wrong so it would pass the variable but the
 incoming script was looking for a variable that wasn't passed. In the
 meantime, and now that I correct that, I'm still comparing artid to
 '$artid' (with single quotes) and it does it well... it is an int(4)
 field and now that you mention it... how is it possible?

MySQL lets you compare numbers and strings pretty liberally:

mysql create table foo (x int, y double);
Query OK, 0 rows affected (0.02 sec)

mysql insert into foo values (1, 3.1415);
Query OK, 1 row affected (0.09 sec)

mysql select * from foo where x = '1';
+--++
| x| y  |
+--++
|1 | 3.1415 |
+--++
1 row in set (0.01 sec)

mysql select * from foo where y like '3.14%';
+--++
| x| y  |
+--++
|1 | 3.1415 |
+--++
1 row in set (0.00 sec)



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