Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Thursday, March 28, 2024
About Us
Magazine
Open Source
CVS
Services
Index  »  Projects  »  phpMyEdit  »  Forum  »  Will PME work under PHP5?

phpMyEdit Installation     Will PME work under PHP5?
Post new topic   Reply to topic   Goto page 1, 2  Next  
 
fat-tony     Joined: 25 Mar 2010   Posts: 2  
Post Posted: 2010-03-25 15:19
Back to top  Reply with quote     

I have a background in IT, but am not familiar particularly with PHP and MySQL.
I have installed the last version of PME on a Windows XP Pro system, running WAMP with Apache 2.2.11, PHP 5.3.0 and MySQL 5.1.36

I battled through various issues where phpMyEditsetup was using deprecated calls to MySQL and crashing Apache on me. I changed the MySQL code and it is now reliably generating table_name.php files for me.

However, when I run any of the generated php files I get errors.

The table name in this instance is called address and the generated file is called address.php.

The following is output on the screen:


address

Warning: array_keys() expects parameter 1 to be array, null given in D:\wamp\www\phpMyEdit-5.7.1\phpMyEdit.class.php on line 2930

Warning: Invalid argument supplied for foreach() in D:\wamp\www\phpMyEdit-5.7.1\phpMyEdit.class.php on line 2930

Warning: array_keys() expects parameter 1 to be array, null given in D:\wamp\www\phpMyEdit-5.7.1\phpMyEdit.class.php on line 2940

Warning: Invalid argument supplied for foreach() in D:\wamp\www\phpMyEdit-5.7.1\phpMyEdit.class.php on line 2940

Warning: array_keys() expects parameter 1 to be array, null given in D:\wamp\www\phpMyEdit-5.7.1\phpMyEdit.class.php on line 2967

Warning: Invalid argument supplied for foreach() in D:\wamp\www\phpMyEdit-5.7.1\phpMyEdit.class.php on line 2967

Warning: array_keys() expects parameter 1 to be array, null given in D:\wamp\www\phpMyEdit-5.7.1\phpMyEdit.class.php on line 3034

Warning: Invalid argument supplied for foreach() in D:\wamp\www\phpMyEdit-5.7.1\phpMyEdit.class.php on line 3034
MySQL error 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '`PMEtable0`.`` FROM `address` AS `PMEtable0` LIMIT 0, 15' at line 1
phpMyEdit error: invalid SQL query
SELECT ,`PMEtable0`.`` FROM `address` AS `PMEtable0` LIMIT 0, 1510.948 miliseconds

I have read through the forum posts and have tried various combinations of fixes, but nothing seems to work for me. As regards the specific SQL error it would appear that the SELECT statement should read SELECT * FROM address AS .... but the expression 'PMEtable0' is used instead. Any pointers to where I should be looking, please?

 
doug     Joined: 10 Feb 2003   Posts: 1013   Location: Denver, Colorado (USA)
Post Posted: 2010-03-27 14:59
Back to top  Reply with quote     

Somewhat unrelated, on three different PC's, I was never able to get the latest version of Apache to play well with PHP and MySQL, however version 2.06x worked perfectly. Installing the latest version of stuff is not always a good idea, given that comparatively few of us geeks waste our time with WAMP stuff and related bug reports are difficult (if not impossible) to locate. IMHO, on 64-Bit Windows 7, Apache's latest version works perfectly by itself, but it will NOT play well with PHP or MySQL due to obscure bugs in DLL files belonging to PHP and MySQL.

Post the schema (table structure) from your table, as exported using phpMyAdmin. Also determine if the same files and data set works OK on a Linux web server.

 
fat-tony     Joined: 25 Mar 2010   Posts: 2  
Post Posted: 2010-03-27 17:04
Back to top  Reply with quote     

doug - thanks for coming back to me. I hacked away at the code last night and finally got it to work. It seems that some of the deprecated db calls in mySQL 5 were causing the issue for me. I played around with the code and it works fine for me now. Ideally it needs to be re-written properly to suit mySQL 5,but for now it's generating table code for me such that I can CRUD.

Now I need to work out how to handle table joins!

I've pasted the changes I made in two sections of db handling in phpMyEditSetup.php

// I have extracted two fragments of code in phpMyEdit 5.7.1 where
// it was causing my php (5.3.0) and mySQL(5.1.36) to blow up.
// As far as I see it stems from use of code now deprecated in mySQL 5
// the count loops ($j or $k) were being initialised with wrong values
// Works like a charm now!


echo ' <h1>Please select an identifier from table: '.htmlspecialchars($tb).'</h1>
<p>
This field will be used in change, view, copy and delete operations.<br>
The field should be numeric and must uniquely identify a record.
</p>
<p>
Please note, that there were problems reported by phpMyEdit users
regarding using MySQL reserved word as unique key name (the example for
this is "key" name). Thus we recommend you to use another name
of unique key. Usage of "id" or "ID" should be safe and good idea.
</p>
<form action="'.htmlspecialchars($self).'" method="POST">
<input type="hidden" name="hn" value="'.htmlspecialchars($hn).'">
<input type="hidden" name="un" value="'.htmlspecialchars($un).'">
<input type="hidden" name="pw" value="'.htmlspecialchars($pw).'">
<input type="hidden" name="db" value="'.htmlspecialchars($db).'">
<input type="hidden" name="tb" value="'.htmlspecialchars($tb).'">
<table border="1" cellpadding="1" cellspacing="1" summary="Key selection">'.PHP_EOL;
// <tr><td><input type="radio" name="id" value="">
// <td><i>None</i></td><td><i>No id field required</i></td></tr>
@mysql_select_db($db);
$tb_desc = @mysql_query("DESCRIBE $tb");
$fds = @mysql_list_fields($db,$tb,$dbl);
$num_ids = @mysql_num_rows($tb_desc);
// for ($j = 0; ($fd = @mysql_field_name($fds, $j)) != false; $j++) { I commented out this and replaced it
for ($j = 0; $j < $num_ids; $j++) {
$fd = @mysql_field_name($fds, $j);
$ff = @mysql_field_flags($fds, $j);
strlen($ff) <= 0 && $ff = '---';
$checked = stristr($ff, 'primary_key') ? ' checked' : '';
echo '<tr><td><input',$checked,' type="radio" name="id" value="',htmlspecialchars($fd),'"></td>';
echo '<td>',htmlspecialchars($fd),'</td>';
echo '<td>',htmlspecialchars($ff),'</td>';
$r = @mysql_fetch_array($tb_desc, $j);
//
//
//
//
//





@mysql_select_db($db);
$tb_desc = @mysql_query("DESCRIBE $tb");
$fds = @mysql_list_fields($db, $tb, $dbl);
// $num_fds = @mysql_num_fields($fds); I commented out this and replaced it with the next line
$num_fds = @mysql_num_rows($tb_desc);

$ts_cnt = 0;
for ($k = 0; $k < $num_fds; $k++) {
$fd = mysql_field_name($fds,$k);
$fm = mysql_fetch_field($fds,$k);
$fn = strtr($fd, '_-.', ' ');
$fn = preg_replace('/(^| +)id( +|$)/', '\\1ID\\2', $fn); // uppercase IDs
$fn = ucfirst($fn);
$row = @mysql_fetch_array($tb_desc);
echo_buffer('$opts[\'fdd\'][\''.$fd.'\'] = array('); // )
echo_buffer(" 'name' => '".str_replace('\'','\\\'',$fn)."',");
$auto_increment = strstr($row[5], 'auto_increment') ? 1 : 0;
if (substr($row[1],0,3) == 'set') {
echo_buffer(" 'select' => 'M',");
} else {
echo_buffer(" 'select' => 'T',");
}
if ($auto_increment) {
echo_buffer(" 'options' => 'AVCPDR', // auto increment");
}
// timestamps are read-only
else if (@mysql_field_type($fds, $k) == 'timestamp') {
if ($ts_cnt > 0) {
echo_buffer(" 'options' => 'AVCPD',");
} else { // first timestamp
echo_buffer(" 'options' => 'AVCPDR', // updated automatically (MySQL feature)");
}
$ts_cnt++;
}
echo_buffer(" 'maxlen' => ".@mysql_field_len($fds,$k).',');
// blobs -> textarea
if (@mysql_field_type($fds,$k) == 'blob') {
echo_buffer(" 'textarea' => array(");
echo_buffer(" 'rows' => 5,");
echo_buffer(" 'cols' => 50),");
}
// SETs and ENUMs get special treatment
if ((substr($row[1],0,3) == 'set' || substr($row[1],0,4) == 'enum')
&& ! (($pos = strpos($row[1], '(')) === false)) {
$indent = str_repeat(' ', 18);
$outstr = substr($row[1], $pos + 2, -2);
$outstr = explode("','", $outstr);
$outstr = str_replace("''", "'", $outstr);
$outstr = str_replace('"', '\\"', $outstr);
$outstr = implode('",'.PHP_EOL.$indent.'"', $outstr);
echo_buffer(" 'values' => array(".PHP_EOL.$indent.'"'.$outstr.'"),');
}
// automatic support for Default values
if ($row[4] != '' && $row[4] != 'NULL') {
echo_buffer(" 'default' => '".$row[4]."',");
} else if ($auto_increment) {
echo_buffer(" 'default' => '0',");
}
// check for table constraints
$outstr = check_constraints($tb, $fd);
if ($outstr != '') {
echo_buffer($outstr);
}
echo_buffer(" 'sort' => true");
//echo_buffer(" 'nowrap' => false,");
echo_buffer(');');
}

echo_buffer("

 
youngd     Joined: 12 Aug 2010   Posts: 8  
Post Posted: 2010-08-12 22:38
Back to top  Reply with quote     

[quote="fat-tony"]doug - thanks for coming back to me. I hacked away at the code last night and finally got it to work. It seems that some of the deprecated db calls in mySQL 5 were causing the issue for me...snip"]

Hi I think I maybe having similar problems I am also running WAMP.
What were the deprecated MySQl calls you discovered?
Thanks
Don
Specifcs below.
I am running the WAMP package ( e.g. Apache v 2.2.11, PHP 5.3.0, MySQL 5.1.36) on Windows Vista I installed phpMyEdit 5.7.1 .
When I run phpMyEditSetup.php I get :
Notice: Undefined index: db in C:\wamp\www\phpcode\classes\phpMyEdit-5-7-1\phpMyEditSetup.php on line 70
Notice: Undefined index: tb in C:\wamp\www\phpcode\classes\phpMyEdit-5-7-1\phpMyEditSetup.php on line 71
Please log in to your MySQL database
Notice: Undefined variable: db in C:\wamp\www\phpcode\classes\phpMyEdit-5-7-1\phpMyEditSetup.php on line 194
Notice: Undefined variable: tb in C:\wamp\www\phpcode\classes\phpMyEdit-5-7-1\phpMyEditSetup.php on line 197

I added...
&#8220;error_reporting(E_ERROR | E_WARNING | E_PARSE);&#8221;
as suggested in the forum. It seems as if it is just covering a problem , but now the Notices were not displayed.

I now get the form and enter in the requested data
Hostname:, Username:, Password:, Database:, Table:
Upon submit it crashes Apache with the following in its log

&#8220;[Thu Aug 12 12:54:21 2010] [notice] Parent: child process exited with status 255 -- Restarting.&#8221;

One posting in the forum indicates there are depreciated MySQL calls but are not specific as to what they are. Also there are some references to previous versions of compnents that may work.

Any ideas on a solution that will allow me to not be dead ended by old versions?
Thanks

 
doug     Joined: 10 Feb 2003   Posts: 1013   Location: Denver, Colorado (USA)
Post Posted: 2010-08-12 22:55
Back to top  Reply with quote     

If your system is 64-bit my opinion is that in no way will PHP, MySQL, and Apache play well together. Based of 3-4 days smashing my head on the keyboard in January after acquiring 64-bit Windows 7. They'll all act OK on their own but the DLL's are messed up, bugs are slow to be reported, slow to be fixed, etc.

I'll bet if you revert back to Apache 2.0.x then all will work just fine. This is what I've had to do on every 64-bit Windows system.

 
youngd     Joined: 12 Aug 2010   Posts: 8  
Post Posted: 2010-08-13 00:48
Back to top  Reply with quote     

doug wrote:
..I'll bet if you revert back to Apache 2.0.x then all will work just fine. This is what I've had to do on every 64-bit Windows system.

I appreciate the quick response. ( BTW mine is a 64 bit version). I do not want to use an app that forces a previous version of Apache, since it seems like a dead end when other apps may require a more current version.

The WAMP combination I am using is not the latest versions of everything and seems to be working fine for other apps.

Is there some coding within phpMyEdit that causes the problem? I have looked in the Apache logs and windows event logs but no clues. Any ideas of how to track down the specific area giving the problem?
Thanks,

 
doug     Joined: 10 Feb 2003   Posts: 1013   Location: Denver, Colorado (USA)
Post Posted: 2010-08-13 01:54
Back to top  Reply with quote     

The unknown problem is with your WAMP installation, not phpMyEdit. Yes, there are some "Undefined variable" warnings depending on error_level but just ignore them. phpMyEdit works with MyISAM type tables having column 0 as a primary key (or unique key). Your tables are MyISAM, right? And first column a primary key?

64-bit errors in PHP .DLL's are most likely to be the problem. So few people install PHP or MySQL on Windows anyway, and even fewer on 64-bit systems, that bugs are super slow to get reported. Using releases which are one year old for PHP and definitely Apache 2.0x and not 2.2 would likely cure your problems.

Check your error logs for both PHP and Apache, since they might hold some clues to the problem.

 
youngd     Joined: 12 Aug 2010   Posts: 8  
Post Posted: 2010-08-13 07:48
Back to top  Reply with quote     

doug wrote:
... phpMyEdit works with MyISAM type tables having column 0 as a primary key (or unique key). Your tables are MyISAM, right? And first column a primary key?
.


The tables are InnoDB and do have first column as primary key.
I have checked the error logs for both PHP and Apache, but new clues.

Any suggestions on any other schema to Web form generator applications?
Much appreciated,
Don

 
doug     Joined: 10 Feb 2003   Posts: 1013   Location: Denver, Colorado (USA)
Post Posted: 2010-08-13 13:16
Back to top  Reply with quote     

Why are you using INNODB tables?

http://www.php-html-form.com/sakila/

 
youngd     Joined: 12 Aug 2010   Posts: 8  
Post Posted: 2010-08-13 17:04
Back to top  Reply with quote     

doug wrote:
Why are you using INNODB tables?

Doug , your responses are much appreciated
I had selected INNOB, because of the multiuser/ transactional features, but I changed it to ISAM and could now "submit" without crashing Apache Hooray! now it gives me the message...
Quote:
Please select an identifier from table: patient
This field will be used in change, view, copy and delete operations.
The field should be numeric and must uniquely identify a record.

Please note, that there were problems reported by phpMyEdit users regarding using MySQL reserved word as unique key name (the example for this is "key" name). Thus we recommend you to use another name of unique key. Usage of "id" or "ID" should be safe and good idea.

The key is in column 0 and named
Quote:
idrx
and I changed it to
Quote:
id_rx
and still same error message.
Your thoughts?

 
doug     Joined: 10 Feb 2003   Posts: 1013   Location: Denver, Colorado (USA)
Post Posted: 2010-08-13 18:01
Back to top  Reply with quote     

If you *really* need multiuser / transactional features then abandon phpMyEdit and hire a professional programmer or attend a lot of Oracle's MySQL training sessions.

Presumably phpMyAdmin exists in your control panel. Use it to export the table schema (uncheck Data) and post it here. Can't tell from the above how the key is defined (auto_increment MEDIUMINT(6) / SMALLINT(5) unsigned recommended). INT type wastes storage space.

Notes for my personal amusement if nothing else are at
http://www.php-html-form.com/index.php?s=26&t=1&f=2

 
youngd     Joined: 12 Aug 2010   Posts: 8  
Post Posted: 2010-08-13 18:39
Back to top  Reply with quote     

Hi Doug, thank you for yur insights
doug wrote:

Presumably phpMyAdmin exists in your control panel. Use it to export the table schema (uncheck Data) and post it here. Can't tell from the above how the key is defined (auto_increment MEDIUMINT(6) / SMALLINT(5) unsigned recommended). INT type wastes storage space.


Here is an export using phpMyAdmin, (I had been using mySQL Workbench.) I created a new myISAM DB and simple table. It still crashes Apache. I could have created the HTML form by now teh old fashioned way :-)
Quote:
-- phpMyAdmin SQL Dump
-- version 3.2.0.1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Aug 13, 2010 at 05:30 PM
-- Server version: 5.1.36
-- PHP Version: 5.3.0

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

--
-- Database: `test2db`
--

-- --------------------------------------------------------

--
-- Table structure for table `table1`
--

CREATE TABLE IF NOT EXISTS `table1` (
`idtable1` int(11) NOT NULL AUTO_INCREMENT,
`data_1` varchar(45) DEFAULT NULL,
`data_2` varchar(45) DEFAULT NULL,
`data_3` varchar(45) DEFAULT NULL,
PRIMARY KEY (`idtable1`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;

--
-- Dumping data for table `table1`
--

INSERT INTO `table1` (`idtable1`, `data_1`, `data_2`, `data_3`) VALUES
(1, '1', '2', '3'),
(2, '1', '2', '3'),
(3, '4', '5', '6');


 
doug     Joined: 10 Feb 2003   Posts: 1013   Location: Denver, Colorado (USA)
Post Posted: 2010-08-13 19:03
Back to top  Reply with quote     

Set sql-mode="" at my.ini and restart MySQL, and see if problems go away.

Crashes are probably due to Apache 2.2 not getting along with MySQL DLL's furnished with recent PHP versions, given a 64-bit operating system.

Properly configured hosting for $4.95 per month is available at http://secure.hostgator.com/cgi-bin/affiliates/clickthru.cgi?id=denver27

I'm out of ideas.

 
youngd     Joined: 12 Aug 2010   Posts: 8  
Post Posted: 2010-08-13 19:30
Back to top  Reply with quote     

doug wrote:
Set sql-mode="" at my.ini and restart MySQL, and see if problems go away.
I'm out of ideas.

Hi Doug, I could not find
Quote:
sql-mode
in my.ini, but added it. problem is still there.
Thank you for all ofyour help. I liked the striaght forwardness of myphpedit, but I may have to do it the old fashion way or find a different forms generator.
Best,
Don

 
doug     Joined: 10 Feb 2003   Posts: 1013   Location: Denver, Colorado (USA)
Post Posted: 2010-08-13 19:54
Back to top  Reply with quote     

When I'm right, no one remembers. When I'm wrong, no one forgets (especially my wife).

But given a 64-bit O/S, I'll bet $25 that other applications will have problems which won't go away either, until Apache 2.0.63 is installed. Several silent and under-documented bugs may produce unexpected results indefinitely.

On 64-bit Windows 7 I have individually installed and configured:
PHP Version 5.3.1
MySQL 5.1.42-community
Apache 2.0.63 (days spent with higher versions were a waste of time).

 
Post new topic   Reply to topic   Goto page 1, 2  Next  

Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top · Feedback form · Application form
Report bug on PLATON.SK website · Terms of use · Privacy policy