radio button and mysql HELP PLEASE!
09-20-2007, 05:17 AM
|
Re: radio button and mysql HELP PLEASE!
|
Posts: 65
|
i have a question: let say if in page one my code is :
page1.php
PHP Code:
<html> <head> <title>MY data</title> </head> <body> <?php require_once 'myClass.class.php'; new my($php); ?> </body> </html>
then in the class i have a button once triggered to call the display function
myClass.class.php
PHP Code:
<?php class my { .... function display() { header("Location:display.php"); } } ?>
if in the function display() i put the echo function it triggered properly but when i replace the echo with the header("Location:display.php");
then i trigger the button it shows the message
"Warning: Cannot modify header information - headers already sent by (output started at c:\program files\easyphp1-8\www\pt\ets.php:6) in c:\program files\easyphp1-8\www\pt\ets.php
again. I had try to put the php code outside and still show the message?
how should i put the class structure and how should i organize my page1.php sho that message will not appear?
thanks
|
|
|
|
09-20-2007, 06:14 AM
|
Re: radio button and mysql HELP PLEASE!
|
Posts: 134
|
it is not about where you put it, it is about when it is executed. The header() function has to be executed before the browser encounters the <html> tag
__________________
Please login or register to view this content. Registration is FREE
Check out the Facebook Clone build with Jcow SNS at Please login or register to view this content. Registration is FREE , it is free and it always will be
|
|
|
|
09-20-2007, 09:35 PM
|
Re: radio button and mysql HELP PLEASE!
|
Posts: 65
|
I have found a source that help save my time a lot. now what i want to use the header function to call another page. what the source did is they use the class function which like below:
this is my page1.php
PHP Code:
<html> <head> <title>My Data</title> </head> <body> <?php // MySQL host name, user name, password, database, and table $opts['hn'] = 'localhost'; $opts['un'] = 'root'; $opts['pw'] = ''; $opts['db'] = 'school'; $opts['tb'] = 'employee_data'; // Name of field which is the unique key $opts['key'] = 'idnum'; // Type of key field (int/real/string/date etc.) $opts['key_type'] = 'string'; // Sorting field(s) $opts['sort_field'] = array('idnum'); // Number of records to display on the screen // Value of -1 lists all records in a table $opts['inc'] = 15; // Options you wish to give the users // A - add, C - change, P - copy, V - view, D - delete, // F - filter, I - initial sort suppressed Q-Convert $opts['options'] = 'AQ'; // Number of lines to display on multiple selection filters $opts['multiple'] = '4'; // Navigation style: B - buttons (default), T - text links, G - graphic links // Buttons position: U - up, D - down (default) $opts['navigation'] = 'DB'; // Display special page elements $opts['display'] = array( 'form' => true, 'query' => true, 'sort' => true, 'time' => true, 'tabs' => true ); // Set default prefixes for variables $opts['js']['prefix'] = 'PME_js_'; $opts['dhtml']['prefix'] = 'PME_dhtml_'; $opts['cgi']['prefix']['operation'] = 'PME_op_'; $opts['cgi']['prefix']['sys'] = 'PME_sys_'; $opts['cgi']['prefix']['data'] = 'PME_data_'; /* Get the user's default language and use it if possible or you can specify particular one you want to use. Refer to official documentation for list of available languages. */ $opts['language'] = 'EN-US'; $opts['fdd']['idnum'] = array( 'name' => 'ID NUM', 'select' => 'T', 'maxlen' => 16, 'sort' => true ); $opts['fdd']['Name'] = array( 'name' => 'NAME', 'select' => 'T', 'maxlen' => 10, 'default' => '0000-00-00', 'sort' => true ); $opts['fdd']['Age'] = array( 'name' => 'AGE', 'select' => 'T', 'maxlen' => 16, 'sort' => true ); // Now important call to phpMyEdit require_once 'phpMyEdit.class.php'; new phpMyEdit($opts); ?> </body> </html>
and in the phpMyEdit.class.php
PHP Code:
<?php class phpMyEdit { var $operation; // operation to do: Add, Change, Delete var $page_types = array( 'L' => 'list', 'F' => 'filter', 'A' => 'add', 'Q' => 'convert' ); var $default_buttons = array( 'L' => array('<<','<','add','view','change','copy','delete','convert','>','>>','goto','goto_combo'), 'F' => array('<<','<','add','view','change','copy','delete','convert','>','>>','goto','goto_combo'), 'A' => array('save','more','cancel'), 'Q' => array('save','more','cancel') ); function nav_buttons() { return stristr($this->navigation, 'B'); } function nav_up() { return (stristr($this->navigation, 'U') && !($this->buttons[$this->page_type]['up'] === false)); } function nav_down() { return (stristr($this->navigation, 'D') && !($this->buttons[$this->page_type]['down'] === false)); } /* * functions for indicating whether operations are enabled */ function add_enabled() { return stristr($this->options, 'A'); } function convert_enabled(){ return stristr($this->options, 'Q'); } function filter_enabled() { return stristr($this->options, 'F'); } function tabs_enabled() { return $this->display['tabs'] && count($this->tabs) > 0; } function hidden($k) { return stristr($this->fdd[$k]['input'],'H'); } function password($k) { return stristr($this->fdd[$k]['input'],'W'); } function readonly($k) { return stristr($this->fdd[$k]['input'],'R') || $this->virtual($k); } function add_operation() { return $this->operation == $this->labels['Add'] && $this->add_enabled(); } function convert_operation() { return $this->operation == $this->labels['Convert'] && $this->convert_enabled(); } function filter_operation() { return $this->fl && $this->filter_enabled() && $this->list_operation(); } function list_operation() { /* covers also filtering page */ return ! $this->convert_operation() && ! $this->add_operation(); } function add_canceled() { return $this->canceladd == $this->labels['Cancel']; } function displayed($k) /* {{{ */ { return ($this->add_operation() && stristr($options, 'A')) || ($this->convert_operation() && stristr($options, 'Q')) || ($this->filter_operation() && stristr($options, 'F')) || ($this->list_operation() && stristr($options, 'L')); } /* }}} */ function myquery($qry, $line = 0, $debug = 0) /* {{{ */ { if (isset($this->db)) { $ret = @mysql_db_query($this->db, $qry, $this->dbh); } return $ret; } /* }}} */ function make_language_labels($language) /* {{{ */ { if (! file_exists($file)) { // try the language w/o variant $file = $this->dir['lang'].'PME.lang.'.substr($language,0,2).'.inc'; } $ret = @include($file); if (! is_array($ret)) { return $ret; } return $ret; } /* }}} */ function set_values($field_num, $prepend = null, $append = null, $strict = false) /* {{{ */ { return (array) $prepend + (array) $this->fdd[$field_num]['values2'] + (isset($this->fdd[$field_num]['values']['table']) || $strict ? $this->set_values_from_table($field_num, $strict) : array()) + (array) $append; } /* }}} */ function display() { header("Location:convert.php"); } function get_SQL_query($parts) /* {{{ */ { foreach ($parts as $k => $v) { $parts[$k] = trim($parts[$k]); } switch ($parts['type']) { case 'select': $ret = 'SELECT '; if ($parts['DISTINCT']) $ret .= 'DISTINCT '; $ret .= $parts['select']; $ret .= ' FROM '.$parts['from']; if ($parts['where'] != '') $ret .= ' WHERE '.$parts['where']; if ($parts['groupby'] != '') $ret .= ' GROUP BY '.$parts['groupby']; if ($parts['having'] != '') $ret .= ' HAVING '.$parts['having']; if ($parts['orderby'] != '') $ret .= ' ORDER BY '.$parts['orderby']; if ($parts['limit'] != '') $ret .= ' LIMIT '.$parts['limit']; if ($parts['procedure'] != '') $ret .= ' PROCEDURE '.$parts['procedure']; break; default: die('unknown query type'); break; } return $ret; } /* }}} */ function get_SQL_join_clause() /* {{{ */ { $main_table = 'PMEtable0'; $join_clause = $this->tb." AS $main_table"; return $join_clause; } /* }}} */ function get_SQL_where_from_query_opts($qp = null, $text = 0) /* {{{ */ { if ($qp == null) { $qp = $this->query_opts; } $where = array(); return ''; /* empty string */ } /* }}} */ function form_begin() /* {{{ */ { $page_name = htmlspecialchars($this->page_name); if ($this->add_operation()) { $first_required = true; for ($k = 0; $k < $this->num_fds; $k++) { if ($this->displayed[$k] && ! $this->readonly($k) && ! $this->hidden($k) && ($this->fdd[$k]['js']['required'] || isset($this->fdd[$k]['js']['regexp']))) { if ($first_required) { $first_required = false; echo '<script type="text/javascript"><!--',"\n"; echo ' function '.$this->js['prefix'].'trim(str) { while (str.substring(0, 1) == " " || str.substring(0, 1) == "\\n" || str.substring(0, 1) == "\\r") { str = str.substring(1, str.length); } while (str.substring(str.length - 1, str.length) == " " || str.substring(str.length - 1, str.length) == "\\n" || str.substring(str.length - 1, str.length) == "\\r") { str = str.substring(0, str.length - 1); } return str; } function '.$this->js['prefix'].'form_control(theForm) {',"\n"; } } } if (! $first_required) { echo ' return true; }',"\n\n"; echo '// --></script>', "\n"; } } if ($this->display['form']) { echo '<form class="',$this->getCSSclass('form'),'" method="POST"'; echo ' action="',$page_name,'" name="'.$this->cgi['prefix']['sys'].'form">',"\n"; } return true; } /* }}} */ function display_add_record() /* {{{ */ { echo "<h1> DISPLAY_ADD RECORD</h1>"; } /* }}} */ function getCSSclass($name, $position = null, $divider = null, $postfix = null) /* {{{ */ { } /* }}} */ /** * Returns field cell HTML attributes */ function htmlSubmit($name, $label, $css_class_name, $js_validation = true, $disabled = false, $js = NULL) /* {{{ */ { // Note that <input disabled> isn't valid HTML, but most browsers support it $markdisabled = $disabled ? ' disabled' : ''; $ret = '<input'.$markdisabled.' type="submit" class="'.$css_class_name .'" name="'.$this->cgi['prefix']['sys'].ltrim($markdisabled).$name .'" value="'.(isset($this->labels[$label]) ? $this->labels[$label] : $label); if ($js_validation) { $ret .= '" onClick="return '.$this->js['prefix'].'form_control(this.form);'; } $ret .='"'; if(isset($js)) $ret .= ' '.$js; $ret .= '>'; return $ret; } /* }}} */ function get_sys_cgi_var($name, $default_value = null) /* {{{ */ { if (isset($this)) { return $this->get_cgi_var($this->cgi['prefix']['sys'].$name, $default_value); } return phpMyEdit::get_cgi_var(phpMyEdit::get_default_cgi_prefix('sys').$name, $default_value); } /* }}} */ function get_cgi_var($name, $default_value = null) /* {{{ */ { if (! isset($var)) { global $HTTP_POST_VARS; $var = @$HTTP_POST_VARS[$name]; } return $var; } /* }}} */ function display_list_table_buttons($position) /* {{{ */ { if (($but_str = $this->display_buttons($position)) === null) return; if($position == 'down') echo '<hr class="'.$this->getCSSclass('hr', 'down').'">'."\n"; echo '<table class="',$this->getCSSclass('navigation', $position),'">',"\n"; echo '<tr class="',$this->getCSSclass('navigation', $position),'">',"\n"; echo '<td class="',$this->getCSSclass('buttons', $position),'">',"\n"; echo $but_str,'</td>',"\n"; } /* }}} */ function display_record_buttons($position) /* {{{ */ { if (($but_str = $this->display_buttons($position)) === null) return; if ($position == 'down') { if ($this->tabs_enabled()) $this->display_tab_labels('down'); echo '<hr class="',$this->getCSSclass('hr', 'down'),'">',"\n"; } echo '<table class="',$this->getCSSclass('navigation', $position),'">',"\n"; echo '<tr class="',$this->getCSSclass('navigation', $position),'">',"\n"; echo '<td class="',$this->getCSSclass('buttons', $position),'">',"\n"; echo $but_str,'</td>',"\n"; // Message is now written here } /* }}} */ function display_buttons($position) /* {{{ */ { $nav_fnc = 'nav_'.$position; if(! $this->$nav_fnc()) return; $buttons = (is_array($this->buttons[$this->page_type][$position])) ? $this->buttons[$this->page_type][$position] : $buttons = $this->default_buttons[$this->page_type]; foreach ($buttons as $name) { $ret .= $this->display_button($name, $position)."\n"; } return $ret; } /* }}} */ function display_button($name, $position = 'up') /* {{{ */ { if (is_array($name)) { if (isset($name['code'])) return $name['code']; return $this->htmlSubmit($name['name'], $name['value'], $name['css'], $name['disabled'], $name['js']); } $disabled = 1; // show disabled by default if ($name[0] == '+') { $name = substr($name, 1); $disabled = 0; } // always show disabled as enabled if ($name[0] == '-') { $name = substr($name, 1); $disabled = -1; } // don't show disabled if ($name == 'cancel') { return $this->htmlSubmit('cancel'.$this->page_types[$this->page_type], 'Cancel', $this->getCSSclass('cancel', $position), false); } if (in_array($name, array('add','convert'))) { $enabled_fnc = $name.'_enabled'; $enabled = $this->$enabled_fnc(); if ($name != 'add' && ! $this->total_recs && strstr('LF', $this->page_type)) $enabled = false; return $this->htmlSubmit('operation', ucfirst($name), $this->getCSSclass($name, $position), false, $enabled ? 0 : $disabled); } } /* }}} */ function number_of_recs() /* {{{ */ { $count_parts = array( 'type' => 'select', 'select' => 'count(*)', 'from' => $this->get_SQL_join_clause(), 'where' => $this->get_SQL_where_from_query_opts()); $res = $this->myquery($this->get_SQL_query($count_parts), __LINE__); $row = @mysql_fetch_array($res, MYSQL_NUM); $this->total_recs = $row[0]; } /* }}} */ function list_table() /* {{{ */ { $this->number_of_recs(); $this->form_begin(); $this->display_list_table_buttons('down'); } /* }}} */ function display_record() /* {{{ */ { $this->form_begin(); if ($this->cgi['persist'] != '') { echo $this->get_origvars_html($this->cgi['persist']); } if ($this->add_operation()) { $this->display_add_record(); }else if ($this->convert_operation()) { $this->display(); } $this->display_record_buttons('down'); } /* }}} */ function exec_triggers($op, $step, $oldvals, &$changed, &$newvals) /* {{{ */ { if (! isset($this->triggers[$op][$step])) { return true; } $ret = true; $trig = $this->triggers[$op][$step]; if (is_array($trig)) { ksort($trig); for ($t = reset($trig); $t !== false && $ret != false; $t = next($trig)) { $ret = include($t); } } else { $ret = include($trig); } return $ret; } /* }}} */ function exec_triggers_simple($op, $step) /* {{{ */ { $oldvals = $newvals = $changed = array(); return $this->exec_triggers($op, $step, $oldvals, $changed, $newvals); } /* }}} */ function recreate_fdd($default_page_type = 'L') /* {{{ */ { // TODO: one level deeper browsing $this->page_type = $default_page_type; $this->filter_operation() && $this->page_type = 'F'; $this->convert_operation() && $this->page_type = 'Q'; if ($this->add_operation() || $this->saveadd == $this->labels['Save'] || $this->moreadd == $this->labels['More']) { $this->page_type = 'A'; } } /* }}} */ function connect() /* {{{ */ { if (isset($this->dbh)) { return true; } if (!isset($this->db)) { $this->error('no database defined'); return false; } if (!isset ($this->tb)) { $this->error('no table defined'); return false; } $this->dbh = @ini_get('allow_persistent') ? @mysql_pconnect($this->hn, $this->un, $this->pw) : @mysql_connect($this->hn, $this->un, $this->pw); if (!$this->dbh) { $this->error('could not connect to MySQL'); return false; } return true; } /* }}} */ function execute() /* {{{ */ { // Database connection if ($this->connect() == false) { return false; } if ($this->add_operation()) { $this->display_record(); }elseif ($this->convert_operation()) { $this->display_record(); } else { $this->list_table(); } } function phpMyEdit($opts) /* {{{ */ { // Set desirable error reporting level $error_reporting = error_reporting(E_ALL & ~E_NOTICE); // Database handle variables if (isset($opts['dbh'])) { $this->close_dbh = false; $this->dbh = $opts['dbh']; $this->dbp = ''; } else { $this->close_dbh = true; $this->dbh = null; $this->dbp = $opts['db'].'.'; $this->hn = $opts['hn']; $this->un = $opts['un']; $this->pw = $opts['pw']; $this->db = $opts['db']; } $this->tb = $opts['tb']; $this->options = $opts['options']; $this->display['form'] = isset($opts['display']['form']) ? $opts['display']['form'] : true; // Creating directory variables $this->dir['root'] = dirname(realpath(__FILE__)) . (strlen(dirname(realpath(__FILE__))) > 0 ? '/' : ''); $this->dir['lang'] = $this->dir['root'].'lang/'; // Navigation $this->navigation = @$opts['navigation']; if (! $this->nav_buttons() && ! $this->nav_text_links() && ! $this->nav_graphic_links()) { $this->navigation .= 'B'; // buttons are default } $this->buttons = $opts['buttons']; // Language labels (must go after navigation) $this->labels = $this->make_language_labels(isset($opts['language']) ? $opts['language'] : $this->get_server_var('HTTP_ACCEPT_LANGUAGE')); // Form variables all around $this->fl = intval($this->get_sys_cgi_var('fl')); $this->fm = intval($this->get_sys_cgi_var('fm')); $this->operation = $this->get_sys_cgi_var('operation'); $oper_prefix_len = strlen($this->cgi['prefix']['operation']); if (! strncmp($this->cgi['prefix']['operation'], $this->operation, $oper_prefix_len)) { $this->operation = $this->labels[substr($this->operation, $oper_prefix_len)]; } // Specific $fdd modifications depending on performed action $this->recreate_fdd(); // Call to action !isset($opts['execute']) && $opts['execute'] = 1; $opts['execute'] && $this->execute(); } /* }}} */ } ?>
now when the page started it will show the two button which is the add and convert button. add button which will call the display_add_record() with no problem. but when i click the convert button which triggered the display() function that have the line " header("Location:convert.php"); " and display trhe warning message below:
Warning: Cannot modify header information - headers already sent by (output started at c:\program files\easyphp1-8\www\ets_new\ets_new.php:7) in c:\program files\easyphp1-8\www\ets_new\phpMyEdit.class.php on line 83
i know that the header must be put before the hytml tag but now it call the class function. how to solve my problem? i really need this function to work as it helps me a lot.
could anyone solve my problem cause once i triggered the convert button i want the header to pass to the convert.php page as the page will generate my report.
Anyone please help me out with this so i can call the function display() to triggered the header when i click on the convert button.
thanks
|
|
|
|
09-21-2007, 10:21 AM
|
Re: radio button and mysql HELP PLEASE!
|
Posts: 134
|
try page1.php again without the html-tags
__________________
Please login or register to view this content. Registration is FREE
Check out the Facebook Clone build with Jcow SNS at Please login or register to view this content. Registration is FREE , it is free and it always will be
|
|
|
|
09-23-2007, 09:34 PM
|
Re: radio button and mysql HELP PLEASE!
|
Posts: 65
|
i've remove the html- tags but the errors still appear saying that the headers already sent.
what should i do to fix it?
PLEASE help me out with this
Last edited by leolim; 09-23-2007 at 09:36 PM..
|
|
|
|
09-24-2007, 07:12 PM
|
Re: radio button and mysql HELP PLEASE!
|
Posts: 339
|
<?php header(Location:edit.php...); ?>
<HTML>
<HEAD>....
|
|
|
|
09-24-2007, 09:15 PM
|
Re: radio button and mysql HELP PLEASE!
|
Posts: 65
|
i mean in the page1.php there are several button when is loaded.
the button is created in the phpMyEdit.class.php and each button such as add will triggered the function within the class.
Now the problem is if i click the convert button which is one of the button in the class it will call the display() function with no problem.
but if i put the header("Location:edit.php"); in the function display() and click the convert button which i want it to redirect me to the edit.php page it shows the message
Warning: Cannot modify header information - headers already sent by (output started at c:\program files\easyphp1-8\www\ets_new\ets_new.php:7) in c:\program files\easyphp1-8\www\ets_new\phpMyEdit.class.php on line 83
The function display() belongs to the class. what should i do to avoid the warning?
someone please help me out with this. what i want i to call the function within the class to redirect me to the other page. what do i need to do?
HELP please
thanks
Last edited by leolim; 09-24-2007 at 09:17 PM..
|
|
|
|
09-25-2007, 12:38 PM
|
Re: radio button and mysql HELP PLEASE!
|
Posts: 134
|
check the phpMyEdit class forum http://platon.sk/forum
__________________
Please login or register to view this content. Registration is FREE
Check out the Facebook Clone build with Jcow SNS at Please login or register to view this content. Registration is FREE , it is free and it always will be
Last edited by Falcone; 09-25-2007 at 12:40 PM..
|
|
|
|
09-25-2007, 09:43 PM
|
Re: radio button and mysql HELP PLEASE!
|
Posts: 65
|
Falcone could you help me out with this? cause my problem only the header problem.
the function that consist of the header("Location...") which i want to call is embeded within the class and the button is also generated once the class is loaded. the add button to call display_add_record() which is also the class function will triggered properly without the header function. Now the convert button will call the display() in the class. without the header function the display function can works fine. but when the header function is added then the warning message appear. what is the wrong concept here? i need to include the header function to redirect to another page or is there any alternative solution where i can redirect to another page once the convert button that is generated by the class is clicked?
i really need this solution. please help me out
thanks and thanks again
|
|
|
|
09-26-2007, 06:50 AM
|
Re: radio button and mysql HELP PLEASE!
|
Posts: 134
|
you are using somewhere html code before the header function is executed, that is the problem
__________________
Please login or register to view this content. Registration is FREE
Check out the Facebook Clone build with Jcow SNS at Please login or register to view this content. Registration is FREE , it is free and it always will be
|
|
|
|
09-26-2007, 09:31 PM
|
Re: radio button and mysql HELP PLEASE!
|
Posts: 65
|
Falcone, do you mean any html tag or only <html> tag?could you help me to view the phpMyEdit.class.php? cause i've tried to remove all the <html> tag from page1.php but still errors come out. if the process is executed within the <form> tag will the errors occurs?
please guide me
thanks.
|
|
|
|
09-27-2007, 06:35 AM
|
Re: radio button and mysql HELP PLEASE!
|
Posts: 134
|
any html tag
__________________
Please login or register to view this content. Registration is FREE
Check out the Facebook Clone build with Jcow SNS at Please login or register to view this content. Registration is FREE , it is free and it always will be
|
|
|
|
09-28-2007, 04:56 AM
|
Re: radio button and mysql HELP PLEASE!
|
Posts: 65
|
you mean if the header is executed within the <forms> tag error will occurs too?
|
|
|
|
09-28-2007, 06:43 AM
|
Re: radio button and mysql HELP PLEASE!
|
Posts: 134
|
yes, if the browser encouters any html tag before the header function is executed you get this error
__________________
Please login or register to view this content. Registration is FREE
Check out the Facebook Clone build with Jcow SNS at Please login or register to view this content. Registration is FREE , it is free and it always will be
|
|
|
|
10-01-2007, 02:18 AM
|
Re: radio button and mysql HELP PLEASE!
|
Posts: 65
|
let me try to make the changes again. ya there is one thing i wanna to ask which currently i am using the easyphp 1.8 and i encountered the error Fatal error: Maximum execution time of 30 seconds exceeded.... what should i do to solve the problem?
any one please help me
thanks
Last edited by leolim; 10-01-2007 at 03:09 AM..
|
|
|
|
10-02-2007, 10:36 PM
|
Re: radio button and mysql HELP PLEASE!
|
Posts: 65
|
falcone i think that i might know where the problem of the header error. let me try it. anyone know the easyphp1.8 solution for my problem?
|
|
|
|
10-09-2007, 08:55 PM
|
Re: radio button and mysql HELP PLEASE!
|
Posts: 65
|
could anyone tell me others software used to built PHP beside easyphp?
|
|
|
|
|
« Reply to radio button and mysql HELP PLEASE!
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|