November 2, 2008, 12:23 AM
Asked recently on Yahoo! Answers:
Multiple nested MySQL functions in PHP?
I was going through code today, trying to make some things more compact. The application worked without problems, so I knew that mysql error statements were superfluous.
This is the type of statement I was changing, I figured that I’d remove the seemingly unnecessary $result2 variable
$result2 = mysql_query($carts) or die(mysql_error());<br />
while ($row2 = mysql_fetch_array($result2)) {<br />
echo "<option>$row2[0]</option>";<br />
}
so this is what I changed it into (I basically replaced where it said $result2, to what $result2 had contained, and removed the error check)
while ($row2 = mysql_fetch_array(mysql_query($carts))) {<br />
echo "<option>$row2[0]</option>";<br />
}
but this code returned infinite loops, much to my surprise. Why is it doing this? is there a way around it?
Recently, I wrote about how PHP’s weak data types often can lead to problems for new programmers who don’t understand the difference between null, empty and zero-length variables. Here’s another opportunity to expose why strong data typing is essential for best programming practices, and to show how PHP’s weak data types — normally, a source of comfort for beginning programmers — can be the source of extensive frustration.
Continue reading ‘The Trouble With PHP’s Weak Data Types: An Example Examined And Explained’ »
Tags:
.NET,
Data Types,
Database,
MySQL,
Objects And Classes,
PHP,
SQL,
VB.NET,
Visual Basic,
XHTML Category:
Programming,
Yahoo! Answers |
2 Comments
October 22, 2008, 3:13 PM
A common problem faced by new programmers is understanding the difference between null, empty and zero-length variables, especially when working with database records.
While, for most intents and purposes, the three things have the same effect — either you have some data you can work with, or you don’t — they arise from different circumstances. Understanding how null, empty and zero-length are different can help you avoid data errors in your programs.
The short version is this: If a variable simply doesn’t exist — usually because it hasn’t been declared, but sometimes because it hasn’t been assigned a value — it’s null. If the variable exists but contains no data, it’s empty. And if a structured data variable, such as an array, exists but doesn’t contain any items, it’s zero-length.
An analogy is in order.
Think of a database as a house. A house has rooms, and in each of these rooms are furniture and accessories that are appropriate to that room.
For example, the kitchen has a stove, refrigerator and sink. The bedroom has a dresser, bed and armoire. The living room has a couch, television and coffee table.
Continue reading ‘The Difference Between Null, Empty And Zero-Length Data / Strings’ »
September 12, 2008, 12:51 AM
I have been working in VBA for Microsoft Office 2007 lately. And if you haven’t used it yet, I can tell you there have been significant changes in macro / VBA security versus Office 2003.
Basically, getting a VBA macro / module that hasn’t been digitally signed to run in Word 2007, Excel 2007 or Access 2007 requires the end user to go through a fairly complicated process — if his network’s group policies even allow unsigned macros to run — with many scary warnings against running unsigned code thrown in for good measure.
So I really needed to get a code-signing cert. And after looking around on the Web for places to get one, I settled on Comodo, via Tucows.
Tucows will sell a Comodo certificate for $75 per year, or $195 for three years — which, while not cheap, is less than half the cost some certificate authorities charge for a one-year cert, and a significant discount over Comodo’s published prices.
There’s not a lot on the Web about the experience and process of getting a certificate from Comodo, so I thought I would share some advice.
Continue reading ‘My Experience Getting A Code Signing Certificate From Comodo’ »
September 9, 2008, 12:18 AM
I have launched a new Web site to demo ASP.NET scripts. It is http://www.dhvrm.com.
I decided to create the site after reviewing my last couple of ASP.NET entries on this site and discovering that they have some serious errors. I’ll be updating each with new posts as time allows.
For the moment, there isn’t much to see at dhvrm.com, and my schedulewon’t't allow me to do too much more with it for the next few weeks.
But I will correct my ASP.NET scripts and try to create new demos for older posts that don’t have them in the near future. Stay tuned.
August 21, 2008, 12:45 AM
Recently asked on Yahoo! Answers:
How do I read and write binary image data from SQL server?
I’m making a website where visitors can upload their images, I’ve done the uploading code and it (probably) works fine because I can see the data is recorded on the database.
The problem is when I want to test it (display the image on the website) theoretically I have to read the data from the SQL server and write it to the web. I’ve done several ways and tests but all of them failed to display the image.
Anybody knows how to do this? I’m using visual web developer 2008 and VB.NET as programming language
Note: no “wizards” please, I want it to be implemented using fully coded like I did with the uploading code
There are other examples on the Web on how to do this, but most are either written in C#, or are very specific to a given set of circumstances, so I thought I would explore this subject for Visual Basic .NET, and in the process try to address a few different ways to display an image.
The executive summary: Displaying an image that’s stored in a database requires you to make a “helper page.” And that’s what we’re about to make.
Continue reading ‘Displaying An Image Stored In A SQL Server Database On An ASP.NET Page Using VB.NET’ »