stockton
Members-
Posts
319 -
Joined
-
Last visited
Never
Everything posted by stockton
-
Command in php works but not if in a *.inc file?
stockton replied to stockton's topic in PHP Coding Help
<?php // Thanks to http://www.tonymarston.net/php-mysql/errorhandler.html // set_error_handler('errorHandler'); function get_sql_error($sQuery, $hDb_conn, $sError, $bDebug) { if(!$rQuery = @mysql_query($sQuery, $hDb_conn)) { $sMssql_get_last_message = mysql_get_last_message(); $sQuery_added = "BEGIN TRY\n"; $sQuery_added .= "\t".$sQuery."\n"; $sQuery_added .= "END TRY\n"; $sQuery_added .= "BEGIN CATCH\n"; $sQuery_added .= "\tSELECT 'Error: ' + ERROR_MESSAGE()\n"; $sQuery_added .= "END CATCH"; $rRun2= @mysql_query($sQuery_added, $hDb_conn); $aReturn = @mysql_fetch_assoc($rRun2); if(empty($aReturn)) { echo $sError.'. MYSQL returned: '.$sMysql_get_last_message.'.<br>Executed query: '.nl2br($sQuery); } elseif(isset($aReturn['computed'])) { echo $sError.'. MYSQL returned: '.$aReturn['computed'].'.<br>Executed query: '.nl2br($sQuery); } return FALSE; } else { return $rQuery; } } function errorHandler ($errno, $errstr) { // echo "<br>Entered errorHandler()<br>"; // echo $errno." ".$errstr; switch ($errno) { case E_USER_WARNING: case E_USER_NOTICE: case E_WARNING: case E_NOTICE: case E_CORE_WARNING: case E_COMPILE_WARNING: break; case E_USER_ERROR: case E_ERROR: case E_PARSE: case E_CORE_ERROR: case E_COMPILE_ERROR: global $query; echo '<html xmlns="http://www.w3.org/1999/xhtml">'; echo '<head>'; echo '<title>Message</title>'; echo '<style>'; echo '<!--'; echo '.normalcopy { font-family: Verdana, Arial; font-size: 11px; color: Black; }'; echo '.bottomlinks { color: #666666; font-family: Arial, Helvetica, sans-serif; font-size: 11px; font-weight: normal; text-decoration: none; }'; echo '-->'; echo '</style>'; echo '</head>'; echo '<body bgcolor="#ffffff">'; $errorstring = "<align=center>" .date('Y-m-d H:i:s') .""; // $errstr .= " " . $erroruser; echo '<center>'; echo '<table border="0" cellpadding="0" cellspacing="0" width="748">'; echo '<tr>'; echo '<td align left = "" valign="top" height="73" class="normalcopy">'; echo '<p align="center"><strong>'.$errstr.'</p>'; echo '</td></align></tr>'; echo '</table>'; echo '</center>'; $logfile = "errorlog.html"; $client = $_SERVER['REMOTE_ADDR']; $errorstring .= " "; $errorstring .= $errstr; $errorstring .= " on "; $errorstring .= $client; $errorstring .= " by "; $errorstring .= $erroruser; $errorstring .= "<br>"; $Boodskap = "<br><align=left>" . date('Y-m-d H:i:s') . " " . $errstr; error_log($Boodskap, 3, $logfile); $headers = 'From: es-master@stockton.co.za' . "\r\n" . 'Reply-To: alf.stockton@telkomsa.net' . "\r\n"; mail("alf@stockton.co.za","Error log",$Boodskap,$headers); default: break; } // switch // get_sql_error($insert, $link, NULL, NULL); // echo "<a href=index.php><img src=images/Back.png>"; echo "</BODY>"; echo "</HTML>"; } // errorHandler ?> -
Command in php works but not if in a *.inc file?
stockton replied to stockton's topic in PHP Coding Help
I do not understand the ".inc files will NOT be parsed unless you add the .inc as a php handler on the apache server" as all other commands in the included file work fine. The included file contains a function which accepts a string as a parameter, builds a HTML page and also writes the string to a text file and then attempts to send an email, so saying it will not be parsed is going over my head and I do not understand. It is just the mail() command that fails but if I include the same mail() call directly in the parent php it works fine. BTW The "it does not work" means that the email is not sent. -
Command in php works but not if in a *.inc file?
stockton replied to stockton's topic in PHP Coding Help
I do have <?php and ?> at the beginning and end of my error-handler.inc ? -
If I issue the following from my logon.php the mail get sent correctly $mailstring = date('Y-m-d H:i:s') . " ".$erroruser." Logged on from ". $client; $headers = 'From: es-master@stockton.co.za' . "\r\n" . 'Reply-To: alf.stockton@telkomsa.net' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail("alf@stockton.co.za","Dinner Event",$mailstring,$headers); but if I include it as require_once('includes/error-handler.inc'); from the logon.php it does not work. All variables are populated in both cases. Please explain why this is happening.
-
I have a stored procedure that I wish to use to update two tables reliably. In other words either both tables are updated or neither. How do I achieve this? CREATE PROCEDURE spIssueScannedTickets @iEventID int, @MemberNum nvarchar(12), @BatchSize int, @FirstNumber nvarchar(12), @LastNumber nvarchar(12), @SlotsBalance int, @TableBalance int, @BonusBalance int, @UserID int AS DECLARE @Result int SET @Result = 0 BEGIN TRANSACTION INSERT INTO BundlesIssued (MemberNumber, EventID, BundleSize, FirstNumber, LastNumber, DateIssued, UserID, Invalid) VALUES (@MemberNum, @iEventID, @BatchSize, @FirstNumber, @LastNumber, GETDATE(), @UserID , 0x00) if (@SlotsBalance>0) INSERT INTO TicketsIssued (Date, EventID, MemberNumber, EarnType, NumTicketsIssued, Turnover, UserID) VALUES (GETDATE(),@iEventID,@MemberNum, 'Slots', @SlotsBalance, 0, @UserID) if (@TableBalance>0) INSERT INTO TicketsIssued (Date, EventID, MemberNumber, EarnType, NumTicketsIssued, Turnover, UserID) VALUES (GETDATE(),@iEventID,@MemberNum, 'Tables', @TableBalance, 0, @UserID) if (@BonusBalance>0) INSERT INTO TicketsIssued (Date, EventID, MemberNumber, EarnType, NumTicketsIssued, Turnover, UserID) VALUES (GETDATE(),@iEventID,@MemberNum, 'Bonus', @BonusBalance, 0, @UserID) COMMIT TRANSACTION SET @Result = @BatchSize RETURN @Result GO ???
-
Please tell me how I got the following wrong:- <form name="GetTicket" id="GetTicket" method="post" action="Winner.php?Event="<?php echo $Event ?>"> <table border="1" frame="box" cellpadding="3" align="center" width="300"> <tr><td align=left>Ticket Number</td> <td colspan="2" width=65%> <input type="submit" style="width:0px;height:0px;border:none"> <input type=text name="TicketNumber" id="TicketNumber" value=<?php echo $TicketNumber ?> > </td></tr> <tr><td align=left>Member Number</td> <td align=left><input type="text" readonly name=MemberNommer id=MemberNommer value=<?php echo $MemberNommer ?> ></td></tr> <tr><td align=left>Member Name</td> <td align=left><input type="text" readonly value=<?php echo $Naam ?> ></td></tr> The TicketNumber displays fine but neither the MemberNommer nor Naam display even though I have proved that the php variables contain valid data.
-
I have written the following Stored Procedure in an attempt to update two tables in the same database reliably but unfortunately it is not too successful. I ocassionaly end up with only the BundlesIssued tables updated and nothing in TicketsIssued. Please make suggestions on how I could make this stored procedure update both tables reliably. ALTER PROCEDURE spIssueScannedTickets @iEventID int, @MemberNum nvarchar(12), @BatchSize int, @FirstNumber nvarchar(12), @LastNumber nvarchar(12), @SlotsBalance int, @TableBalance int, @BonusBalance int, @UserID int AS DECLARE @Result int -- Declare variables used in error checking. DECLARE @error_var int, @rowcount_var int SET @Result = 0 BEGIN TRANSACTION INSERT INTO BundlesIssued (MemberNumber, EventID, BundleSize, FirstNumber, LastNumber, DateIssued, UserID, Invalid) VALUES (@MemberNum, @iEventID, @BatchSize, @FirstNumber, @LastNumber, GETDATE(), @UserID , 0x00) if (@SlotsBalance>0) -- Save the @@ERROR and @@ROWCOUNT values in local -- variables before they are cleared. SELECT @error_var = @@ERROR, @rowcount_var = @@ROWCOUNT -- check if an error occured and if the expected number of records were affected IF @error_var <> 0 or @rowcount_var <> 1 BEGIN ROLLBACK -- PRINT "Warning: Error on Insert 1" RETURN(-1) END INSERT INTO TicketsIssued (Date, EventID, MemberNumber, EarnType, NumTicketsIssued, Turnover, UserID) VALUES (GETDATE(),@iEventID,@MemberNum, 'Slots', @SlotsBalance, 0, @UserID) if (@TableBalance>0) -- Save the @@ERROR and @@ROWCOUNT values in local -- variables before they are cleared. SELECT @error_var = @@ERROR, @rowcount_var = @@ROWCOUNT -- check if an error occured and if the expected number of records were affected IF @error_var <> 0 or @rowcount_var <> 1 BEGIN ROLLBACK -- PRINT "Warning: Error on Insert 2" RETURN(-2) END INSERT INTO TicketsIssued (Date, EventID, MemberNumber, EarnType, NumTicketsIssued, Turnover, UserID) VALUES (GETDATE(),@iEventID,@MemberNum, 'Tables', @TableBalance, 0, @UserID) if (@BonusBalance>0) INSERT INTO TicketsIssued (Date, EventID, MemberNumber, EarnType, NumTicketsIssued, Turnover, UserID) VALUES (GETDATE(),@iEventID,@MemberNum, 'Bonus', @BonusBalance, 0, @UserID) -- Save the @@ERROR and @@ROWCOUNT values in local -- variables before they are cleared. SELECT @error_var = @@ERROR, @rowcount_var = @@ROWCOUNT -- check if an error occured and if the expected number of records were affected IF @error_var <> 0 or @rowcount_var <> 1 BEGIN ROLLBACK -- PRINT "Warning: Error on Insert 3" RETURN(-3) END COMMIT TRANSACTION SET @Result = @BatchSize RETURN @Result GO -- The function will return your batchSize (that was passed to it, or a Negative number if an error occured
-
I understand what maexus had to say and if one must allow for users who have javascript disallowed, why use it at all? I am also confused as to why it would "allows for websites to behave more like traditional desktop applications" I can see the advantage on large web pages(I think) but if one has to allow for user with javascript switched off, then why use it at all?
-
I need to understand why one needs or wants to use Ajax. I do understand that moving a large amount of data across a network(and the internet is a network) when only one or two pieces of data are needed is a waste. I am assuming that when a user clicks a button on a form based web page the whole form is moved.
-
[SOLVED] Auto print to default printer
stockton replied to stockton's topic in PHP Installation and Configuration
Thank you. Now I understand a little better. -
[SOLVED] Auto print to default printer
stockton replied to stockton's topic in PHP Installation and Configuration
The thing that is confusing me is that there is a C# application on the client(this is an intranet) that prints directly to the default printer without involving the Window's print dialog and the user want their webapp to do the same. -
[SOLVED] Auto print to default printer
stockton replied to stockton's topic in PHP Installation and Configuration
Sorry, I did not explain myself clearly enough. The user has already on a previous screen clicked print. -
[SOLVED] Auto print to default printer
stockton replied to stockton's topic in PHP Installation and Configuration
Would it make any difference if I used something other than JavaScript? VBScript? Java? -
[SOLVED] Auto print to default printer
stockton posted a topic in PHP Installation and Configuration
I have an application running on Windows XP & IE7 which currently displays a screen of information and then uses javascript self.print(); to print same to locally connected printer. Two things wrong with this and they are:- 1) I want my application to print directly to the default printer without the Windows select printer dialog coming up and 2) I really dont need to display the screen. All the user wants is a printout, receipt. Suggestions please. -
Where, on phpfreaks, would you want me to ask that question?
-
I have a MSSQL database with a table containing a row defined as Column Name Data Type Length Turnover decimal 5 also in Enterprise Manager I see Precision is set to 7 and Scale is set to 2. Is it possibly that the max value could be limited to 9999,99 and if so what needs altering to allow up to 1000000,00?
-
Thank you again and sorry that you needed to point out my stupid error of using $Winner rather than $Winners
-
Ben, The code to populate the array looks like:- $Count = 0; // Here we populate array of previous winners $Winners = array(); while ($row = mssql_fetch_array($rs)) { $Winners[$Count] = array('Date Won'=>$row['DateWon'], 'MemberNumber'=>$row['MemberNumber'], 'TicketNumber'=>$row['TicketNumber'], 'UserID'=>$row['UserID'], 'RoundCounter'=>$row['RoundCounter']); $Count++; } echo '<pre>'.print_r($Winners,1).'</pre>'; and the print_r gives me the correct data as follows:- Array ( [0] => Array ( [Date Won] => 2008-01-01 00:00:00 [MemberNumber] => 2020119011 [TicketNumber] => 0100018481 [userID] => 37 [RoundCounter] => 1 ) [1] => Array ( [Date Won] => 2008-01-02 00:00:00 [MemberNumber] => 2020119011 [TicketNumber] => 0100018481 [userID] => 37 [RoundCounter] => 2 ) [2] => Array ( [Date Won] => 2008-01-03 00:00:00 [MemberNumber] => 2020119011 [TicketNumber] => 0100018481 [userID] => 37 [RoundCounter] => 3 ) [3] => Array ( [Date Won] => 2008-01-01 00:00:00 [MemberNumber] => 2 [TicketNumber] => 0100018481 [userID] => 37 [RoundCounter] => 4 ) ) Now how do I populate my HTML page? The closest I have got is:- <?php for ($Nommer = 0; $Nommer < $Count; $Nommer++) { $Name = Get_Member_Name($Winner[$Nommer][MemberNumber]); echo "<tr bgcolor='#C0A062' onMouseover=this.bgColor='#FFF7DF' onMouseout=this.bgColor='#C0A062'> <td align='center'>.$Winner[$Nommer][Date Won].</td> <td align='center'>.$Winner[$Nommer][MemberNumber].</td> <td align='center'>.$Name.</td> <td align='center'>.$Winner[$Nommer][TicketNumber].</td> <td align='center'>.$Winner[$Nommer][userID].</td> </tr>\n"; } ?> but this displays the key not the data/value. Date MemberNumber Member Name TicketNumber User .[Date Won]. .[MemberNumber]. .Client [] not found!. .[TicketNumber]. .[userID]. .[Date Won]. .[MemberNumber]. .Client [] not found!. .[TicketNumber]. .[userID]. .[Date Won]. .[MemberNumber]. .Client [] not found!. .[TicketNumber]. .[userID]. .[Date Won]. .[MemberNumber]. .Client [] not found!. .[TicketNumber]. .[userID].
-
I now have:- <?php for ($Nommer = 0; $Nommer <= $Count; $Nommer++) { echo "<tr bgcolor='#C0A062' onMouseover=this.bgColor='#FFF7DF' onMouseout=this.bgColor='#C0A062'> <td align='center'>.$Winner[$Nommer][Date Won].</td> <td align='center'>.$Winner[$Nommer][MemberNumber].</td> <td align='center'>.$Winner[$Nommer][TicketNumber].</td> <td align='center'>.$Winner[$Nommer][userID].</td> </tr>\n"; } ?> but it displays the key not the value?
-
In fact what I need to populate from that array is a table as follows:- <tr bgcolor="#C0A062" onMouseover=this.bgColor="#FFF7DF" onMouseout=this.bgColor="#C0A062" > <td align=\"center\"><?php echo $Winner[0]['Date Won'] ?></td> <td align=\"center\"><?php echo $Winner[0]['MemberNumber'] ?></td> <td align=\"center\"><?php echo $Winner[0]['TicketNumber'] ?></td> <td align=\"center\"><?php echo $Winner[0]['UserID'] ?></td> </tr>
-
OK I got part of it:- $Winners[$row[$Count]] should read $Winners[$Count]. Now how do I extract the data? Would it be something like $Winners[0][Date Won] and $Winners[1][Date Won] etc?
-
I have eventually got correct data in my array as follows:- $Count = 0; // Here we populate array of previous winners $Winners = array(); while ($row = mssql_fetch_array($rs)) { echo '<pre>'.print_r($row,1).'</pre>'; $Winners[$row[$Count]] = array('Date Won'=>$row['DateWon'], 'MemberNumber'=>$row['MemberNumber'], 'TicketNumber'=>$row['TicketNumber'], 'UserID'=>$row['UserID'], 'RoundCounter'=>$row['RoundCounter']); $Count++; } echo '<pre>'.print_r($Winners,1).'</pre>'; but it displays incorrectly:- Array ( [1] => Array <------- Looks OK except I would expect to start @ 0 ( [Date Won] => 2008-01-01 00:00:00 [MemberNumber] => 2020119011 [TicketNumber] => 0100018481 [userID] => 37 [RoundCounter] => 1 ) [2020119011] => Array <------- Where did this come from ( [Date Won] => 2008-01-02 00:00:00 [MemberNumber] => 2020119011 [TicketNumber] => 0100018481 [userID] => 37 [RoundCounter] => 2 ) [WCC] => Array <------- Where did this come from ( [Date Won] => 2008-01-03 00:00:00 [MemberNumber] => 2020119011 [TicketNumber] => 0100018481 [userID] => 37 [RoundCounter] => 3 ) and finally how do I extract this data from my array?
-
What I have done is:- $Winners = array(); while ($row = mssql_fetch_array($sr)) { $Winners[$row['UserNum']] = array('First Name'=>$row['FirstName'], 'Last Name'=>$row['LastName']); $Count++; } echo '<pre>'.print_r($Winners,1).'</pre>'; but all I get printed is :- Array { } Please tell me what I have misunderstood.
-
Thank you. I did not know that the key was being given a name by the =>, but now I know....:-)
-
Thank you for your reply. An item in your reply that I do not understand is what the => means. I understand = and >= but please tell me what the => in the context of your suggestion means.