[PHP-DB] Re: Screen size, browser on php

2003-02-28 Thread Bastian Vogt
 Is there a way of getting from php the screen size?

Sorry but as php is only server-side, there is no way to get the screen
size. You have to use javascript and send the result to the page again, as
you suggested yourself.

Regards,
Bastian


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



RE: [PHP-DB] Re: Parse Error

2003-02-28 Thread Matthew Moldvan
Actually this is incorrect also and will only result in another parse error
... you have (), which is fine, but then {)}, which doesn't make any sense
to the parser.

Regards,
Matthew Moldvan

---
 System Administrator
 Trilogy International, Inc
  http://www.trilogyintl.com/ecommerce/
--- 

-Original Message-
From: Alejandro Trujillo J. [mailto:[EMAIL PROTECTED]
Sent: Wednesday, February 26, 2003 10:15 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Re: Parse Error


if ($packages == 1)
{
if ($airporttransfer == car) {$airporttransfer2 = 12.00);}
if ($airporttransfer == bus) {$airporttransfer2 = 10.00);}
if ($airporttransfer == none){$airporttransfer2 = 0.00);}
}

try to learn to use the TABS and the BRACES coz is good for you and for who 
are reading the CODE.

-- 
Alejandro Trujillo J.
Cube Systems LTDA.
web : csltda.com

Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/

-- 
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] Screen size, browser on php

2003-02-28 Thread Paul Burney
on 2/27/03 11:09 PM, Petre NICOARA at [EMAIL PROTECTED] appended the
following bits to my mbox:

 I've found this stuff into a javascript, but I need to be able to
 retrieve it through php, only in one file. The javascript is doing this
 through 2 file, one get the info, and passes it to a form in the other.
 So, my dilemma is if
 Is there a way of getting from php the screen size?

No.  What you could do, however, is something like:

- JavaScript code to get screen size

- use document.write to generate the image tag with additional parameters
for screen size, i.e.:

img src=somescript.php?w=615h=420

- Have your php script output the correct Content-type header for the image
and pass it through while logging the info you want.

HTH.

Sincerely,

Paul Burney
http://paulburney.com/

?php
while ($self != asleep) {
$sheep_count++;
}
?

 


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



[PHP-DB] Date

2003-02-28 Thread Jorge Miguel Fonseca Martins
How can a make a query that lists all the fields where a datefield as
the date of tomorow?
 
thanks
 


RE: [PHP-DB] Date

2003-02-28 Thread Snijders, Mark
go to mysql.com en look for date



-Original Message-
From: Jorge Miguel Fonseca Martins [mailto:[EMAIL PROTECTED]
Sent: vrijdag 28 februari 2003 16:23
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Date


How can a make a query that lists all the fields where a datefield as
the date of tomorow?
 
thanks
 


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



[PHP-DB] Storing an array in the database

2003-02-28 Thread Jonathan Villa

How would I store an array in the database?  I want to store 2 things.
One array of shirt sizes and one array of which holds other arrays.


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



RE: [PHP-DB] Storing an array in the database

2003-02-28 Thread Hutchins, Richard
You could store it as a series of comma separated values in a text field and
manipulate it using implode() and explode() on the comma separators. I've
done this for small arrays and it works OK. WOuld like to know if there's an
easier way though. Not that this is all that bad. I'm just lazy. ;^)

HTH
Rich

 -Original Message-
 From: Jonathan Villa [mailto:[EMAIL PROTECTED]
 Sent: Friday, February 28, 2003 11:10 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] Storing an array in the database
 
 
 
 How would I store an array in the database?  I want to store 2 things.
 One array of shirt sizes and one array of which holds other arrays.
 
 
 -- 
 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] Storing an array in the database

2003-02-28 Thread Terry Romine
just as a quick fix. I use the following snip to take an array of 
choices, enter it into a varchar field (or text if you expect alot) and 
extract back to array:
	$choicesArray is a list of checkboxes from a form
	
// put data into table
	$checkList = implode(;, $choicesArray);
	mysql_query(update table set choices='$checkList' where id=$itemID);
	...
// get data out of table
	mysql_query(select choices from table where id=$itemID);
	$choiceArray=explode(;,$row['choices']);

// this is of course, rough and simplified, but you should get the idea.

Terry

On Friday, February 28, 2003, at 10:09 AM, Jonathan Villa wrote:

How would I store an array in the database?  I want to store 2 things.
One array of shirt sizes and one array of which holds other arrays.


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


Re: [PHP-DB] Storing an array in the database

2003-02-28 Thread Ignatius Reilly
If your array is multidimensional, you could store it in a javascript-style:
// get the print_r()
// replace (recursively) all instances of Array( .. ) by [...]

If you ever plan to write a class or a function to do that, let me know!

Ignatius

- Original Message - 
From: Jonathan Villa [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, February 28, 2003 5:09 PM
Subject: [PHP-DB] Storing an array in the database


 
 How would I store an array in the database?  I want to store 2 things.
 One array of shirt sizes and one array of which holds other arrays.
 
 
 -- 
 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] Storing an array in the database

2003-02-28 Thread Chris Boget
 How would I store an array in the database?  I want to store 2 things.
 One array of shirt sizes and one array of which holds other arrays.

Easy.

script language=php

  $singleDimArray = array( 1, 2, 3, 4, 5 );
  $multiDimArray   = array( array( this = that, here = there ),
array( near = far, wherever = you are )); // hehe

  $query = INSERT INTO table
 ( field1, field2 )
 VALUES
 ( \ . serialize( $singleDimArray ) . \, \ . serialize( 
$multiDimArray ) . \ );

  $result = mysql_query( $query );
  
  $selectQuery = SELECT * FROM table;
  $result = mysql_query( $selectQuery );
  
  $fetchedRecord = mysql_fetch_assoc( $result );
  
  $singleDimArray = unserialize( $fetchedRecord['field1'] );
  $multiDimArray  = unserialize( $fetchedRecord['field2'] );
  
/script

serialize() is your friend when it comes to storing arrays in
a DB field.

Chris


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



RE: [PHP-DB] Storing an array in the database

2003-02-28 Thread Jonathan Villa
Thanks!

I checked out the php docs, 

serialize() returns a string containing a byte-stream representation of
value that can be stored anywhere.

Perfect!

 
--- Jonathan
 
 
 
-Original Message-
From: Chris Boget [mailto:[EMAIL PROTECTED] 
Sent: Friday, February 28, 2003 10:43 AM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Storing an array in the database

 How would I store an array in the database?  I want to store 2 things.
 One array of shirt sizes and one array of which holds other arrays.

Easy.

script language=php

  $singleDimArray = array( 1, 2, 3, 4, 5 );
  $multiDimArray   = array( array( this = that, here = there
),
array( near = far, wherever = you
are )); // hehe

  $query = INSERT INTO table
 ( field1, field2 )
 VALUES
 ( \ . serialize( $singleDimArray ) . \, \ .
serialize( $multiDimArray ) . \ );

  $result = mysql_query( $query );
  
  $selectQuery = SELECT * FROM table;
  $result = mysql_query( $selectQuery );
  
  $fetchedRecord = mysql_fetch_assoc( $result );
  
  $singleDimArray = unserialize( $fetchedRecord['field1'] );
  $multiDimArray  = unserialize( $fetchedRecord['field2'] );
  
/script

serialize() is your friend when it comes to storing arrays in
a DB field.

Chris



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



[PHP-DB] Interbase locking

2003-02-28 Thread Koleszr Tibor
Hello,

I've an interbase locking question. Sometime i got interbase deadlock from
php scripts at updates and at inserts. I'm using simple ibase_query, and as
i've
read the manual of the interbase, it should handle the locking with the
default transaction
WAIT option. Is it enoug to using ibase_query(); or I have to use
ibase_trans();?
Interbase (PHP's interbase function) wont lock with a simple query?

Can someone help me its getting dangerous, and I've found nothing usefull at
google or at borland.

Thanks

Tibor



--
Integranet Internet Service Provider Co. - www.integranet.hu
GnuPG fingerprint: 189C B343 71A8 C25F 7456  F46F D522 C34C ED7F A574
Koleszr Tibor, Director and Senior System Engineer, Debian Developer
[EMAIL PROTECTED], [EMAIL PROTECTED], http://www.oldw.net



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



Re: [PHP-DB] Storing an array in the database

2003-02-28 Thread 1LT John W. Holmes
 How would I store an array in the database?  I want to store 2 things.
 One array of shirt sizes and one array of which holds other arrays.

$safe = addslashes(serialize($array));

and store $safe into a text column. Use 

$array = unserialize($database_data);

to get the array back. 

---John Holmes...

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



Re: [PHP-DB] Storing an array in the database

2003-02-28 Thread 1LT John W. Holmes
  How would I store an array in the database?  I want to store 2 things.
  One array of shirt sizes and one array of which holds other arrays.
[snip]
   $query = INSERT INTO table
  ( field1, field2 )
  VALUES
  ( \ . serialize( $singleDimArray ) . \, \ .
serialize( $multiDimArray ) . \ );

FYI: Make sure you addslashes() _after_ you serialize your array if it can
contain quotes. Everything else remains the same.

---John Holmes...


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



Re: [PHP-DB] Storing an array in the database

2003-02-28 Thread Chris Boget
 FYI: Make sure you addslashes() _after_ you serialize your array if it can
 contain quotes. Everything else remains the same.

Yeah, my bad.  Good catch.

Chris


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



[PHP-DB] Code to send user info to database

2003-02-28 Thread Michelle Whelan

Hi all, 

I'm just starting out with writing PHP and would like to get help with writing the 
code for my forms to have the data sent to a database.  Here is one of my forms:

?php
if ($submit == Submit){ 
  echo Your listing has been submitted; 
  echo Go back a href=Homewww.dirtjobs.com/index.phpHome/a;
  echo a href=Addwww.dirtjobs.com/havedirt.phpAdd another listing/a;
} 
else{ 
  echo ' 

form method=post action=.php name=

table width=100%
trtdimg src=images/xhavedirt.gif width=191 height=40/td
/tr

trtdnbsp;/td/tr

trtdfont face=Arial, Helvetica, sans-serif, Verdana size=2 
color=#FFbWHAT TYPE OF DIRT?/font
  
SELECT NAME=needdirtype
option value=cleanCLEAN DIRT FOR FINISH GRADING
option value=minusDIRT WITH 6 MINUS ROCKS
option value=rocksDIRT WITH ROCKS
/SELECT/td
/tr

 
trtdfont face=Arial, Helvetica, sans-serif, Verdana size=2 
color=#FFbAPPROXIMATE QUANTITY OF DIRT IN YARDS:
input type=text size=7 maxlength=7 name=noyardsYards/font/td
/tr

trtdnbsp;/td/tr

trtdfont face=Arial, Helvetica, sans-serif, Verdana size=2 
color=redbui*MANDATORY*/font/b/i/u/td
/tr

trtdfont face=Arial, Helvetica, sans-serif, Verdana size=2 
color=#FFbCONTACT NAME:/b/font
input type=text size=25 maxlength=25 name=contactname/td
/tr
 
trtdfont face=Arial, Helvetica, sans-serif, Verdana size=2 
color=#FFbCONTACT PHONE NUMBER:/b
input type=text size=3 maxlength=3 name=areacode 
input type=text size=3 maxlength=3 name=prefix 
trtdfont face=Arial, Helvetica, sans-serif, Verdana size=2 color=#FF - 
input type=text size=4 maxlength=4 name=suffix/td
/font/tr

trtdfont face=Arial, Helvetica, sans-serif, Verdana size=2 
color=#FFbZIP CODE:/b
input type=text size=5 maxlength=5 name=zip code
br
i(Jobs are sorted by zip code to find other jobs in the area)/i/font/td
/tr

trtdfont face=Arial, Helvetica, sans-serif, Verdana size=2 
color=#FFbJOB EXPIRATION DATE:/b/font 
input type=text size=12 maxlength=12 name=expdate
br
i(If no date is listed, jobs will be removed in 60 days.)/i/font/td
/tr

trtdnbsp;/td/tr

trtdfont face=Arial, Helvetica, sans-serif, Verdana size=2 
color=blueb(*Optional)/b/font/td
/tr

trtdfont face=Arial, Helvetica, sans-serif, Verdana size=2 
color=#FFbEMAIL ADDRESS:/b/font
input type=text size=30 maxlength=30 name=email/td
/tr

trtdfont face=Arial, Helvetica, sans-serif, Verdana size=2 
color=#FFbCITY OF JOB LOCATION:/b/font
input type=text size=30 maxlength=30 name=jobcity/td
/tr

trtdfont face=Arial, Helvetica, sans-serif, Verdana size=2 
color=#FFbJOB CROSS STREETS:/b/font
input type=text size=58 maxlength=58 name=xstreets/td
/tr
 
trtdfont face=Arial, Helvetica, sans-serif, Verdana size=2 
color=#FFbJOB EXPIRATION DATE:/b
input type=text size=12 maxlength=12 name=exp.date
br
i(If no date is listed, jobs will be removed in 60 days.)/i/font/td
/tr

trtdnbsp;/td/tr

trtdcenterinput type=submit name=submit value=Submit/inputnbsp
input type=reset name=reset value=Clear/input/center/td
/tr
/table

I imagine the code is probably somewhat simple, but I have read tutorial after 
tutorial etc. and am getting nowhere for the past two weeks.  

This is also the first time I have ever posted to a mailing list so I apologize if my 
request is incorrect in format.  

Thanks so much, 

Michelle 



[PHP-DB] phpMyAdmin

2003-02-28 Thread Jonathan Villa

Ok, maybe this is strictly a phpMyAdmin Q, but I'm sure many of use it
=)

I have a server at home which runs phpMyAdmin.
I also run it locally on my laptop.  The cfg_uri for both is
http://localhost/phpMyAdmin/

When I open a web browser (IE), I go to
http://mydomainonmyserverathome/phpMyAdmin
Then when I try to work with my database at home.

All of a sudden, it acts as if I were trying to work on the db which is
on my laptop.

So here are my steps:

1.  go to http://mydomainonmyserverathome/phpMyAdmin
2.  Try to create a table which exists on my laptop but not on my
server at home
3.  Get message that table already exists
4.  view list of tables on the left nav and they contain all the
db's which are on my laptop.


Help please!!!



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



[PHP-DB] Unknown() error

2003-02-28 Thread AP Fritts
Hi!  I am having a problem with Unknown() error.
Here is my code:

echo 2;
mysql_query(INSERT INTO sessions SET sessionid='{$sid}',
ipaddr='{$_SERVER[REMOTE_ADDR]}, page='{$_SERVER[SCRIPT_FILENAME]}',
dt='.$dt.')
   or OnErr(2);
echo 3;

I get this error:

Notice: Unknown(): The session bug compatibility code will not try to locate
the global variable $15 due to its numeric nature. in Unknown on line 0

I know that it has to do with the mysql_query line because the system prints
out 2 but doesn't print 3.

Thanks in advance for your help,
AP Fritts



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



RE: [PHP-DB] Unknown() error

2003-02-28 Thread Hutchins, Richard
Just a guess, but do you have a variable (global variable) named $15
someplace? If you do, PHP does not allow variable names that start with
numbers.

 -Original Message-
 From: AP Fritts [mailto:[EMAIL PROTECTED]
 Sent: Friday, February 28, 2003 3:51 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] Unknown() error
 
 
 Hi!  I am having a problem with Unknown() error.
 Here is my code:
 
 echo 2;
 mysql_query(INSERT INTO sessions SET sessionid='{$sid}',
 ipaddr='{$_SERVER[REMOTE_ADDR]}, 
 page='{$_SERVER[SCRIPT_FILENAME]}',
 dt='.$dt.')
or OnErr(2);
 echo 3;
 
 I get this error:
 
 Notice: Unknown(): The session bug compatibility code will 
 not try to locate
 the global variable $15 due to its numeric nature. in Unknown 
 on line 0
 
 I know that it has to do with the mysql_query line because 
 the system prints
 out 2 but doesn't print 3.
 
 Thanks in advance for your help,
 AP Fritts
 
 
 
 -- 
 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] Customer id

2003-02-28 Thread Dan Kelly
How do I write a script that will automatically create an ID in the 
database. Here is a sample

-- orderform.shtml 

form action=order.php method=post
First Nameinput type=text name=fnamebr
Last Nameinput type=text name=lname

input type=submit name=submit value=enter
input type=reset name=Clear
--Order.php 
--
?PHP
include('dbconnect.php');

if ($submit == enter)
{
   $query = insert into orders
 (fname,lname) values
 ('$fname','$lname') ;
mysql_query($query) or
 die (mysql_error());
}
?
Any Ideas? Thanks, Dan


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


RE: [PHP-DB] Customer id

2003-02-28 Thread Jonathan Villa
Create a customer_id field in the database, make it primary, int, and
autoincrement

 
--- Jonathan
 
 
 

-Original Message-
From: Dan Kelly [mailto:[EMAIL PROTECTED] 
Sent: Friday, February 28, 2003 6:52 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Customer id

How do I write a script that will automatically create an ID in the 
database. Here is a sample

-- orderform.shtml 

form action=order.php method=post
First Nameinput type=text name=fnamebr
Last Nameinput type=text name=lname

input type=submit name=submit value=enter
input type=reset name=Clear

--Order.php 
--
?PHP
include('dbconnect.php');

if ($submit == enter)
{
$query = insert into orders
  (fname,lname) values
  ('$fname','$lname') ;
mysql_query($query) or
  die (mysql_error());
}
?
Any Ideas? Thanks, Dan



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

2003-02-28 Thread Hutchins, Richard
You need to create a column in the target table similar to:
custID SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT
When you run your INSERT query, you pass NULL to that column and the ID will
be created/auto incremented for you.

Is that what you mean?
Rich

 -Original Message-
 From: Dan Kelly [mailto:[EMAIL PROTECTED]
 Sent: Friday, February 28, 2003 7:52 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] Customer id
 
 
 How do I write a script that will automatically create an ID in the 
 database. Here is a sample
 
 -- orderform.shtml 
 
 form action=order.php method=post
 First Nameinput type=text name=fnamebr
 Last Nameinput type=text name=lname
 
 input type=submit name=submit value=enter
 input type=reset name=Clear
 
 --Order.php 
 --
 ?PHP
 include('dbconnect.php');
 
 if ($submit == enter)
 {
 $query = insert into orders
   (fname,lname) values
   ('$fname','$lname') ;
 mysql_query($query) or
   die (mysql_error());
 }
 ?
 Any Ideas? Thanks, Dan
 
 
 
 -- 
 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] worked

2003-02-28 Thread Dan Kelly
Hey that worked guys.. Thanks..Dan

You need to create a column in the target table similar to:
custID SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT
When you run your INSERT query, you pass NULL to that column and the ID will
be created/auto incremented for you.
Is that what you mean?
Rich

-Original Message-
From: Dan Kelly [mailto:[EMAIL PROTECTED]
Sent: Friday, February 28, 2003 7:52 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Customer id
How do I write a script that will automatically create an ID in the 
database. Here is a sample

-- orderform.shtml 

form action=order.php method=post
First Nameinput type=text name=fnamebr
Last Nameinput type=text name=lname

input type=submit name=submit value=enter
input type=reset name=Clear
--Order.php 
--
?PHP
include('dbconnect.php');

if ($submit == enter)
{
$query = insert into orders
  (fname,lname) values
  ('$fname','$lname') ;
mysql_query($query) or
  die (mysql_error());
}
?
Any Ideas? Thanks, Dan


 



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


[PHP-DB] pgp support

2003-02-28 Thread M Hemmings

Hi all ! does anyone know if there is a way to get pgp support in

php.



-
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, and more

[PHP-DB] Creating MySQL Entry Forms

2003-02-28 Thread Jeremy N.E. Proffitt
I need to create some simple web forms for entering, changing, deleteing information 
from a fairly simple MySQL database.  This is to be for internal use, so doesn't have 
to be really fancy or have alot of error checking.
  I could make a form for each table myself, but I would think their is an easier 
way...

Cheers
Jeremy

Re: [PHP-DB] Creating MySQL Entry Forms

2003-02-28 Thread Leif K-Brooks
What's wrong with PhpMyAdmin?

Jeremy N.E. Proffitt wrote:

I need to create some simple web forms for entering, changing, deleteing information 
from a fairly simple MySQL database.  This is to be for internal use, so doesn't have 
to be really fancy or have alot of error checking.
 I could make a form for each table myself, but I would think their is an easier way...
Cheers
Jeremy
 

--
The above message is encrypted with double rot13 encoding.  Any unauthorized attempt 
to decrypt it will be prosecuted to the full extent of the law.


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


RE: [PHP-DB] Re: Get MySQL table schema for a dump

2003-02-28 Thread Daevid Vincent
The wrap it in an exec() or one of the other exec type functions  ;)

$result = exec(mysqldump -uMyUser -pMyPass MyDB  db_dump_file.sql);

 -Original Message-
 From: Jonathan Villa [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, February 26, 2003 3:36 PM
 To: [EMAIL PROTECTED]
 Subject: RE: [PHP-DB] Re: Get MySQL table schema for a dump
 
 
 Sorry, I should have explained that I want to do this via PHP.
 
  
 --- Jonathan
  
  
  
 
 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf
 Of Fredrik de Vibe
 
 Sent: Wednesday, February 26, 2003 5:31 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] Re: Get MySQL table schema for a dump
 
 [EMAIL PROTECTED] (Jonathan Villa) writes:
  Is there was to get a database's table schema?
 
 I don't think it's called schemas in mysql, but I'm not sure :-)
 
  So far, I have a simple function which will output 
  INSERT INTO table (x,x,x,) VALUES(x,x,x);
  [ ... ]
  but what I'm missing is 
  CREATE table blah, blah, blah
 
 mysqldump is the tool you need.
 
 e.g.
   $ mysqldump -u user [-p] Database  db_dump_file.sql
 
 man mysqldump for more info.
 
 
 -- 
 --Fredrik
 If God is dead, who will save the Queen?
 
 -- 
 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 Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] Making Join

2003-02-28 Thread Daniel Harik
  Hello,
 
  I have 2 tables users table, that stores user info, and photos table,
  i want to select all users with one photo form photos table, but i don't
  want it to be photos * users = result.
 
  Is there way to do it?
 
 Assuming you mean, you have a table called user_info and another called
 photos and each of them has a common element AND there must be a photo for
 the user then you could use this sort of select...
 
 select user_info.name, photo.image from user_info, photo where 
user_info.id
 = photo.user_id
 
 The above will not display anything if there are no matching id to user_id
 so if one of your users didn't have a photo they would not get displayed.
 Also, if a user had more than one photo they would all be displayed.
 
 If your users are expected to have one and only one photo then you may 
want
 get rid of the photo table and just put the photo in the user table.
 
 HTH


Thank You for your reply, but the problem is that users may have many
photos, and i need to get only one, i use folllowing sql:
SELECT users.username, photos.file FROM users left join photos on
users.id=photos.userid


And i get:

 username file
dan  9a2de085e456e78ed66f079572638ff3.jpg
dan  852d28e6fa730f6d29d69aacd1059ae7.jpg
dan  672df2f16e89e3dc92ff74e3a0fa4b4f.jpg
dan  8bae6f20ed6e12ba1c86d04b8ebc9e1f.jpg
dan  7de9d2db2b2096cfc3f072f8c15a9e50.jpg 
404  f474a8ee5965f0a792e5b626fb30c2cd.jpg
404  3acd391cf7abafa032c5e3b21eb7b322.jpg
404  4e5df8cfa4bce5dd30c1166b8a86fa23.jpg
Bedman  NULL

but i want only 3 users from this join, not 3x3=9



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



Re: [PHP-DB] Making Join

2003-02-28 Thread Paul Burney
on 2/28/03 3:15 PM, Daniel Harik at [EMAIL PROTECTED] appended the following
bits to my mbox:

 Thank You for your reply, but the problem is that users may have many
 photos, and i need to get only one, i use folllowing sql:
 SELECT users.username, photos.file FROM users left join photos on
 users.id=photos.userid
 
 And i get:
 
 username file
 dan  9a2de085e456e78ed66f079572638ff3.jpg
 dan  852d28e6fa730f6d29d69aacd1059ae7.jpg
 dan  672df2f16e89e3dc92ff74e3a0fa4b4f.jpg
 dan  8bae6f20ed6e12ba1c86d04b8ebc9e1f.jpg
 dan  7de9d2db2b2096cfc3f072f8c15a9e50.jpg
 404  f474a8ee5965f0a792e5b626fb30c2cd.jpg
 404  3acd391cf7abafa032c5e3b21eb7b322.jpg
 404  4e5df8cfa4bce5dd30c1166b8a86fa23.jpg
 Bedman  NULL
 
 but i want only 3 users from this join, not 3x3=9

So you just want the users who have pictures, but not all the pictures for
each?  Something like:

SELECT count(*) AS num_photos, username FROM photos LEFT JOIN users ON
photos.userid=users.id GROUP BY userid

You could add the file field in there as well, but it would only be
returning one of the files (the first or last one for that user, but I don't
know of a way for you to be specific).

Hope that helps.

Sincerely,

Paul Burney
http://paulburney.com/

Q: Tired of creating admin interfaces to your MySQL web applications?

A: Use MySTRI instead. Version 3.1 now available.
http://mystri.sourceforge.net/



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



Re: [PHP-DB] Making Join

2003-02-28 Thread Mark

--- Daniel Harik [EMAIL PROTECTED] wrote:
   Hello,
  
   I have 2 tables users table, that stores user info, and photos
 table,
   i want to select all users with one photo form photos table,
 but i don't
   want it to be photos * users = result.
  
   Is there way to do it?
  
  Assuming you mean, you have a table called user_info and another
 called
  photos and each of them has a common element AND there must be a
 photo for
  the user then you could use this sort of select...
  
  select user_info.name, photo.image from user_info, photo where 
 user_info.id
  = photo.user_id
  
  The above will not display anything if there are no matching id
 to user_id
  so if one of your users didn't have a photo they would not get
 displayed.
  Also, if a user had more than one photo they would all be
 displayed.
  
  If your users are expected to have one and only one photo then
 you may 
 want
  get rid of the photo table and just put the photo in the user
 table.
  
  HTH
 
 
 Thank You for your reply, but the problem is that users may have
 many
 photos, and i need to get only one, i use folllowing sql:
 SELECT users.username, photos.file FROM users left join photos on
 users.id=photos.userid
 
 
 And i get:
 
  username file
 dan  9a2de085e456e78ed66f079572638ff3.jpg
 dan  852d28e6fa730f6d29d69aacd1059ae7.jpg
 dan  672df2f16e89e3dc92ff74e3a0fa4b4f.jpg
 dan  8bae6f20ed6e12ba1c86d04b8ebc9e1f.jpg
 dan  7de9d2db2b2096cfc3f072f8c15a9e50.jpg 
 404  f474a8ee5965f0a792e5b626fb30c2cd.jpg
 404  3acd391cf7abafa032c5e3b21eb7b322.jpg
 404  4e5df8cfa4bce5dd30c1166b8a86fa23.jpg
 Bedman  NULL
 
 but i want only 3 users from this join, not 3x3=9

If you only want the users, and not the photos, then the previous
post should do what you want. But if you also want the photo, and
there's more than one photoo for a user, how will the code know which
photo you want? Do you want a random photo from each user? The last
photo from each user? The first?

Mark

=
Mark Weinstock
[EMAIL PROTECTED]
***
You can't demand something as a right unless you are willing to fight to death to 
defend everyone else's right to the same thing.
***

__
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/

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