Posts Tagged ‘line numbers’
Sunday, August 22nd, 2010
This is my script for counting file size in folders, but when I put this script on normal text page it shows error:
Warning: in_array() [function.in-array]: Wrong datatype for second argument in statistics.php on line 20
- <?php
-
if (session_id() == ""){
-
session_start();
-
}
-
$maxupload=1024000000; // in byte
-
$dir=’jdownloads’;
-
$notcount=array(‘index.html’,'listing.php’,'descriptionfile.txt’);
-
dirs($dir);
-
$sizeinbyte=($_SESSION[tots]==0)?’0′:$_SESSION[tots];
-
$_SESSION[tots]=array();
-
unset($_SESSION[tots]);
-
function dirs($dir){
-
global $notcount;
-
if ($handle = opendir($dir)) {
-
while (false !== ($file = readdir($handle))) {
-
if ($file != "." && $file != "..") {
-
if(is_dir($dir.’/’.$file)){
-
dirs($dir.’/’.$file);
-
}else{
-
if (!in_array($file, $notcount)) {
-
$fl=filesize($dir.’/’.$file);
-
$_SESSION[tots]=$_SESSION[tots]+$fl;
-
}
-
}
-
}
-
}
-
closedir($handle);
-
}
-
}
-
?>
Tags: array function, datatype, folders, line numbers, statistics
Posted in dotnet, vb, vb.net | No Comments »
Sunday, August 22nd, 2010
Hello Everyone,
I’m having abit of difficulty with an aspect of Access. I wish to create a query which changes a persons wage depending upon their age. This is what I have done so far:
-
SELECT Tble_Staff.[Unique Staff Number], Tble_Staff.[Age], Tble_Staff.[Age] AS Normal_Wage
-
FROM Tble_Staff
-
WHERE IIF([Normal_Wage]=12,13,IIF([Normal_Wage]=13,13.34,IIF([Normal_Wage]=14,13.78,IIF([Normal_Wage]=15,14,IIF([Normal_Wage]=16,14.50,IIF([Normal_Wage]=17,14.70,IIF([Normal_Wage]>=18,15.60,"Invalid Number")))))));
-
Now, I have the feeling that this doesn’t work due to the fact that I utilise the [Normal_Wage] variable twice. However, I am unsure as to how to avoild this.
Any help or suggestions would be greatly appreciated. I need to get this done ASAP.
Thanks,
Edward Gorman
Tags: abit, hello everyone, line numbers
Posted in dotnet, vb, vb.net | No Comments »
Sunday, August 22nd, 2010
Hello, I am trying to figure out how to redirect users from accessing a form if they have already submitted it within the past hour. I am trying to figure this out because the TOS with my hosting company state that I cannot send over x amount of emails per hour. This form is made to send out to a distribution list and if it gets submitted twice within the same hour, I will be breaking the TOS. What should I do to prevent the form from getting submitted twice within the same hour? I have had to resort to something because even though I tell the other admins, they still break it every now and then.
Here is a modified version of the form(test_mail.php). It is made to send out text messages. The only difference between the two forms is that one actually sends to the distribution list and this one doesn’t.
-
<?php
-
if ($_POST["emailaddress"]<>”) {
-
$ToEmail = ’testmail@higherpowermedia.com ’;
-
$mailheader = "From: ".$_POST["fullname"]."rn";
-
$mailheader .= "Reply-To: ".$_POST["emailaddress"]."rn";
-
$mailheader .= "Content-type: text/html; charset=iso-8859-1rn";
-
$MESSAGE_BODY .= "".nl2br($_POST["comment"])."";
-
mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure");
-
?>
-
Your message has been successfully sent to all users.
-
<?php
-
} else {
-
?>
-
<html>
-
<head>
-
<script language="javascript"><!–
-
-
maxKeys = 136;
-
var IE = (document.all) ? 1 : 0;
-
var DOM = 0;
-
if (parseInt(navigator.appVersion) >=5) {DOM=1};
-
-
function txtshow( txt2show ) {
-
-
// Detect Browser
-
-
if (DOM) {
-
var viewer = document.getElementById("txtmsg");
-
viewer.innerHTML=txt2show;
-
}
-
else if(IE) {
-
document.all["txtmsg"].innerHTML=txt2show;
-
}
-
}
-
-
function keyup(what)
-
{
-
var str = new String(what.value);
-
var len = str.length;
-
var showstr = len + " characters of " + maxKeys + " have been entered";
-
if (len > maxKeys) showstr += ’<br>Your text message is over 136 characters long, please revise your entry.’;
-
txtshow( showstr );
-
}
-
//–></script>
-
-
-
-
</head>
-
<body>
-
<form action="test_mail.php" method="post">
-
-
<input id="name" class="text-input" type="hidden" name="fullname" value="TestMail">
-
-
-
<input id="email" class="text-input" name="emailaddress" type="hidden" value="testmail@higherpowermedia.com">
-
You are limited to 136 characters.
-
-
<br>
-
<input id="message" class="text-input" name="comment" type="text" maxlength="136" onkeyup="keyup(this)" style="width: 200px">
-
<br><div id="txtmsg">
-
</div>
-
-
<input type="submit" class="submit" name="Submit" value=" Broadcast Message">
-
</form><?php
-
};
-
?>
-
</body>
-
</html>
-
Tags: admins, distribution list, hosting company, line numbers, mail php, modified version, test mail, text messages, tos
Posted in dotnet, vb, vb.net | No Comments »
Saturday, August 21st, 2010
Hi All,
I am creating a custom chart using SVG and I am having problems while dealing with text on IE. I have the SVG file being loaded through an EMBED tag and I can access it through JavaScript. This is a line chart and the lines are being positioned correctly. The problem is that I want to change the text of the scale to the values on the JavaScript, but I can’t make it work on IE.
Below is the code snippet that handles this:
-
var newText = svg_doc.createElementNS(svgNS,"text");
-
newText.setAttributeNS(null,"x",100);
-
newText.setAttributeNS(null,"y",100);
-
newText.setAttributeNS(null,"font-size","13px");
-
newText.setAttributeNS(null,"text-anchor","middle");
-
newText.setAttributeNS(null,"fill-opacity",Math.random());
-
var red = Math.round(Math.random() * 255);
-
var green = Math.round(Math.random() * 255);
-
var blue = Math.round(Math.random() * 255);
-
newText.setAttributeNS(null,"fill","rgb("+ red +","+ green+","+blue+")");
-
var textNode = document.createTextNode("a new text");
-
newText.appendChild(textNode);
-
My code stops working when I call appendChild(). I have seen this working when the code is inside the SVG file. But due to restrictions on the system I am working in I have to put my code on a HTML that has the SVG on an EMBED tag.
On Firefox this would be quite simple using something like this:
-
var text_el = svg_doc.getElementById(‘value’);
-
text_el.textContent = ’something’;
-
But this construction does not work in IE. Nor it throws an error. Does anybody know of any similar way of dealing with SVG text IE?
Any help would be really appreciated,
Thanks a lot in advance,
Regards,
Igor
Tags: code snippet, embed tag, line numbers, svg
Posted in dotnet, vb, vb.net | 1 Comment »
Friday, August 20th, 2010
Hello everyone
I would like to load some images using JS.
My code:
-
var img=new Image();
-
img.onload = function() {f1()};
-
img.onerror = function() {f2()};
-
img.src=’http://example.com/image.gif’;
-
sett = setTimeout(function() {f3()}, 100000);
-
-
//f3 contains not interesting code and:
-
img = null;
-
clearTimeout(sett);
-
Simply task, but I have two problems.
1) Some images don’t listen to orders from setTimeout and load for 200 and more second. What is wrong with my code? Notice, that it happens only with some images, not all.
2) Images are loading according to status of currently user. In some cases there can appear images which require to login by htpassword to see them. Then user would see a window with fields to login. What can I do to in that case skip this image and avoid showing that window?
Thank you so much for any help.
Tags: hello everyone, images, line numbers
Posted in dotnet, vb, vb.net | No Comments »
Friday, August 20th, 2010
I’m trying the run a function that only executes if an array is empty.
If the array is empty is technically has one element with the value of ”.
The above code should tell me if the array has one or more non-empty elements and it works. However although it works, I get this message.
Warning: array_filter() [function.array-filter]: The first argument should be an array in /my server/my site /public_html/my file.php on line 40
If there a solution to this please?
Tags: array, element, empty elements, file php, filter function, line numbers
Posted in dotnet, vb, vb.net | No Comments »
Friday, August 20th, 2010
I have a couple of private subs where I open multiple recordsets and then close them and set them to nothing in my Exit_Procedure. Example:
-
On Error GoTo Error_Handler:
-
-
Dim rs1 As ADODB.Recordset
-
Dim rs2 As ADODB.Recordset
-
‘etc.
-
-
‘…code…
-
-
Exit_Procedure:
-
On Error Resume Next
-
rs1.Close
-
Set rs1 = Nothing
-
rs2.Close
-
Set rs2 = Nothing
-
’etc.
-
Exit Sub
-
Error_Handler:
-
MsgBox "Error " & Err.Number & ": " & Err.Description, vbCritical
-
Resume Exit_Procedure
-
Usually, if a certain criterion is met I have the code jump to my Exit_Procedure. Using the example code above, if my rs1 recordset is empty (BOF And EOF = True) then I have it jump to the Exit_Procedure. The problem is that when it gets to rs2.Close in my Exit_Procedure I get a runtime error 91: Object variable or With block variable not set. I understand the error. However, I thought the On Error Resume Next line would cause the code to overlook this? I don’t want to remove this line of code because rs2 would need to be closed and set to Nothing if it’s opened during another execution of the code.
Tags: exit procedure, line numbers, subs
Posted in dotnet, vb, vb.net | No Comments »
Friday, August 20th, 2010
Hello,
I am attempting to import an excel document into a mysql database using python. The excel document has three columns of data: MATCH_ID, DATETIME, and POS_TYPE. Using the code I’ll show at the end, I have successfully imported the excel document except for one problem. The column DATETIME has values in the format of ‘yyyy-mm-dd’. Yet when I try the importing, all the values just come out as ’0000-00-00′. When I tried importing this as a varchar file, all of the numbers that came out were just a large five-digit number. I;m thinking this may have something to do with the formating of the cells in excel. The other two values which are just a number string and a short word import perfectly. I have tried changing the variable type, but that was not helpful. Clearly form my code you can see I quite new at this. Your help will be very much appreciated.
-
from xlrd import open_workbook, cellname
-
import MySQLdb as mysql
-
db=mysql.connect(db_info)
-
c=db.cursor()
-
c.execute(‘CREATE DATABASE actual_data’)
-
-
db=mysql.connect(db_info)
-
c=db.cursor()
-
c.execute(‘CREATE TABLE actual_data_table (MATCH_ID VARCHAR(35) NOT NULL,DATETIME DATE NOT NULL,POS_TYPE VARCHAR(35) NOT NULL, TICKER VARCHAR(35) NOT NULL, EXIT_TYPE TEXT NOT NULL)’)
-
-
file_to_import=’actualdata.xls’
-
column_count=5
-
book=open_workbook(file_to_import)
-
sheet=book.sheet_by_index(0)
-
db=mysql.connect(db_info)
-
c=db.cursor()
-
-
for row_index in range(sheet.nrows):
-
-
row_num=row_index
-
MATCH_ID=sheet.cell(row_index,0).value
-
DATETIME=sheet.cell(row_index,1).value
-
POS_TYPE=sheet.cell(row_index,2).value
-
c.execute(‘insert into actual_data_table values ("%s","%s","%s")’ % (MATCH_ID, DATETIME, POS_TYPE))
-
(MATCH_ID,DATETIME,POS_TYPE)
-
-
cursor.close()
-
conn.commit()
-
conn.close()
-
Tags: cells, datetime, digit number, formating, line numbers, mysql database, number string, Python, variable type, yyyy
Posted in dotnet, vb, vb.net | No Comments »
Thursday, August 19th, 2010
As I am learning PHP, I am running into errors in my code. I notice that the error message contains the line number. I have been using NotePad (OS=windows-7 Ultimate) to print the code but I notice line numbers do not print. Is there any way to print line numbers when you want to view the code?
Thanks,
Sam
Tags: error message, line numbers, notepad, os windows
Posted in dotnet, vb, vb.net | No Comments »
Thursday, August 19th, 2010
Tags: action script in flash, code id, flash template, line numbers, mail, mini test, php code, script in flash, test string
Posted in dotnet, vb, vb.net | No Comments »