Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP post data to MySQL problem

Status
Not open for further replies.

tsltsl

Technical User
Jan 17, 2002
24
SE
Hi,
I have a problem which is hard to explain. It's with posting (or altering) html data into MySQL. The site uses htmlpages module for POST-NUKE. We have recently moved the site to a new server with updated PHP and MySQL. When altering a html code in an article from a html form the result get's really wierd in the DB.
--------
<form action=&quot; method=&quot;post&quot; enctype=&quot;application/x---------
For instance, if I delete some html lines those same lines can be repeated several times as the result!?
If I alter the code directly in the DB there's no problem.

I'm unable to reproduce the problem on another server with the same versions of PHP, MySQL and httpd:
(RH8)
mysql-server-3.23.52-3
mysql-3.23.52-3
php-mysql-4.2.2-8.0.5
php-4.2.2-8.0.5
register_globals = On in /etc/php.ini

What should I look for, what more info should I provide?
I have tested reloading the files and the DB but problem remains. If I copy the files and the DB's to another similar server with the same PHP settings the problem is gone!

I would really appreciate if someone have any ideas.
Thank you
-tsltsl-
 
Could you show some code? Did you output your query (echo $q;) and then paste it into the db directly to see what happens? You don't have the database named incorrectly?

Rick

-----------------------------------------------------------
RISTMO Designs
Arab Church
 
Sorry, I don't know what code to provide. I'm quite unfamiliar with how Post-Nuke work along with it's modules.

The Db name is correct, otherwise Post-Nuke would not work at all.

If I edit the row in the table from phpMyAdmin there is no problem.

Here is a part of the PHP code for htmlpages module that is used when updating/altering aa article:

------------------------------
/**
* modify an item
* This is a standard function that is called whenever an administrator
* wishes to modify a current module item
* @param 'pid' the id of the item to be modified
*/
function htmlpages_admin_modify($args)
{
// Get parameters from whatever input we need. All arguments to this
// function should be obtained from pnVarCleanFromInput(), getting them
// from other places such as the environment is not allowed, as that makes
// assumptions that will not hold in future versions of PostNuke
list($pid,
$objectid)= pnVarCleanFromInput('pid',
'objectid');
extract($args);

if (!empty($objecpid)) {
$pid = $objecpid;
}


// Create output object
$output = new pnHTML();

// Load API.
if (!pnModAPILoad('htmlpages', 'user')) {
$output-&gt;Text(_LOADFAILED);
return $output-&gt;GetOutput();
}

// The user API function is called.
$item = pnModAPIFunc('htmlpages',
'user',
'get',
array('pid' =&gt; $pid));

if ($item == false) {
$output-&gt;Text(_HTMLPAGESNOSUCHITEM);
return $output-&gt;GetOutput();
}

if (!pnSecAuthAction(0, 'htmlpages::', &quot;$item[title]::$pid&quot;, ACCESS_EDIT)) {
$output-&gt;Text(_HTMLPAGESNOAUTH.$item['title'].$pid);
return $output-&gt;GetOutput();
}

// Add menu to output - it helps if all of the module pages have a standard
// menu at their head to aid in navigation
$output-&gt;SetInputMode(_PNH_VERBATIMINPUT);
$output-&gt;Text(htmlpages_adminmenu());
$output-&gt;SetInputMode(_PNH_PARSEINPUT);

// Title
$output-&gt;Title(_EDITHTMLPAGES);

// Start form
$output-&gt;FormStart(pnModURL('htmlpages', 'admin', 'update'));

// Add an authorisation ID
$output-&gt;FormHidden('authid', pnSecGenAuthKey());
$output-&gt;FormHidden('printlink', '0'); //need this otherwise will never reve
rt to 0

// Add a hidden variable for the item id. This needs to be passed on to
// the update function so that it knows which item for which item to carry
// out the update
$output-&gt;FormHidden('pid', pnVarPrepForDisplay($pid));

// Start the table that holds the information to be input.
$output-&gt;TableStart();

// TITLE
$row = array();
$output-&gt;SetOutputMode(_PNH_RETURNOUTPUT);
$row[] = $output-&gt;Text(pnVarPrepForDisplay(_HTMLPAGESTITLE));
$row[] = $output-&gt;FormText('title', pnVarPrepForDisplay($item['title']), 32,
128);
$output-&gt;SetOutputMode(_PNH_KEEPOUTPUT);
$output-&gt;SetInputMode(_PNH_VERBATIMINPUT);
$output-&gt;TableAddrow($row, 'left');
$output-&gt;SetInputMode(_PNH_PARSEINPUT);

// printlink

$row = array();
$output-&gt;SetOutputMode(_PNH_RETURNOUTPUT);
$row[] = $output-&gt;Text(pnVarPrepForDisplay(_HTMLPRINTLINK));
$row[] = $output-&gt;FormCheckbox('printlink', pnVarPrepForDisplay($item['print
link']),'1', 'checkbox');
$output-&gt;SetOutputMode(_PNH_KEEPOUTPUT);
$output-&gt;SetInputMode(_PNH_VERBATIMINPUT);
$output-&gt;TableAddrow($row, 'left');
$output-&gt;SetInputMode(_PNH_PARSEINPUT);

// UID
$row = array();
$output-&gt;FormHidden('uid', $item['uid']); //makes sure nonadmins can edit
$output-&gt;SetOutputMode(_PNH_RETURNOUTPUT);
// only admins can change userid's
if (pnSecAuthAction(0, 'htmlpages::', &quot;$item[title]::$pid&quot;, ACCESS_ADMIN)) {

$row[] = $output-&gt;Text(pnVarPrepForDisplay(_HTMLPAGESUID));
$row[] = $output-&gt;FormText('uid', pnVarPrepForDisplay($item['uid']), 5,
5);
} else {
$row[] = $output-&gt;Text(pnVarPrepForDisplay(_HTMLPAGESUSER));
$row[] = $output-&gt;Text(pnVarPrepForDisplay(pnUserGetVar('uname')));
}
$output-&gt;SetOutputMode(_PNH_KEEPOUTPUT);
$output-&gt;SetInputMode(_PNH_VERBATIMINPUT);
$output-&gt;TableAddrow($row, 'left');
$output-&gt;SetInputMode(_PNH_PARSEINPUT);
// content
$row = array();
$output-&gt;SetOutputMode(_PNH_RETURNOUTPUT);
$row[] = $output-&gt;Text(pnVarPrepForDisplay(_HTMLPAGESCONTENT));
$row[] = $output-&gt;FormSubmit(_HTMLPAGESUPDATE);
$output-&gt;SetOutputMode(_PNH_KEEPOUTPUT);
$output-&gt;SetInputMode(_PNH_VERBATIMINPUT);
$output-&gt;TableAddrow($row, 'left');
$output-&gt;SetInputMode(_PNH_PARSEINPUT);


$output-&gt;TableEnd();
$output-&gt;FormTextArea('content', $item['content'],30,77);
// End form


$output-&gt;FormEnd();
// Return the output that has been generated by this function
return $output-&gt;GetOutput();
}


/**
* This is a standard function that is called with the results of the
* form supplied by htmlpages_admin_modify() to update a current item
* @param 'pid' the id of the item to be updated
* @param 'uid' the name of the item to be updated
* @param 'title' the name of the item to be updated
* @param 'content' the number of the item to be updated
*/
function htmlpages_admin_update($args)
{
// Get parameters from whatever input we need.
list($pid,
$uid,
$title,
$printlink,
$content) = pnVarCleanFromInput('pid',
'uid',
'title',
'printlink',
'content');

// User functions of this type can be called by other modules.
extract($args);

if (!pnSecConfirmAuthKey()) {
pnSessionSetVar('errormsg', _BADAUTHKEY);
pnRedirect(pnModURL('htmlpages', 'admin', 'view'));
return true;
}

// Load API.
if (!pnModAPILoad('htmlpages', 'admin')) {
pnSessionSetVar('errormsg', _LOADFAILED);
return $output-&gt;GetOutput();
}

// The API function is called.
if(pnModAPIFunc('htmlpages',
'admin',
'update',
array( 'pid' =&gt; $pid,
'uid' =&gt; $uid,
'title' =&gt; $title,
'printlink'=&gt;$printlink,
'content'=&gt; $content))) {
// Success
pnSessionSetVar('statusmsg', _HTMLPAGESUPDATED);
}

// This function generated no output, and so now it is complete we redirect
// the user to an appropriate page for them to carry on their work
pnRedirect(pnModURL('htmlpages', 'admin', 'view'));

// Return
return true;
}
---------------------------

Thanks
-tsltsl-
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top