Catzwolf
New Members-
Posts
4 -
Joined
-
Last visited
Never
Everything posted by Catzwolf
-
Hi all, I am using a user defined function to handle php and system (userdefined errors) in a singleton class. Now I use this class to handle php errors and I aslo want it to handle user defined errors. Will this cause any problems than I am not aware of? example set_error_handler( 'MyErrorHandler_HandleError' ); function handleError( $errno, $errstr, $errfile, $errline ) { //do error stuff here } function MyErrorHandler_HandleError( $errNo, $errStr, $errFile, $errLine, $errContext = null ) { $_eh = &error_handler::instance(); $_eh ->handleError( $errNo, $errStr, $errFile, $errLine, $errContext ); } I use the above to trap php errors to output later. Now, I want to use this to handle user defined errors, like a database insert that failed or if a user entered a wrong password. Could I pass user defined error via this handler? Would this cause problems else where? MyErrorHandler_HandleError( '1002', 'Failed to to login, wrong username or password', __FILE__, __LINE__, null ); Sorry if this doesn't seem clear enough lol Thanks Catz
-
Alphanumerical username with underscores and spaces
Catzwolf replied to Brandon Jaeger's topic in Regex Help
Try this instead: [code] '/[^a-zA-Z0-9\_\-]/' [/code] -
I am not the greatest with JS, to me it doesn't seem to make sense. I am comfortable with Object prgramming but JS is another story. I have been trying to get a script to work for the last few days, I keep getting the same error and the script refuses to work. The error is submit() is not a function. [code] /** * Start of User Output */ xoops_cp_header(); xoops_admin_menu( $tblColors, '', _AM_FINDUS, $op ); echo "<div><b>" . _AM_RESULTS . "</b></div><br />"; if ( $total == 0 ) { echo "<h4>" . _AM_NOFOUND, "</h4>"; } elseif ( $start < $total ) { echo sprintf( _AM_USERSFOUND, $total ) . "<br /><br />"; echo " <form action='admin.php' method='post' name='memberslist' id='memberslist'> <input type='hidden' name='op' value='delete_many' /> <table width='100%' border='0' cellspacing='1' cellpadding='2' class='outer'> <tr align='center'> <th> <input type='checkbox' name='memberslist_checkall' id='memberslist_checkall' onclick='xoopsCheckAll(\"memberslist\", \"memberslist_checkall\");' /> </th> <th>" . _AM_UNAME . "</th> <th>" . _AM_RANK . "</th> <th>" . _AM_REGDATE . "</th> <th>" . _AM_LASTLOGIN . "</th> <th>" . _AM_POSTS . "</th> <th> </th> </tr>"; foreach ( array_keys( $foundusers ) as $j ) { $class = ( $ucount % 2 == 0 ) ? 'even' : 'odd'; $ucount++; $fuid = $foundusers[$j]->getVar( "uid" ); $funame = $foundusers[$j]->getVar( "uname" ); $fuser_name = $foundusers[$j]->getVar( "name" ) ? $foundusers[$j]->getVar( "name" ) : " "; $funame_linked = $foundusers[$j]->getUnameFromId(); $last_login = $foundusers[$j]->getTimeStamp( null . 'last_login' ); $user_regdate = $foundusers[$j]->getTimeStamp( null . 'user_regdate' ); $rank = $foundusers[$j]->rank( true ); echo " <tr align='center'> <td class='head'> <input type='checkbox' name='memberslist_id[]' id='memberslist_id[]' value='" . $fuid . "' /> <input type='hidden' name='memberslist_uname[" . $fuid . "]' id='memberslist_uname[]' value='" . $funame . "' /> </td> <td class='even'>" . $funame_linked . "</td> <td class='even'>" . $rank . "</td> <td class='even'>" . $user_regdate . "</td> <td class='even'>" . $last_login . "</td> <td class='even'>" . $foundusers[$j]->getVar( "posts" ) . "</td> <td class='even'> <a href='" . $_PHP_SELF . "?fct=users&uid=" . $fuid . "&op=edituser'>" . xoops_img_show( 'edit', _EDIT, 'middle' ) . "</a> <a href='" . $_PHP_SELF . "?fct=users&uid=" . $fuid . "&op=deluser'>" . xoops_img_show( 'delete', _DELETE, 'middle' ) . "</a> <a href='" . $_PHP_SELF . "?fct=mailusers&uid=" . $fuid . "&type=0'>" . xoops_img_show( 'pmmailtot', _AM_SENDEMAIL, 'middle' ) . "</a> </td> </tr>\n"; } $group_array = array(); $this_array = array( 'users' => _DELETE, 'mailusers' => _AM_SENDMAIL ); if ( $group > 0 ) { $add2group = &$member_handler->getGroup( $group ); $group_array = array( 'groups' => sprintf( _AM_ADD2GROUP, $add2group->getVar( 'name' ) ) ); } $total_array = array_merge( $this_array, $group_array ); echo " <tr class='foot'> <td>"; xoops_getSelection( $total_array, 'users', 'fct' ); echo "</td>"; if ( $group > 0 ) { echo "<input type='hidden' name='groupid' value='" . $group . "' />"; } echo " <td colspan='10'><input type='submit' value='" . _SAVE . "' /></td> </tr> </table> </form>\n"; /* * JS to display page navigation. This part doesn't seem to work as expected */ $totalpages = ceil( $total / $limit ); if ( $totalpages > 1 ) { $hiddenform = "<form name='findnext' action='admin.php' method='post'><input type='hidden' name='op' value='findusers' />"; foreach ( $_POST as $k => $v ) { $hiddenform .= "<input type='hidden' name='$k' value='" . $myts->stripSlashesGPC( $v ) . "' />\n"; } if ( !isset( $_POST['limit'] ) ) { $hiddenform .= "<input type='hidden' name='limit' value='" . $limit . "' />\n"; } if ( !isset( $_POST['start'] ) ) { $hiddenform .= "<input type='hidden' name='start' value='" . $start . "' />\n"; } $prev = $start - $limit; if ( $start - $limit >= 0 ) { $hiddenform .= "<a href='#0' onclick='javascript:document.findnext.start.value=" . $prev . ";document.findnext.submit();'>" . _AM_PREVIOUS . "</a> \n"; } $counter = 1; $currentpage = ( $start + $limit ) / $limit; while ( $counter <= $totalpages ) { if ( $counter == $currentpage ) { $hiddenform .= "<b>" . $counter . "</b> "; } elseif ( ( $counter > $currentpage-4 && $counter < $currentpage + 4 ) || $counter == 1 || $counter == $totalpages ) { if ( $counter == $totalpages && $currentpage < $totalpages-4 ) { $hiddenform .= "... "; } $hiddenform .= "<a href='#" . $counter . "' onclick='javascript:document.findnext.start.value=" . ( $counter-1 ) * $limit . ";document.findnext.submit();'>" . $counter . "</a> "; if ( $counter == 1 && $currentpage > 5 ) { $hiddenform .= "... "; } } $counter++; } $next = $start + $limit; if ( $total > $next ) { $hiddenform .= " <a href='#" . $total . "' onclick='javascript:document.findnext.start.value=" . $next . ";document.findnext.submit();'>" . _AM_NEXT . "</a>\n"; } $hiddenform .= "</form>"; echo "<div style='text-align:center'>Users: " . $hiddenform . "</div><br />"; [/code] The script is to show users via a form, depending on certain criteria (Top half of the script is for display output) and this works as it should. There is a page navigation which is the second part, this uses JS to control which 'page' is selected and shown. This is the part that is giving me the error. If I click on the next page I get the above error. I thought this might have been due to me naming a button 'submit' but it still doesn't work. Any help would be great, Thanks
-
I have written a script to update the database when a user upgrades from one script to another. The problem I have is that I need to check that Field already exists, if not \'ADD\' to the \'TABLE\' or \'UPDATE\' field row. But everytime I try to \'UPDATE\' the field I get an error saying that it already exists? This is code I am trying to use: [php:1:4e2d389063]<?php $$result = $xoopsDB->queryF(\"ALTER TABLE \".$xoopsDB->prefix(\"wfs_category\").\" ADD groupid varchar(255) NOT NULL default \'1 2 3\'\"); if (!$result) { $result = $xoopsDB->queryF(\"ALTER TABLE \".$xoopsDB->prefix(\"wfs_category\").\" UPDATE groupid varchar(255) NOT NULL default \'1 2 3\'\"); if (!$result) { $error[] = \"Failed ALTER TABLE \".$xoopsDB->prefix(\"wfs_category\").\"\"; } }?>[/php:1:4e2d389063] But it will not update the table giving this MySQL Error: I am quite new to PHP/MySQL and any help would be really gratefull :-) Many thanks