Re: [PHP-DB] Really Dumb Question...

2001-04-11 Thread Darryl Friesen



 How do I create a table within my PHP? Heres what I currently have, but I
 keep getting parse error on the "create" line...

Because create is not a valid PHP command.  You have to assign the create
statement to a string, _then_ pass the string to mysql_query:

$sql = "create table $propTable (
  ID int not null auto_increment primary key,
  TourName tinytext,
  TourTitle tinytext,
  ViewTitle tinytext,
  TourNum tinyint not null,
  Applet tinyint not null,
  Desc text,
  TourPath text,
  SmFile text,
  LgFile text );
";

$result = mysql_query($sql);


- Darryl

 ----------
  Darryl Friesen, B.Sc., Programmer/Analyst[EMAIL PROTECTED]
  Education  Research Technology Services, http://gollum.usask.ca/
  Department of Computing Services,
  University of Saskatchewan
 --
  "Go not to the Elves for counsel, for they will say both no and yes"



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




Re: [PHP-DB] how do I connect to MSSQL and mySQL with PHP4 and Linux?

2001-03-28 Thread Darryl Friesen

 I see this FreeTDS thing (www.freetds.org), but do I really need that?
 I don't even know what it is really? The 'FAQ' is not very informative for
a
 'novice'.
 It seems like some extra layer of minutiae that I don't want to deal with.

 Isn't there some way to compile PHP "--with-mssql" just like there is
 "--with-mysql"?

No.

 And there are all these built in mssql_connect() etc functions in PHP
 already, how would FreeTDS effect that?

It lets you use them.

There are two ways to talk to an SQL server, ODBC (in which case you'd use
the odbc_* functions) or TDS (using the sybase_* or mssql_* functions).
You'll need support installed on your linux box for at least one of these
protocols.

All the unix based ODBC stuff I've seen also _requires_ software to be
installed on your SQL server.  TDS does not; think of it as the 'native'
protocol spoken by the MS SQL server (and Sybase servers actually).  It's
_way_ easier than ODBC (I never could get ODBC support installed and working
on our Digital Unix machines). FreeTDS is a free, open source implementation
of the TDS protocol.

I guess I was hoping this would be simple, like mySQL connectivity was...

It's no more work than MySQL.  In order to compile PHP with MySQL support,
you first had to install MySQL.  In order to talk to a Sybase or MS SQL
server, you need to install TDS.

FreeTDS is very easy to install.  You should be able to install FreeTDS and
recompile PHP in under an hour.  The only tricky part is knowing what port
the SQL server listens on (the default is 1433).

Feel free to email me if you need more help.

By the way, I understand there are major issues with SQL2000 server.  In
that case, ODBC might be a better choice.


- Darryl

 ----------
  Darryl Friesen, B.Sc., Programmer/Analyst[EMAIL PROTECTED]
  Education  Research Technology Services, http://gollum.usask.ca/
  Department of Computing Services,
  University of Saskatchewan
 --
  "Go not to the Elves for counsel, for they will say both no and yes"




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




Re: [PHP-DB] Hold that insert!

2001-03-27 Thread Darryl Friesen

 I have the insertRecord function which is supposed to be called only
 when you hit submit. For some reason I'm blanking out on how to do
 this. The function and function call ARE on the same page. I think I
 just need some logic to indicate "stop" and "go".

Every form has a submit button right?  Submit buttons are form elements
(whose value is submitted when the button is clicked), just like any other
form field.  So I have something like this:

   INPUT NAME="submit" TYPE="submit" Value=" Click Here! "

In my PHP code, I check the value of $submit; if it's empty, I know the form
data hasn't been submitted yet (if it had, $submit would have the value "
Click Here! "), so in that case I display the form.  If it does not have an
empty value, the user has clicked the submit button, so I can go ahead
processing the form data.  Like this:

if ( empty($submit) )
{
### Display the form
}
else
{
### Do some checks to make the the data is OK

### Do the Insert, or whatever else is to be done
}



- Darryl

 ----------
  Darryl Friesen, B.Sc., Programmer/Analyst[EMAIL PROTECTED]
  Education  Research Technology Services, http://gollum.usask.ca/
  Department of Computing Services,
  University of Saskatchewan
 --
  "Go not to the Elves for counsel, for they will say both no and yes"



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




Re: [PHP-DB] A question - ($file_exists)

2001-03-27 Thread Darryl Friesen

 Whats wrong with this code?

 $img1 = "episodeID_a.jpg";
 $img2 = "episodeID_b.jpg";
 $img3 = "episodeID_c.jpg";

 $img$x="blank.jpg";

That doesn't what you expect.  I think the syntax is the same as Perl:

$var  = "$img$x"; #  $var hold the _name_ of the variable
  #  you want to change
$$var = "blank.jpg";  #  The $$ syntax is used to references the
  #  actual variable

See the section of the manual dealing with variables
(http://www.php.net/manual/en/language.variables.php)


- Darryl

 ----------
  Darryl Friesen, B.Sc., Programmer/Analyst[EMAIL PROTECTED]
  Education  Research Technology Services, http://gollum.usask.ca/
  Department of Computing Services,
  University of Saskatchewan
 --
  "Go not to the Elves for counsel, for they will say both no and yes"



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




Re: [PHP-DB] More on strings

2001-03-20 Thread Darryl Friesen

  $resultp = mysql_query("select Primaryid from primarycodes where Code =
 '".$row['Primaryexpertise']."'") or die (mysql_error());

  $resultp = mysql_query("select Primaryid from primarycodes where Code
like
 '%$row[Primaryexpertise]%'") or die (mysql_error());

  $pcodeid = mysql_fetch_array($resultp) or die("No pcodeid");

Two suggestions.:

First, stick the query into a variable instead of using it directly; that
way you can do some simple debugging (i.e. print the query to the page
instead of posting this email).  Second, take the array variable out of the
double quotes, like you did in the first line.

$sql = "select Primaryid from primarycodes where Code like'%" .
$row[Primaryexpertise] . "%'";
print $sql . "BR\n";
$resultp = mysql_query($sql) or die (mysql_error());


- Darryl

 ----------
  Darryl Friesen, B.Sc., Programmer/Analyst[EMAIL PROTECTED]
  Education  Research Technology Services, http://gollum.usask.ca/
  Department of Computing Services,
  University of Saskatchewan
 --
  "Go not to the Elves for counsel, for they will say both no and yes"




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




Re: [PHP-DB] Select where

2001-03-20 Thread Darryl Friesen

 Thanks, I only gave the mySQL but the php scripting is

 $deceased = mysql_query(SELECT * FROM members where
 status=\'deceased\'");
  and later
 while ($myrow = mysql_fetch_row($deceased))

 MySQL now says in relation to the *while* line
 Warning: Supplied argument is not a valid MySQL result resource

Yikes!  I hope those are typos, and that you didn't cut and paste that query
from your script.  If you did, then it needs some work.  Try:

$deceased = mysql_query("SELECT * FROM members where status='deceased'");

You need the leading double quote before SELECT, and you don't need to
escape the single quotes.


- Darryl

 ------
  Darryl Friesen, B.Sc., Programmer/Analyst[EMAIL PROTECTED]
  Education  Research Technology Services, http://gollum.usask.ca/
  Department of Computing Services,
  University of Saskatchewan
 --
  "Go not to the Elves for counsel, for they will say both no and yes"



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




Re: [PHP-DB] Re: [PHP] Query - Grouping Results

2001-03-19 Thread Darryl Friesen

 Doesn't seem to work, how would I print that out with PHP?

The results will come back sorted by name, then time.  While processing each
row, you'll need to keep track of when the username changes, something like
this (this is just rough code, not quite valid PHP):

$username = '';
while ($data = fetchrow)
{
if ($username != $data['name'])
{
$username = $data['name'];
print "Logins for " . $username . "\n\n";
}
print $login . "\n";
}

Keep track of the current user.  As you examine each record, check if it's
different than the current one.  If it is, save it as the current username,
and print the login info.  If it's the same, just print the login info.


- Darryl

 ----------
  Darryl Friesen, B.Sc., Programmer/Analyst[EMAIL PROTECTED]
  Education  Research Technology Services, http://gollum.usask.ca/
  Department of Computing Services,
  University of Saskatchewan
 --
  "Go not to the Elves for counsel, for they will say both no and yes"



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




Re: [PHP-DB] Default port on sybase_connect()

2001-03-15 Thread Darryl Friesen

 In the documentation for sybase_connect() the 'interfaces' file is
 mentioned. Where is this file on php4 for win32, and what is the syntax
for
 defining a server including a specific port?


It's in whatever directory you installed FreeTDS or the Sybase client.  It
should be fairly obvious by looking at the file how to change the port
number.  Also, check out the documentation that came with FreeTDS/Sybase.


- Darryl

 --
  Darryl Friesen, B.Sc., Programmer/Analyst[EMAIL PROTECTED]
  Education  Research Technology Services, http://gollum.usask.ca/
  Department of Computing Services,
  University of Saskatchewan
 --
  "Go not to the Elves for counsel, for they will say both no and yes"



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




Re: [PHP-DB] mysql_fetch_array problem...!

2001-03-05 Thread Darryl Friesen

 How can I refer to one specific row in this query..?
 What I mean is, how can i refer to result row number 4...?

 If I only selected rows from one table I could do something like this:

 $i = mysql_fetch_array($sql) ;
 echo "$i[4]" ;

Actually, no.  mysql_fetch_array return the _current row_ from the query
(use this function in a loop to process each row of the resulting data).
$i[4] in your case is the fourth field in the current row.

If you really don't want to process the rows in order, look at the
documentation for mysql_data_seek; it can be used to jump around the result
set.


- Darryl

 ------
  Darryl Friesen, B.Sc., Programmer/Analyst[EMAIL PROTECTED]
  Education  Research Technology Services, http://gollum.usask.ca/
  Department of Computing Services,
  University of Saskatchewan
 --
  "Go not to the Elves for counsel, for they will say both no and yes"



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




Re: [PHP-DB] Drop down box

2001-03-01 Thread Darryl Friesen



 The action you want is only available using JavaScript.

 You need to submit the form without a submit button.
 The "select" tag has the "OnChange" event which is scriptable. You
 can use the JavaScript statement "this.form.submit();" associated
 with the "OnChange" event.

 form... select name="x" OnChange="this.form.submit();"option..
 /select.../form

It's a good idea to include the submit button as well, for browers that
don't support javascript, or for those who turn it off.  That way your site
will always work properly.





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




Re: [PHP-DB] Resolution detect and redirect

2001-02-27 Thread Darryl Friesen

Why not just create a table that will resize to any resolution?

 Because I am using different sized images for the different resolutions
as
 well as other page thingys.

 And I need the script for other things too.

 So can anyone help?

Is there anyway to convince you this is a very very bad idea?  Leave the
choice up to the user.

Why?  Sure, my screen resolution is 1024x768, but I never run the browser
full screen (I'd bet 99% of people don't), so forcing me to view a page that
only looks good at 1024x768 when my window size is closer to 800x600 just
annoys me (I've seen a few sites like that; left immediatly even though they
were good sites).

If I have the choice, I'll pick the one I think is closest to my current
window size.  I've seen several sites that do this.  Much better.

Another reason not to do this is all the extra work in maintaining all the
different versions of pages/images etc.  Better to spend the time writing
PHP code. :)


- Darryl

 --
  Darryl Friesen, B.Sc., Programmer/Analyst[EMAIL PROTECTED]
  Education  Research Technology Services, http://gollum.usask.ca/
  Department of Computing Services,
  University of Saskatchewan
 --
  "Go not to the Elves for counsel, for they will say both no and yes"





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




Re: [PHP-DB] Hide Files

2001-02-19 Thread Darryl Friesen

   ($file_name !="*.php")

 how come that still displays all the *.php files?

Because that's an exact string match for a file called '*.php' which
probably doesn't exist.  Try some thing like

 (substr($file_name, -4) != '.php')

That should exclude all files ending in '.php'.


- Darryl

 ------
  Darryl Friesen, B.Sc., Programmer/Analyst[EMAIL PROTECTED]
  Education  Research Technology Services, http://gollum.usask.ca/
  Department of Computing Services,
  University of Saskatchewan
 --
  "Go not to the Elves for counsel, for they will say both no and yes"



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




Re: [PHP-DB] Basic MySQL question

2001-02-15 Thread Darryl Friesen

 At someone's advice, I found mysqladmin w/ "whereis mysqladmin" and later
 did ./bin/mysqladmin in the mysql installation dir (which got me a
printout
 of a bunch of commands for use with mysqladmin, but none of them worked),
 but I still can't get anywhere.

Is the mysql server process running?  I assume this is a unix box of some
sort.  Try "ps -ef | grep mysqld".  Get any results?


- Darryl

 ----------
  Darryl Friesen, B.Sc., Programmer/Analyst[EMAIL PROTECTED]
  Education  Research Technology Services, http://gollum.usask.ca/
  Department of Computing Services,
  University of Saskatchewan
 --
  "Go not to the Elves for counsel, for they will say both no and yes"



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




Re: [PHP-DB] Apache, PHP4, access problem to MS SQL 7.0

2001-02-14 Thread Darryl Friesen

 Can anybody help me about my serious problem to connect to MS SQL 7.0. I
 tried to use the freetds-driver but i'm not able to connect with it. They
 said that I must define the Serverconnection in the interfaces-file. I
found
 one in the freetds-directory but i don't know how to write it correct.
I've
 got a Linux-webserver and MS SQL runs on a WinNT4.0-Server.

There should be a file called 'interfaces' in whatever directory you
installed FreeTDS (our is in /usr/local/freetds).  That file lists all the
Sybase/MSSQL servers you can connect to.  Ours looks like this:

server1
query tcp tds4.2 128.233.x.y 1433
server2
query tcp tds7.0 128.233.x.y 1433

(substitute 128.233.x.y for the real IP numbers of your server).

For a 'standard' install of MSSQL server the port number is 1433.  Took me a
while to find that.  If you're using FreeTDS, the third parameter of the
interfaces file can be the version of TDS protocol to use when talking to
that server.

Also, make sure you have the SYBASE environment variable set to the
directory where FreeTDS is installed.

I'd recommend trying sqsh (SQL command line shell for Sybase servers --
works with MSSQL as well) to test the connection.  It assumes a full Sybase
install, so the Makefile took a little tweaking in order to get it to
compile, but once installed it will help you debug the connection problem,
test your queries etc.
Not sure of a download site, but if you search Google you're bound to find
it.

Hope that helps.


- Darryl

 --
  Darryl Friesen, B.Sc., Programmer/Analyst[EMAIL PROTECTED]
  Education  Research Technology Services, http://gollum.usask.ca/
  Department of Computing Services,
  University of Saskatchewan
 --
  "Go not to the Elves for counsel, for they will say both no and yes"



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




Re: [PHP-DB] what's a core file?

2001-02-07 Thread Darryl Friesen

 ran a few php scripts retrieiving info from mysql database to check /
 test things, and ended up with a file called "core" in the same new
 directory created for this purpose. any one know what a "core" file is?
 or why it's there? the scripts were little, under 10k, but the core file
 is 3mb

That's a tiny one.  :)

When a program dies a horrible and nasty death, it produces a core file
("dumps core").  If you have the knowledge and tools, you can debug what
went wrong using these core files.  (someone will explain it better, I'm
sure)

If your PHP script, or mysql server is dumping core, you've got big problems
that need addressing.


- Darryl

 ----------
  Darryl Friesen, B.Sc., Programmer/Analyst[EMAIL PROTECTED]
  Education  Research Technology Services, http://gollum.usask.ca/
  Department of Computing Services,
  University of Saskatchewan
 --
  "Go not to the Elves for counsel, for they will say both no and yes"



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




Re: [PHP-DB] installing

2001-02-06 Thread Darryl Friesen

 You
 will also need to have Personal Web Server installed on your workstation.
 Internet Explorer is not setup to run php by itself.  It needs a webserver
 to do it.

 If you don't want to use Micrsofts Personal Web Server, you can download
the
 win32 version of Apache at www.apache.org.

I wouldn't bother with PWS.  Apache or Xitami (www.xitami.com) are far
easier to setup.  I've installed PHP under both, with no problems.


- Darryl

 --
  Darryl Friesen, B.Sc., Programmer/Analyst[EMAIL PROTECTED]
  Education  Research Technology Services, http://gollum.usask.ca/
  Department of Computing Services,
  University of Saskatchewan
 --
  "Go not to the Elves for counsel, for they will say both no and yes"



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




Re: [PHP-DB] insert into mysql

2001-01-29 Thread Darryl Friesen

$sql = "INSERT INTO ecomm (ID,part) VALUES ('$sid','$spp')";
 
  Another thought:  Are ID and part character data of some sort?  If not
(i.e.
  if ID is an int) then remove the single quotes.
 
 A trivial point this, but if you insert values in ' into a mysql int
 column then MySQl still treats it as intended. THey aren' necessary for
 int columns, but it is acceptable to have them there

Thanks for pointing that out Tom.  That's a good bit of info to tuck away
for later.

We've been using MSSQL Server 7 here quite a bit lately, and it isn't nearly
as forgiving.  :(

- Darryl

 ------
  Darryl Friesen, B.Sc., Programmer/Analyst[EMAIL PROTECTED]
  Education  Research Technology Services, http://gollum.usask.ca/
  Department of Computing Services,
  University of Saskatchewan
 --
  "Go not to the Elves for counsel, for they will say both no and yes"



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




Re: [PHP-DB] insert into mysql

2001-01-25 Thread Darryl Friesen



 It still didn't work.
 just says unable to add part

  $sql = "INSERT INTO ecomm (ID,part) VALUES ('$sid','$spp')";

Another thought:  Are ID and part character data of some sort?  If not (i.e.
if ID is an int) then remove the single quotes.


- Darryl

 ------
  Darryl Friesen, B.Sc., Programmer/Analyst[EMAIL PROTECTED]
  Education  Research Technology Services, http://gollum.usask.ca/
  Department of Computing Services,
  University of Saskatchewan
 --
  "Go not to the Elves for counsel, for they will say both no and yes"



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




Re: [PHP-DB] Child tables in MySQL

2001-01-19 Thread Darryl Friesen



 How about creating a separate table for each user and a column in the
 main table pointing to these user preference tables

I missed the first part of this thread, so forgive me if I'm missing
something, but that seems like a very bad idea.

What if 10,000 people sign up (for whatever this service is)?  Do you really
want 10,000 tables in your database?  Is it not possible to have a single
table for users (one row per user) with preferences in that same table
(perhaps encoded somehow to save space)?  Or a table for users, one for the
different preference options, and third to join them?


- Darryl

 --
  Darryl Friesen, B.Sc., Programmer/Analyst[EMAIL PROTECTED]
  Education  Research Technology Services, http://gollum.usask.ca/
  Department of Computing Services,
  University of Saskatchewan
 --
  "Go not to the Elves for counsel, for they will say both no and yes"



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