[PHP-DB] Insert problem

2003-08-11 Thread Kim Kohen
G'day all,

I have a problem with an insert which is proving infuriating.  When I run
the following code everything seems to work (no errors) except the database
remains empty. When I echo $query and run it from a command line it inserts
fine.  I don't get any connection errors - in fact when I echo the
connection variables, it reflects a valid db connection.

Finally, if I change if (! $result = 1) to if (! $result = 0) it fires which
tends to indicate the query was successful.

Any suggestions would be most appreciated.

cheers

kim

$fileinfo = fopen($filepath, r) OR die (Failed to open the files
successfully);
$line = fgets($fileinfo, 1024);
$ad_num = substr($line,0, 19);
$page = substr($line,21, 4);
$section = substr($line,26, 6);
$width = substr($line,35, 5);
$height = substr($line,41, 7);
$client = substr($line,72, 20);
$xcoord = substr($line,135, 7);
$ycoord = substr($line,143, 7);
$publication = Torch;
fclose($fileinfo); 

$db_name = test;
$table_name = dummy;
$connection = @mysql_connect(localhost,root,password) or die(Couldn't
Connect.);
$db = @mysql_select_db($db_name, $connection) or die(Couldn't select dummy
database.);

$query =insert into dummy
(ad_num,width,height,client,page_number,publication,section,xpos,ypos)
VALUES 
('$ad_num','$width','$height','$client','$page','$publication','$section','$
xcoord','$ycoord');

echo $db_name.br. $table_name.br. $connection.br.$query;

if (! $result = 1)
{
echo insert failed;
}


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



[PHP-DB] PHP and ODBC

2003-08-11 Thread Antonio Musarra
How to cofigurare PHP in order to approach PostgreSQL using ODBC?  
Thanks

-- 
Antonio Musarra
Phone: +39 334 3401157
Phone: +39 328 8113527
Mail: [EMAIL PROTECTED]
Web: http://www.romcad.it


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



[PHP-DB] Re: newbie lost on data import - solved

2003-08-11 Thread jsWalter
It seems that my text file was a UNICODE text file

I have no idea how that happened as this was exported from Excel.

So, anyway, now I know to check the file format before I spend over 100
hours trying to figure out why I could not INSERT to a database.

Thanks to all who offered help, thoughts and comments.

Walter




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



Re: [PHP-DB] ODBC Database

2003-08-11 Thread Robert Twitty
Unless I am mistaken, but isn't there an ODBC driver available for MySQL
called MyODBC?

-- bob

On Sun, 10 Aug 2003, Gerard Samuel wrote:

 Larry E.Ullman wrote:

  Im looking at venturing into working with PHP's ODBC extention.
  Does anyone have any recommendations as to a Database, that is easy to
  understand/get into from a novice point of view, that installs on
  windows 2k,
  and is free?
 
 
  MySQL is kind of free, installs on W2K and is easy to use but it
  doesn't require PHP's ODBC extension since PHP already has a good
  MySQL extension. If you really want to use ODBC and you have MS
  Office, you could try Access.

 What Im doing is seeing if my code will run on different databases.
 Of which it currently runs on mySQL, PostgreSQL and MSSQL.
 As soon as I can get PHP5 installed Ill be checking out SQLLite.
 But in the meantime, Im looking for a database that would interface with
 ODBC.
 I just downloaded IBM's DB2 Personal Edition, to see what I can do
 there, but,
 Im just looking for advice etc from others who went down this road.

 Thanks


 --
 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] mysql problem importing data

2003-08-11 Thread Merlin
Hi there,

I have a data file with data seperated by semicolons. It is about 8MB big.
Now I just want to import it into mysql.
I tryed several things. First I took phpmyadmin, which resulted in  a white
page without error msg. Then I tryed it by hand with load data. This did not
work as well. No I installed myodbc and tryed to export it from MS Access.
This completly crashes my database server with this message:

 /usr/local/mysql/bin/safe_mysqld: line 1:  1067 Segmentation fault
nice --5 nohup
/usr/local/mysql/libexec/mysqld --basedir=/usr/local/mysql --datadir=/home/m
ysqladm/data --user=mysql --pid-file=/home/mysqladm/var/mysqld.pid --skip-lo
cking -u mysqladm /home/mysqladm/data/SARATOGA.err 21
030807 00:00:45  mysqld ended

Has anybody an idea on how to import that data? Its nicely seperated by ;

Thanx for any help,

Merlin



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



[PHP-DB] looping code

2003-08-11 Thread Khristopher_Klaich
Hello all I have a helpdesk application that was written in php and I 
would like to create a script that will e-mail the systems staff how many 
open helpdesk tickets they have.  There are 10 users and I can wrtie a 
script no problem to do a count and then e-mail that to a user I just have 
no idea how the heck to loop it through all of the users .

Here is my code for one user if they are logged in if anyone can help me 
or lead me in the right direction I would appreicate it very much my brain 
is just not working today:


function showSummary() {
   global $user, $mysql_link;
   $openTickets = 0;
   $userTickets = 0;
 
   $query = SELECT events.e_id, events.t_id, events.e_status,  .
events.e_assignedto, ticket.t_id FROM events,ticket  .
 WHERE events.t_id = ticket.t_id ORDER BY  .
 events.t_id, events.e_id;;
   $result = query( $query );

   $row = mysql_fetch_row( $result );

   $prev_e_id = $row[0]; 
   $prev_t_id = $row[1]; 
   $prev_e_status = $row[2]; 
   $prev_e_assignedto = $row[3];

   $done = 0;
   while( !$done  ) {
   $row = mysql_fetch_row( $result );
   if( !$row ) { 
   $done = 1;
   }
 
   $e_id = $row[0]; 
   $t_id = $row[1]; 
   $e_status = $row[2]; 
   $e_assignedto = $row[3];

   if( $t_id != $prev_t_id ) {
   if( $prev_e_status == OPEN ) {
   $openTickets++;
   if( $prev_e_assignedto == $user  isset($user) )
   $userTickets++;
   }
   }
 
   $prev_e_id = $e_id;
   $prev_t_id = $t_id;
   $prev_e_status = $e_status;
   $prev_e_assignedto = $e_assignedto;
   }
 
   print Open Tickets: $openTicketsbr\n;
   print Assigned to you: $userTicketsbr\n;
}


Re: [PHP-DB] PHP MSSQL

2003-08-11 Thread Robert Twitty
This is true if Shaun was using MySQL, but he is using MSSQL.  MSSQL
allowas you to declare char and varchar fields with lengths up to 8000
characters.  Unfortunately the extension bundled with PHP cannot read
beyond the first 255 characters.  This is primarily due to the fact that
the extension was built using DB-LIB, which does not adequately support
all of the new data types introduced in MSSQL 7.0 and 2000.

-- bob

On Mon, 11 Aug 2003, Matthew McNicol wrote:


 Shaun, the MySQL manual suggests that you have hit your limit using the
 VARCHAR field type (255 characters). To store 6,000 characters have you not
 considered using the TEXT field type?



 6.2.3.1 The CHAR and VARCHAR Types
 The CHAR and VARCHAR types are similar, but differ in the way they are
 stored and retrieved.

 The length of a CHAR column is fixed to the length that you declare when you
 create the table. The length can be any value between 1 and 255. (As of
 MySQL Version 3.23, the length of CHAR may be 0 to 255.) When CHAR values
 are stored, they are right-padded with spaces to the specified length. When
 CHAR values are retrieved, trailing spaces are removed.

 Values in VARCHAR columns are variable-length strings. You can declare a
 VARCHAR column to be any length between 1 and 255, just as for CHAR columns.
 However, in contrast to CHAR, VARCHAR values are stored using only as many
 characters as are needed, plus one byte to record the length. Values are not
 padded; instead, trailing spaces are removed when values are stored. (This
 space removal differs from the SQL-99 specification.) No case conversion
 takes place during storage or retrieval.

 If you assign a value to a CHAR or VARCHAR column that exceeds the column's
 maximum length, the value is truncated to fit.



 - Original Message -
 From: Shaun Bentley [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Monday, August 11, 2003 11:23 AM
 Subject: [PHP-DB] PHP  MSSQL


  Hi
  I am currently trying to use PHP and MSSQL together but I am having a
  few problems.
 
  I can enter data into the Db OK, but when pulling the data back to display
  on the page, the string cuts to around 250 chars. The Db field is VarChar
  6000 and I can see the whole data in the field.
 
  I have tried pulling the data out as object, array  row but always lose
 the
  end.
 
  Any help please!
 
  Shaun
 
 
 
  --
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 


 ---
 Outgoing mail is certified Virus Free.
 Checked by AVG anti-virus system (http://www.grisoft.com).
 Version: 6.0.506 / Virus Database: 303 - Release Date: 01/08/2003


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

2003-08-11 Thread Gerard Samuel
[EMAIL PROTECTED] wrote:

whoops, meant to include
thishttp://www.mysql.com/downloads/api-myodbc-3.51.html
 

Unless I am mistaken, but isn't there an ODBC driver available for MySQL
called MyODBC?
-- bob

   

I haven't a clue.  Ill look, maybe it will help me create drivers for my
DB layer, as I already know MySQL.
Last night I successfully connected to IBM's DB2, but I didnt get far
past that as I have to figure out,
how to create tables, figure out how it likes its schemas etc, to really
give it a work out...
Ok, I got the driver, and Im currently using it.  Thanks.
Now lets see what quirks I run into with odbc  ;)
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] PHP MSSQL

2003-08-11 Thread Shaun Bentley
Hi
I am currently trying to use PHP and MSSQL together but I am having a
few problems.

I can enter data into the Db OK, but when pulling the data back to display
on the page, the string cuts to around 250 chars. The Db field is VarChar
6000 and I can see the whole data in the field.

I have tried pulling the data out as object, array  row but always lose the
end.

Any help please!

Shaun



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



[PHP-DB] ODBC Database

2003-08-11 Thread Gerard Samuel
Im looking at venturing into working with PHP's ODBC extention.
Does anyone have any recommendations as to a Database, that is easy to
understand/get into from a novice point of view, that installs on 
windows 2k,
and is free?
Thanks for your suggestions.

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


RE: [PHP-DB] Don't know why query works this way

2003-08-11 Thread Adam Alkins
Quoting Aaron Wolski [EMAIL PROTECTED]:

 Here's some functions I use in my development which save on connect and
 query calls for me.
 
 //General Purpose Utilities.
 //db_connect connects to the database server and selects the proper
 database.
 //Arguments: None
 //Returns: Nothing
 
 
 function db_connect() {
 
   mysql_pconnect(localhost,username,password);
   mysql_select_db(Database);
   
 }
 
 
 //db_query queries the database server and returns the results.
 //Arguments: SQL query string
 //Returns: Query results
 
 function db_query($query) {
 
   return mysql_query($query);
   
 }
 
 
 //db_fetch returns the next set of results from a db_query.
 //Arguments: db_query results variable
 //Returns: Next set of query results as an array or 0 if no further
 results are present
 
 
 function db_fetch($results) {
 
   return mysql_fetch_array($results);
   
 }
 
 
 //db_numrows returns the number of rows selected from a query.
 //Arguments: query result
 //Returns: number of rows in the query result
 
 function db_numrows($result) {
 
   return mysql_num_rows($result);
   
 }
 
 
 //Always connect to the database!
 
 db_connect();
 
 
 Keep these in an include file. The db_connect(); goes at the bottom and
 keep the connection open during the routines.
 
 
 To call db_query you would use it like:
 
 $someQuery = db_query(SELECT * from someTable );
  
 
 to get the results out of the query you would call db_fetch and use it
 like:
 
 
 $someResult = db_fetch($someQuery);
 
 If you needed to return an array you would use it with a while or for
 statement like:
 
 While ($someResult = db_fetch($someQuery)) {
 
 }
 
 If you needed to get the number of rows from the query you'd use like:
 
 numRows = db_numrows($someQuery);
 
 or
 
 if (db_numrows($someQuery)  ...)
 
 
 These are just some thing I use to make my life easier.
 
 Hope it helps
 

Not to be rude... but what does that have to do with his question?

-- 
Adam Alkins
http://www.rasadam.com

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



Re: [PHP-DB] Sorting issue

2003-08-11 Thread Fernando Soto







You have to change 

kwo VARCHAR(10) NOT NULL,

for 

kwoint(10) NOT NULL,

Hope this helps

Fernando Soto




From: Jeff
Date: Viernes, 08 de Agosto de 2003 10:36:33 a.m.
To: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Sorting issue

Yes duh...

I didn't realize numbers weren't considered characters.
What's the sql entry for numeric characters?

I'm new at this, and figure I'm not doing to bad so far. .

"John W. Holmes" [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]...
 Jeff wrote:

  kwo VARCHAR(10) NOT NULL,
  lsd VARCHAR(20) NOT NULL,

 duh

 --
 ---John Holmes...

 Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

 PHP|Architect: A magazine for PHP Professionals – www.phparch.com







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


.







 IncrediMail - Email has finally evolved - Click Here