[PHP-DB] Re: mysql results, arrays, and for loops

2004-06-13 Thread franciccio
Hi, here is my solution (one of the possible) it is tested so it should work
fine:

?php
$recordset=mysql_query($query);
$num_righe=mysql_num_rows($recordset);

// here starts the dinamyc table
echo TABLE align=\left\ border=\1\ cellspacing=\2\ cellpadding=\2\
width=\80%\\ntr;

$record= mysql_fetch_array($recordset, MYSQL_ASSOC);
foreach ($record as $k =$val)
{
echo tdb$k/b/td\n; // print the field name in the first row of
the table
for ($i=0;$i$num_righe;$i++)
{
echo /tr;
mysql_data_seek($recordset,$i);
$record = mysql_fetch_array($recordset, MYSQL_ASSOC);
foreach ($record as $val){
echo td$val/td\n; // print the result of query, starting under
1st row
}
}
mysql_free_result($recordset);
mysql_close();
echo /tr/tablebr;
?
Let me know if it fits your problem.
Best regards
Francesco Basile

Philip Thompson [EMAIL PROTECTED] ha scritto nel messaggio
news:[EMAIL PROTECTED]
 Hi all!

 I am using a select statement to obtain all the dates whenever someone
 submitted a problem in a database. Well, I want to get the result
 (which could be multiple dates) and then print that in a table format
 with some other information on a webpage. So I want to use a FOR loops
 and go through each of the dates and dynamically create a table.

 My question is: how do I store the results of the select query? Would I
 want to store them in an array, and then just parse through each
 element of the array, and what is the syntax for that? Or is there a
 better way?

 Thanks,
 ~Philip

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



[PHP-DB] Re: how to reuse DB results

2004-06-13 Thread franciccio
Sorry for mystakes, (shame on me, i said i was new) using Object array,
here is a working version (tested) with use of array.

Bye

$recordset=mysql_query('SELECT * FROM my_tabella'); // or whatever query is

/* define an array with fields to be shown on top of page. Attention
...values name must be the same of table field names you want to show on top
of the page*/
$my_key = array('key01','key02','key03'); /* u can use $_REQUEST variables
instead of
fixed values*/
$i=0;
while($record=mysql_fetch_array($recordset, MYSQL_ASSOC))
{
foreach ($record as $k=$val)
if ($k==$my_key[$i])
{
// echo the top of the page
echo p$k :$val/p;
/* if u need a top_array to store result shown on top of the
page, comment this line only
$top_array[$i]=$val; // loose the matching key-field!! */
$i++;
}
}

//reset the resource
mysql_data_seek($recordset,0);

// some middle-page code here

echo 'pthis is the bottom page and displays the whole result/p';
while ($record=mysql_fetch_array($recordset, MYSQL_ASSOC))
foreach ($record as $k=$val)
echo p$k : $val/p; // make your choice for html code

mysql_free_result($recordset);

// Bye

Aaron Wolski [EMAIL PROTECTED] ha scritto nel messaggio
news:[EMAIL PROTECTED]
 Hi All,

 Got this logic problem I don't know how to solve.

 Is there any way I can make a call to the DB for some records.

 Display some info from a column or two say at the top of the page and
 then display the full result set in a while() loop?

 Right now, I am making two calls to the Db to get the data I need to
 display at the top of the page and then a second query to retrieve the
 full result set.

 I'm confused!

 Thanks for any help!

 Aaron

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



[PHP-DB] Re: Retrieve data from a table, edit/add it and enter it in a new table

2004-06-13 Thread franciccio
I see one bug in your code , that is you never rewind the pointer of
mysql_fetch_array($result), so at the end of the first cycle ...while
($r=mysq...)... the pointer is at the end of the query resource. You should
use mysql_data_seek($result,0) to rewind before doing another while cycle.
Hope it can help

Bye

Francesco Basile (PHP_newbee)

Justin [EMAIL PROTECTED] ha scritto nel messaggio
news:[EMAIL PROTECTED]
Hi,

I am trying to do the following:

Retrieve some information from a table, edit it by appending some further
information to it (a few more fields) and then enter the new data record
into a new table, and delete the old data in the original table. Sounds
confusing I know.

The code is below (I apologise for its poor style etc as I am very new to
php), but when I click on the  'Enter Information' button, nothing happens.
The existing data is retrieved without any problems and I can select it
using the radio button. But when I try and add data to the new fields
('option_close_price' and 'notes'), nothing happens.

Any help appreciated.


form action=? echo $PHP_SELF ? method=post
?
mysql_pconnect(localhost,root,password);
mysql_select_db(options);
if(!$cmd)
{
$result = mysql_query(select * from open_trades);
while($r=mysql_fetch_array($result))
{
$open_date=$r[open_date];
$share=$r[share];
$code=$r[code];
$short_long_trade=$r[short_long_trade];
$id=$r[id];
$expiry=$r[expiry];
$exercise=$r[excercise];
$option_price=$r[option_price];
$no_purchased=$r[no_purchased];
$no_sold=$r[no_sold];
$income_in=$r[income_in];
$income_out=$r[income_out];

print table border=\1\ cellpadding=\3\ cellspacing=\0\\n;
print td/tdtdOpen Date/tdtdShare/tdtdCode/tdtdShort
orbr Long Trade/tdtdExpiry/tdtdExcercise/tdtdOption
Price/tdtdNumberbr Purchased/tdtdNumber Sold/tdtdIncome
In/tdtdIncome Out/tdtd
/tr;

while ($row = mysql_fetch_array($result))

{
print trtd;
print INPUT TYPE='RADIO' NAME='id' VALUE='echo $id';
print /tdtd;
print $row[open_date];
print /tdtd;
print $row[share];
print /tdtd;
print $row[code];
print /tdtd;
print $row[short_long_trade];
print /tdtd;
print $row[expiry];
print /tdtd;
print $row[excercise];
print /tdtd;
print $row[option_price];
print /tdtd;
print $row[no_purchased];
print /tdtd;
print $row[no_sold];
print /tdtd;
print $row[income_in];
print /tdtd;
print $row[income_out];
print /td/tr\n;
}
print /table\n;

?

? }?
input type=submit name=cmd value=Close/form

? }
 ?

?

if($cmd==Close)
{
if (!$submit)
{



$result = mysql_query(select * from open_trades);
while($myrow=mysql_fetch_array($result))
?


input type=hidden name=id value=?php echo $myrow[id] ?

Option Close PriceINPUT TYPE=TEXT NAME=option_close_price VALUE=?PHP
echo $myrow[option_close_price]? SIZE=7 br
Notes:INPUT TYPE=TEXT NAME=notes VALUE=?php echo $myrow[notes] ?
SIZE=60br
input type=hidden name=cmd value=edit
input type=Submit name=submit value=Enter information
/form
? } ?



?
if($submit)
{

$query = INSERT INTO closed_trades SET code='$code',
option_price='$option_price', option_close_price='$option_close_price',
no_sold='$no_sold', open_date='$open_date',
short_long_trade='$short_long_trade, share='$share', expiry='$expiry',
excercise='$excercise', no_purchased='$no_purchased',
income_in='$income_in', income_out='$income_out', notes='$notes', id=$id';
$result = mysql_query($ql);

  $query = DELETE FROM open_trades WHERE id=$id;
  $result = mysql_query($sql);


echo Thank you! Information updated.;

}
}
?
/td
   /table

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



Re: [PHP-DB] Re: HTTP header information

2004-06-13 Thread franciccio
You may try with this:

?php
ob_start();/* buffer the output so no header is sent until the script is
complete*/

 session_start();
if (!session_is_registered('_isLoggedIn')) {
header (Location:viewer.php?type=login);
} else {
// do the stuff to submit a problem if they have
// logged in and have pressed the submit button
// in the html
 }
 ?
 // then here is all the html for that page

?php
ob_end_flush();// send the output now
?

Bye

Basile Francesco


Philip Thompson [EMAIL PROTECTED] ha scritto nel messaggio
news:[EMAIL PROTECTED]

 On Jun 10, 2004, at 9:44 AM, Torsten Roehr wrote:

  Philip Thompson [EMAIL PROTECTED] wrote in message
  news:[EMAIL PROTECTED]
  Hi all.
 
  I am running a website to where a user needs to login to authenticate
  themselves to perform certain tasks. So a user logs in, and I start a
  session (in PHP, of course). Well, the catch is, I am doing this all
  from one page, 'viewer.php', and I just tack on the specific view/page
  that I want them to see, depending on the link selected on that page.
  Meaning, they click on the 'submit problem' link and it goes to
  'viewer.php?type=submitproblem'.
 
  The problem comes whenever I load the view 'submitproblem' and I start
  a session with session_start(), which carries over the variable to
  tell
  whether or not the user is logged in. If they have not logged in
  whenever they click on 'submitproblem' then it will redirect them to
  'viewer.php?type=login'. So I log in, and then go to 'submitproblem'.
 
  This is where I get the error: Warning: session_start(): Cannot send
  session cookie - headers already sent. Essentially, I understand why
  this is occurring, but is there an easy way to get around it without
  creating a new page, such as 'submitproblem.php' instead of
  'viewer.php?type=submitproblem'???
 
  Make sure that NO output is done before session_start() is called. Can
  you
  post some of your code?
 
  Regards,
 
  Torsten Roehr
 

 See, that's the case. Because I'm essentially just changing the content
 within the page, it never leaves the page 'viewer.php' - it just
 changes the content by tacking on '?type=login, submitproblem, etc'.

 But my code in the beginning of the file 'submitproblem.view' is:

 ?php
 session_start();

 if (!session_is_registered('_isLoggedIn')) {
 header (Location:viewer.php?type=login);
 } else {
 // do the stuff to submit a problem if they have
 // logged in and have pressed the submit button
 // in the html
 }

 ?

 // then here is all the html for that page

 So, does that help any?

 ~Philip

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



[PHP-DB] Re: how to reuse DB results

2004-06-13 Thread franciccio

Hi here is my logic, i haven't tested but it should work (i hope)!!!
i'm not sure if it works only on php5...!?! Let me know if it is a complete
crap i've just started learning php.
Bye

$recordset=mysql_query($query); // whatever query is
$obj_array=new ArrayObject($recordset);
// get the iterator now
$interator=$obj_array-getIterator();
// you can now easly navigate in the recordset by the iterator

/* define an array with n fields to be shown on top of page. Attention
...values name must be the same of table field names you want to show on top
of the page*/
$my_key = array(0='key1',1= 'key2',,n-1='keyn');

// echo the top of the page
$i=0;
while($iterator-valid())
{
if  ($iterator-key()==$my_key[$i] )
{
echo p.$iterator-key(). : .$iterator-current()./p;
/* if u need a top_array to store result shown on top of the page,
uncomment this line only
$top_array[$i]=$iterator-current(); // loose the matching
key-field!! */
$i++;
$iterator-next();
}
else
$iterator-next();
}

/* to display the whole recordset resulting from the query  don't forget
you still have
$recordset free to use with mysql_fetch_array() or other way to display */

 echo 'pthis is the bottom page and displays the whole result/p';

while ($res=mysql_fetch_array($recordset))
for each ($res as $k=$val)
   echo p$k : $val/p; // make your choice for html code


Aaron Wolski [EMAIL PROTECTED] ha scritto nel messaggio
news:[EMAIL PROTECTED]
 Hi All,

 Got this logic problem I don't know how to solve.

 Is there any way I can make a call to the DB for some records.

 Display some info from a column or two say at the top of the page and
 then display the full result set in a while() loop?

 Right now, I am making two calls to the Db to get the data I need to
 display at the top of the page and then a second query to retrieve the
 full result set.

 I'm confused!

 Thanks for any help!

 Aaron

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



[PHP-DB] Mysql not receiving the data

2004-06-13 Thread Andrew Rothwell
Good day list,
I was running a Mysql/PHP DB/Webpage that was hosted on Redhat 8.0 
It was a simple DB - only 1 table, and the php page connected and fed data
to it.

Last weekend I rebuilt the server to Fedora Core 2 - using the default
PHP/Mysql/apache installs.

I setup the databases, and imported the old data (taken from a MySQL dump)
into the new DB, and setup Apache, so that I could view the pages that
displayed the data, and also the page that I used to add the data.

Online I could see everything, and the pages gave the appearance of working,
however when I went into the DB using PHPMYADMIN to check the status of the
new data entered, all I found was blank rows ( for the new data since the
rebuild, all the old data was there) There were the correct number of new
rows for the amount of records that I had entered, which tells me (unless I
am nistaken) that the PHP is talking to the DB, and is atleast sending a
insert command, but the rest of the data is not getting in. - 

I hope that I have made sense, Please note that the php/html pages used to
input the data used to work on the old server and had been running for
several years flawlessly. 

As I said I have a default conf for apache, obviously changing the bits that
needed to be changed (servername, etc) and did not change anything on the
PHP  MySQL confs.

Any ideas?

Thank you 
Andrew Rothwell

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



Re: [PHP-DB] Mysql not receiving the data

2004-06-13 Thread Larry E . Ullman
Online I could see everything, and the pages gave the appearance of 
working,
however when I went into the DB using PHPMYADMIN to check the status 
of the
new data entered, all I found was blank rows ( for the new data since 
the
rebuild, all the old data was there) There were the correct number of 
new
rows for the amount of records that I had entered, which tells me 
(unless I
am nistaken) that the PHP is talking to the DB, and is atleast sending 
a
insert command, but the rest of the data is not getting in. -
Without seeing any code whatsoever and since this worked before but no 
longer works on a new install, I can only assume that your code was 
written with the assumption that register_globals was turned on and 
it's not on in your current configuration.

If that is the case, see the PHP manual or search the Web for the 
solution ($_POST, $_GET, etc.).

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


RE: [PHP-DB] Mysql not receiving the data

2004-06-13 Thread Andrew Rothwell
Hi Larry, Thank you very much for the very quick response, I set my php.ini
file (located /etc/php.ini ) for the register_globals = On (it was off by
default)

Now however I get an error 
Error adding entry: You have an error in your SQL syntax near 's spanish
driver is found shot dead, Inspector Jacques Clouseau is the first off' at
line 8

My Database is a movie database of my dvd's that I own (for insurance
reasons)

My addmovie.php is this
?
  mysql_connect(localhost,username,password);
  mysql_select_db(movies);
  $add = INSERT INTO movies SET
 movie_name='$movie_name',
 genre='$genre',
 director='$director',
 star1='$star1',
 star2='$star2',
 star3='$star3',
 brief_synopsis='$brief_synopsis',
 imdb_link='$imdb_link';
  if (@mysql_query($add))
{
  echo(pYour entry has been added. br
  $movie_name/p);
}
  else
{
echo(pError adding entry:  .
mysql_error() . /p);
   }
?


And the addmovie.htm page (atleast the form action is this)

body bgcolor=#FF
form method=post action=addmovie.php name=addmovies
  table width=300 border=0 cellspacing=2 cellpadding=2
bordercolordark=#FF0033 bordercolorlight=#66
tr
  td width=41% bgcolor=#99Movie Name /td
  td width=59% bgcolor=#99FFCC 
input type=text name=movie_name
  /td
/tr


Andrew

-Original Message-
From: Larry E. Ullman [mailto:[EMAIL PROTECTED] 
Sent: Sunday, June 13, 2004 11:22 AM
To: Andrew Rothwell
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Mysql not receiving the data

 Online I could see everything, and the pages gave the appearance of 
 working, however when I went into the DB using PHPMYADMIN to check the 
 status of the new data entered, all I found was blank rows ( for the 
 new data since the rebuild, all the old data was there) There were the 
 correct number of new rows for the amount of records that I had 
 entered, which tells me (unless I am nistaken) that the PHP is talking 
 to the DB, and is atleast sending a insert command, but the rest of 
 the data is not getting in. -

Without seeing any code whatsoever and since this worked before but no
longer works on a new install, I can only assume that your code was written
with the assumption that register_globals was turned on and it's not on in
your current configuration.

If that is the case, see the PHP manual or search the Web for the solution
($_POST, $_GET, etc.).

Larry

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



Re: [PHP-DB] Mysql not receiving the data

2004-06-13 Thread Lester Caine
Andrew Rothwell wrote:
Hi Larry, Thank you very much for the very quick response, I set my php.ini
file (located /etc/php.ini ) for the register_globals = On (it was off by
default)
Now however I get an error 
Error adding entry: You have an error in your SQL syntax near 's spanish
driver is found shot dead, Inspector Jacques Clouseau is the first off' at
line 8
I would think it fairly obvious that the extra ' in the text you are 
loading is causing a problem, use an ` instead, or escape the single 
'
Not sure if MySQL uses '' or \' :)

--
Lester Caine
-
L.S.Caine Electronic Services
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP-DB] Mysql not receiving the data

2004-06-13 Thread Rich Hutchins
The apostrophe (') in your data is, most likely, killing the SQL statement
when it is sent to the server. Use addslashes() around all of your form data
to prevent this and also to help guard against SQL injection attacks.

Ex:

$add = INSERT INTO movies SET
 movie_name='.addslashes($movie_name).',
 genre='.addslashes($genre).',
 director='.addslashes($director).',
 star1='.addslashes($star1).',
 star2='.addslashes($star2).',
 star3='.addslashes($star3).',
 brief_synopsis='.addslashes($brief_synopsis).',
 imdb_link='$imdb_link';

Hope this helped.
Rich
-Original Message-
From: Andrew Rothwell [mailto:[EMAIL PROTECTED]
Sent: Sunday, June 13, 2004 1:48 PM
To: [EMAIL PROTECTED]
Subject: RE: [PHP-DB] Mysql not receiving the data


Hi Larry, Thank you very much for the very quick response, I set my php.ini
file (located /etc/php.ini ) for the register_globals = On (it was off by
default)

Now however I get an error
Error adding entry: You have an error in your SQL syntax near 's spanish
driver is found shot dead, Inspector Jacques Clouseau is the first off' at
line 8

My Database is a movie database of my dvd's that I own (for insurance
reasons)

My addmovie.php is this
?
  mysql_connect(localhost,username,password);
  mysql_select_db(movies);
  $add = INSERT INTO movies SET
 movie_name='$movie_name',
 genre='$genre',
 director='$director',
 star1='$star1',
 star2='$star2',
 star3='$star3',
 brief_synopsis='$brief_synopsis',
 imdb_link='$imdb_link';
  if (@mysql_query($add))
{
  echo(pYour entry has been added. br
  $movie_name/p);
}
  else
{
echo(pError adding entry:  .
mysql_error() . /p);
   }
?


And the addmovie.htm page (atleast the form action is this)

body bgcolor=#FF
form method=post action=addmovie.php name=addmovies
  table width=300 border=0 cellspacing=2 cellpadding=2
bordercolordark=#FF0033 bordercolorlight=#66
tr
  td width=41% bgcolor=#99Movie Name /td
  td width=59% bgcolor=#99FFCC
input type=text name=movie_name
  /td
/tr


Andrew

-Original Message-
From: Larry E. Ullman [mailto:[EMAIL PROTECTED]
Sent: Sunday, June 13, 2004 11:22 AM
To: Andrew Rothwell
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Mysql not receiving the data

 Online I could see everything, and the pages gave the appearance of
 working, however when I went into the DB using PHPMYADMIN to check the
 status of the new data entered, all I found was blank rows ( for the
 new data since the rebuild, all the old data was there) There were the
 correct number of new rows for the amount of records that I had
 entered, which tells me (unless I am nistaken) that the PHP is talking
 to the DB, and is atleast sending a insert command, but the rest of
 the data is not getting in. -

Without seeing any code whatsoever and since this worked before but no
longer works on a new install, I can only assume that your code was written
with the assumption that register_globals was turned on and it's not on in
your current configuration.

If that is the case, see the PHP manual or search the Web for the solution
($_POST, $_GET, etc.).

Larry

--
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] Mysql not receiving the data

2004-06-13 Thread franciccio
I agree, the slashes are killing the query. I would suggets doing this:

 $add = INSERT INTO movies SET
  movie_name=\$movie_name\,
  genre=\$genre\,
  director=\$director\,
  star1=\$star1\,
  star2=\$star2\,
  star3=\$star3\,
  brief_synopsis=\$brief_synopsis\,
  imdb_link=\$imdb_link\;



Rich Hutchins [EMAIL PROTECTED] ha scritto nel messaggio
news:[EMAIL PROTECTED]
 The apostrophe (') in your data is, most likely, killing the SQL statement
 when it is sent to the server. Use addslashes() around all of your form
data
 to prevent this and also to help guard against SQL injection attacks.

 Ex:

 $add = INSERT INTO movies SET
  movie_name='.addslashes($movie_name).',
  genre='.addslashes($genre).',
  director='.addslashes($director).',
  star1='.addslashes($star1).',
  star2='.addslashes($star2).',
  star3='.addslashes($star3).',
  brief_synopsis='.addslashes($brief_synopsis).',
  imdb_link='$imdb_link';

 Hope this helped.
 Rich
 -Original Message-
 From: Andrew Rothwell [mailto:[EMAIL PROTECTED]
 Sent: Sunday, June 13, 2004 1:48 PM
 To: [EMAIL PROTECTED]
 Subject: RE: [PHP-DB] Mysql not receiving the data


 Hi Larry, Thank you very much for the very quick response, I set my
php.ini
 file (located /etc/php.ini ) for the register_globals = On (it was off by
 default)

 Now however I get an error
 Error adding entry: You have an error in your SQL syntax near 's spanish
 driver is found shot dead, Inspector Jacques Clouseau is the first off' at
 line 8

 My Database is a movie database of my dvd's that I own (for insurance
 reasons)

 My addmovie.php is this
 ?
   mysql_connect(localhost,username,password);
   mysql_select_db(movies);
   $add = INSERT INTO movies SET
  movie_name='$movie_name',
  genre='$genre',
  director='$director',
  star1='$star1',
  star2='$star2',
  star3='$star3',
  brief_synopsis='$brief_synopsis',
  imdb_link='$imdb_link';
   if (@mysql_query($add))
 {
   echo(pYour entry has been added. br
   $movie_name/p);
 }
   else
 {
 echo(pError adding entry:  .
 mysql_error() . /p);
}
 ?


 And the addmovie.htm page (atleast the form action is this)

 body bgcolor=#FF
 form method=post action=addmovie.php name=addmovies
   table width=300 border=0 cellspacing=2 cellpadding=2
 bordercolordark=#FF0033 bordercolorlight=#66
 tr
   td width=41% bgcolor=#99Movie Name /td
   td width=59% bgcolor=#99FFCC
 input type=text name=movie_name
   /td
 /tr


 Andrew

 -Original Message-
 From: Larry E. Ullman [mailto:[EMAIL PROTECTED]
 Sent: Sunday, June 13, 2004 11:22 AM
 To: Andrew Rothwell
 Cc: [EMAIL PROTECTED]
 Subject: Re: [PHP-DB] Mysql not receiving the data

  Online I could see everything, and the pages gave the appearance of
  working, however when I went into the DB using PHPMYADMIN to check the
  status of the new data entered, all I found was blank rows ( for the
  new data since the rebuild, all the old data was there) There were the
  correct number of new rows for the amount of records that I had
  entered, which tells me (unless I am nistaken) that the PHP is talking
  to the DB, and is atleast sending a insert command, but the rest of
  the data is not getting in. -

 Without seeing any code whatsoever and since this worked before but no
 longer works on a new install, I can only assume that your code was
written
 with the assumption that register_globals was turned on and it's not on in
 your current configuration.

 If that is the case, see the PHP manual or search the Web for the solution
 ($_POST, $_GET, etc.).

 Larry

 --
 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] Re: Problem in passing the necessary variable.

2004-06-13 Thread franciccio
Ciao..hi, i would suggest to embed the html code in php like this:

?php
$_your_variable=$row[imgid];
echo
a href=\../images/image.php?img=$_your_variable\
target=\_blank\
 onClick=\window.open(this.href, this.target,
\'width=200,height=250\');
 return false;\img SRC=\../preview.jpg\ ALT=\Click to look at
the picture
 you are charging\ border=\0\/a;
?

If it works let me know , bye

Francesco Basile
__

Alessandro Folghera [EMAIL PROTECTED] ha scritto nel messaggio
news:[EMAIL PROTECTED]
 Hi,

 I have developed a news system .. I can select to insert an image into the
 articles.

 The function to extract the image calling them by the imgid of images
 table is the following:

 function getImm() {
 ?
   select name=image
 ?
 connect();
 $sql = select * from images;
 $result = mysql_query($sql);
 while($row = mysql_fetch_array($result)) {
 printf(option value=\%s\%s/option, $row[id_img], $row[imgid]);
 }
 ?
   /select
 ?

 I'd like to be able to see the image before to publish the piece of news.

 I think about a window pop up with java in order to create a preview of
the
 image. The code follows:

 a href=../images/image.php?img=XX target=_blank
 onClick=window.open(this.href, this.target, 'width=200,height=250');
 return false;img SRC=../preview.jpg ALT=Click to look at the picture
 you are charging border=0/a

 The problem is that I can't pass the imgid to the href inspite of the
 

 May someone tell me how to pass the id number in order to show me the
image
 or how may I solve the trouble?

 I hope someone will help me ...

 Sincerely,
 Alexander

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



RE: [PHP-DB] Mysql not receiving the data

2004-06-13 Thread Andrew Rothwell
Thank you everybody that responded so quickly -
I used the suggestion of Franciccio - and the data is now gow into the db
Thank you very much - I really appreciate the help.

Another question - with this fix in place - do I still need the
register_globals = On ?
Or can I now turn it off?

Thank you all again
Andrew

 

-Original Message-
From: franciccio [mailto:[EMAIL PROTECTED] 
Sent: Sunday, June 13, 2004 12:26 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Mysql not receiving the data

I agree, the slashes are killing the query. I would suggets doing this:

 $add = INSERT INTO movies SET
  movie_name=\$movie_name\,
  genre=\$genre\,
  director=\$director\,
  star1=\$star1\,
  star2=\$star2\,
  star3=\$star3\,
  brief_synopsis=\$brief_synopsis\,
  imdb_link=\$imdb_link\;

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



Re: [PHP-DB] Mysql not receiving the data

2004-06-13 Thread Hans Lellelid
Hi Andrew,
Andrew Rothwell wrote:
Thank you everybody that responded so quickly -
I used the suggestion of Franciccio - and the data is now gow into the db
Thank you very much - I really appreciate the help.
Another question - with this fix in place - do I still need the
register_globals = On ?
Or can I now turn it off?
It seems like you should have kept your old php.ini file, as this other 
error you encountered was probably due to your old php.ini file having 
this setting:

magic_quotes_gpc = 1
That INI var instructs PHP to automatically addslashes() to any 
GET/POST/COOKIE data.  I would suggest turning this back on, unless 
you've thoroughly redesigned your code to not need it.

This is unrelated to register_globals, which you will need to leave on 
unless you redesign your application.

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


[PHP-DB] creating a nested multidimensional array from a query

2004-06-13 Thread grahama
Hi :)
I am on my second week of php so be gentle
I am creating an XML file out of a mysql query with nested arrays.
Currently I can get 1 element and 1 child with a properly formatted XML 
file with the below script .

My question is: How do  I  add 3 to 4 more child elements to the below 
'playlist' array ?
Currently ,I have one parent 'Artist' and one child 'english' ...
I need to add more child elements to the 'Artist' array like urlPath, 
spanish, biography, etc

Do I have to add another dimension to the 'playlist' array? Do I need 
another  foreach loop ?
Is there an easier more efficient way to do this?
Be nice to spell out the schema in some way in the script...in case you 
need to add more levels...like a 'subCategory'

I am a bit new to this so any help would be greatly appretiated  
head is spinning a bit

$sql = 'SELECT artist.artist_name, media.english, media.path ';
$sql .= 'FROM media, artist ';
$sql .= 'WHERE artist.artist_id = media.artist_id LIMIT 0, 30 ';
$result = mysql_query($sql);
while ($row = mysql_fetch_array($result))
{
$playlist[$row['artist_name']] [] = $row['english'];
//would like to add more children here...
}
$xml = sirenreels\n;
foreach ($playlist as $artist = $media)
{
$num_media = count($media);
$xml .= artist\n;   

$xml .= \tmeta\n;   
$xml .= \t\ttitle.$artist./title\n;
$xml .= \t/meta\n;  

$xml .= \tcontent\n;
foreach ($media as $mediaVal)
{
$xml .= \t\tmedia\n;
$xml .= \t\t\tenglish_name.$mediaVal./english_name\n;
///add more children
///add more children
$xml .= \t\t/media\n;   

}

$xml .= \t/content\n;   
$xml .= /artist\n;  
}
$xml .= /sirenreels\n;
print $xml
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] Mysql not receiving the data

2004-06-13 Thread franciccio
Some of the reason to have register_global on is to easly use variables
sent by post, get, cookie method of a form.
Ex.
form name=form1 method=post action=anypage.php?get_var=1
  input type=text name=text_post value=Hello World
  input type=submit name=Submit value=Submit
/form


in your code at the page anypage.php you will have available the
variables:
$get_var==1 and $text_post==Hello World
if register_global=TRUE  in php.ini file
 - in this case u still have available $_POST;GET ecc...

$_GET['get_var']==1 and $_POST['text_post']==Hello World
if register_global=FALSE  in php.ini file
- in this case you don't have the $get_var e $text_post
available, so code is safer

I would suggest to leave register global=FALSE as to have safer code unless
u have to rewrite the whole code. Think about having hacked variables value
send by GET, COOKIE method.

Bye



Hans Lellelid [EMAIL PROTECTED] ha scritto nel messaggio
news:[EMAIL PROTECTED]
 Hi Andrew,

 Andrew Rothwell wrote:
  Thank you everybody that responded so quickly -
  I used the suggestion of Franciccio - and the data is now gow into the
db
  Thank you very much - I really appreciate the help.
 
  Another question - with this fix in place - do I still need the
  register_globals = On ?
  Or can I now turn it off?
 

 It seems like you should have kept your old php.ini file, as this other
 error you encountered was probably due to your old php.ini file having
 this setting:

 magic_quotes_gpc = 1

 That INI var instructs PHP to automatically addslashes() to any
 GET/POST/COOKIE data.  I would suggest turning this back on, unless
 you've thoroughly redesigned your code to not need it.

 This is unrelated to register_globals, which you will need to leave on
 unless you redesign your application.

 Hans

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



Re: [PHP-DB] MySQL persistent connections

2004-06-13 Thread Michael Gale
Hello,

I am no expert but I believe more information is required, like what
would be the average return of a mysql operation ? How many different
DB's are you accessing ? How many different usernames and passwords for
mysql are you using ??

I believe persistent connections are only useful when the amount of DB
connections being made is inversely proportional to the amount of data
being returned.

That is if you have 50 connections being created to check the same one
field in one table. Then persistent connections would be worth it. But
is you are returning 4-5MB of data per-query then persistent connections
would not be worth it.

Plus with persistent connections I have heard most people have issues
with hitting the too many open connections limit. Because the
connections are not being closed or reused.

Michael.




On Fri, 11 Jun 2004 11:38:37 -0400
Radek Zajkowski [EMAIL PROTECTED] wrote:

 
 
 Hey there PHP fiends,
 
 I have a bit of cookie here. We're designing a PHP based app that uses
 MySQL as the data storage. Scalability is an issue, we want to be able
 to handle up to 1 people utilizing the system (not at once of
 course).
 
 Question is, should I be connecting and disconnecting from the DB on
 each operation or increase the maximum number of allowed connections
 with MySQL and connect just once.
 
 TIA
 
 R
 
 -
 
 -- 
 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