[PHP] Re: [PHP-DB] when click on button, how renew info on page?

2003-03-23 Thread L0vCh1Y
- gert

Monday, March 24, 2003 sent:

gv hello everyone,

gv with this code, a table is loaded with info from the mysql db with id = '1'.

gv but now i want to make a button, and when it is clicked, he has to renew the 
gv table with the info from the db with id ='2'

gv does anyone know has this should be done?

gv thanks in advance!

gv Greetings,

gv Gert Vonck


gv html
gv head title /title /head
gv body

gv ?php
gv mysql_connect(localhost,root,) or
gv die (Could not connect to database);
gv mysql_select_db(oh) or
gv die (problems selecting database);

?

gv h2Info_DJ/h2

gv ?php

gv $result0 = mysql_query(SELECT 
gv naam,leeftijd,muziekgenre,favoriet_liedje,motto,picture_right FROM info_dj 
gv WHERE id='1') or die (mysql_error());

gv printtable border=1\n;
gv $field_count = mysql_num_fields($result0);
gv while ($get_info0 = mysql_fetch_row($result0))
gv {
gv print trtdtable;
gv for($i = 0; $i  $field_count - 1 ; $i++){
gv $value = $get_info0[$i];
gv $column = mysql_field_name($result0,$i);
gv print \ttrtd$column/tdtd$value/td/tr\n;
gv }
gv $last = $field_count - 1;
gv print /table/tdtdimg src='$get_info0[$last]'/td/tr\n;
gv }

gv print /table\n;
gv mysql_close();

?

gv /body
gv /html





gv _





  So, what is problem in? Make button to lead to same page but with
  $n++ variable. i.e.

  ?
  $n = isset($_GET['n']) ? $_GET['n'] : '';

  $sql = 'SELECT `foo` FROM `bar` WHERE id = '.$n;
  $n++;
  if ($req = mysql_query($sql)) { any actions...; print 'a 
href=foo.php?n='.$n.'link/a'; }
  else die (mysql_error());
  ?

  And one more thing - try to use templates, if you work with HTML
  parsing a lot. :]

Yours, L0vCh1Y [EMAIL PROTECTED]


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



[PHP] Session's length.

2003-03-22 Thread L0vCh1Y
- php-general.

  I used such code:

$exp = 60*60*24*10; # for ten days.
session_set_cookie_params($exp);

  But it works wrong - cookies were removed right after i have rebooted.
  The other way is to put session id into the cookies, but...
  Isn't it the same?

  Thank you.

  
Yours, L0vCh1Y [EMAIL PROTECTED]


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



Fwd: Re: [PHP] Separators in variable values causing MySQL commands to fail

2003-03-22 Thread L0vCh1Y
- rentAweek,

rL In my PHP script I have coded e.g.:

rL $sql = INSERT INTO `$owners` ( `FirstName`, `LastName`) VALUES ( 
rL '$firstname' , '$lastname' );

rL $result = mysql_query($sql);

rL So along comes e.g. John O'Groats and nothing gets inserted into the 
rL database.

rL OK, I can bypass my oversight by stripping out apostophes from the 
rL variable values. There has to be a better way please.

Why not just use addslashes() (mysql_escape_string())  check if $result==true?


Yours, L0vCh1Y


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



Re: [PHP] Re: Session's length.

2003-03-22 Thread L0vCh1Y
Hello Joel,

Saturday, March 22, 2003, 9:52:20 PM, you wrote:

JC from the user posts at php.net
JC http://www.php.net/manual/en/function.session-set-cookie-params.php

JC The idea of a session is that it ends when the user closes the browser
JC (maybe even before hand).  If you want a cookie to last longer, than use the
JC setcookie() function.

JC -Kevin

JC Sent out by
JC Joel Colombo

Manual was the first place i've looked into.
session_set_cookie_params($exp) is function, entered
to able sessions to long as much as needed, as it sets up cookies
sent by sessions (equal to same function, working with cookies). But
it's look like server removes session's data much earlier, then i
need...

-- 
Best regards,
 L0vCh1Ymailto:[EMAIL PROTECTED]


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



[PHP] Re: [PHP-DB] Gathering data from a database

2003-03-22 Thread L0vCh1Y
- Mike,

MD I have been having this problem for a while now, and I cant figure it out. the 
code is:
MD ?
MD $host = localhost;
MD $uname = sniper;
MD $pass = starcraft;
MD $database = sha;
MD $tablename = members;
MD $connect = mysql_connect ($host, $uname, $pass); 
MD $select = mysql_select_db ($database);
MD $query = SELECT * from $tablename;
MD $result = mysql_query ($query, $connect);

MD while ($row = mysql_fetch_array($result))
MD {
MD print_r( $row );
MD echo mysql_error();
MD }
?

MD mysql has an error on line 19. Line 19 is while ($row = 
mysql_fetch_array($result)). What am I doing wrong?


MD Thanks for your help,
MD Mike

ensure $result is correct:

?
$host = localhost;
$uname = sniper;
$pass = starcraft;
$database = sha;
$tablename = members;
$connect = mysql_connect ($host, $uname, $pass);
 
what is that? ;] - $select = mysql_select_db ($database); # why do u use ?

$query = SELECT * from $tablename;
$result = mysql_query ($query, $connect);

while ($row = mysql_fetch_array($result))
{
print_r( $row );
echo mysql_error();
}
?


Yours L0vCh1Y


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