The easiest way would be to force the input to $cntry to be regular. Is it put in via a form? If so, it would be better to separate street, city, and country into different fields on the form. If the data is created some other way, you could add a <br /> where the country should be, even if it's not there. If you don't have any control over how the data is created, it could be a problem. Without some regular way to differentiate between fields in a string, you almost have to do it manually because a computer lacks the 'intelligence' to know whether "Port Moresby" is a city, country, or street from the context. You could keep a database of all cities, countries, and streets and compare each field with the database, but creating the database would be nontrivial, and it still wouldn't help in situations where alternate spellings or misspellings occur.
This question is more from curiosity than necessity. I've been playing with the Java2D API, and I noticed a weird quirk with using Active Rendering. The Graphics 2D object doesn't appear to do anything the first time I use it. My code basically looks like this (I know it isn't the proper way to do drawing; I'm just testing stuff with some code I threw together in a few minutes):
public class GraphicsTest
{
private JFrame window;
public void init()
{
window = new JFrame("test");
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setPreferredSize(new Dimension(800, 600));
window.setIgnoreRepaint(true);
window.pack();
window.setLocationRelativeTo(null);
window.setVisible(true);
}
public void render(int x, int y)
{
Graphics2D g = window.getGraphics();
g.drawLine(0, 0, x, y);
Toolkit.getDefaultToolkit().sync();
g.dispose();
}
public static void main(String args[])
{
GraphicsTest gt = new GraphicsTest();
gt.init();
gt.render(100, 100);
}
}
It displays the window, but it's blank. However, if I add another call to gt.render() right after the first one in main, the new line shows up, but the old one does not. If I add subsequent calls, the new ones shows up, but only the first one does not.
I've looked through the Java2D tutorials and API doc, but I haven't found an answer to the question, "Why does it not draw on the first call?" Does anyone know the reason?
I often find myself parsing a url or filepath for includes and links, and it usually leads to messy, frustrating code. Given PHP's massive library, I assumed there would be something to make life easier, but I couldn't find anything while pouring over the online reference. It's a lot of material, though, so I may have missed something. Does anyone know the best way to play with paths?
Here's one example of this problem. I have a navigation template that I include in every page on my site, but the relative links need to be processed to work at different folder depths. For instance, the relative link to mysite.com/folder1/ from mysite.com/ would be "folder1/". From mysite.com/folder2/, it would be "../folder1/". From mysite.com/folder1/page.html, it would be "/".
The script I wrote to perform this function is pretty messy. It involves grabbing the path through $_SERVER, exploding it around "/", finding the depth of current file, and finally adding the necessary "../" to the relative link. I run into situations like this a lot, and I haven't been able to find a general solution thus far. Any tips on the best way to handing path parsing?
If I understand what you're asking, try using a for loop like this:
for($i = 0; $i < count($array); ++$i)
{
if($i % 3 == 0)
explode($array);
}
The $i % 3 will return the remainder of $i divided by 3, and the remainder will be 0 every third element. I wasn't exactly sure if this is what you were trying to do; let me know if it helps.
A function doesn't have access to variables created outside it. If a variable in a function has the same name as one outside the function, the one inside the function is still considered a different variable. When you leave the function and use the variable name again, it is the same as before you entered the function. You can read a better explanation of variable scope in PHP's manual.
You can get around this problem in a few different ways. The safest method is probably to use function arguments as Zagga mentioned, but if you want to be able to simply call connect() (without worrying about arguments and such) elsewhere in your code, you'll need another solution. You can use the global modifier to make variables inside functions refer to global variables:
connect()
{
global $db, $name, $pass, $tbl;
...
}
It isn't the preferred solution, but it will allow calls to connect() to look prettier.
Mongooseman - I'm with ProStores. If you can let me know your store name with us I can offer some help on the ProStores front. Hopefully since you mentioned us already you won't mind me jumping in here. You can contact me on twitter: www.twitter.com/ecommerceguy
Our store's name is RDMElectronics. I don't have a twitter account, but I've been meaning to sign up. Thanks for responding!
I work as a web developer for a small-to-medium sized company. We're not huge, but we do business throughout the entire US and internationally because our service is very niche. We repair and remanufacture gas station and car wash products. We sell to distributors, who in turn service individual gas stations and car washes.
Last summer I was primarily tasked with making the website not suck (because it did). Now, it's decent in terms of layout, markup, and content, but it does not have much in the way of search engine optimization. Optimizing it is my main job this summer.
Since I received my mission, I've been reading up on the subject. I read a good chunk of the book Search Engine Optimization Bible, Second Edition, and I've been consistently reading articles on the web. I added the keywords and description tags and set up Google Analytics and Webmasters accounts. However, the site largely lacks content.
I've been thinking of ways to keep fresh, dynamic content available, but neither I nor my supervisor (who's in charge of marketing) can think of anything right away. We currently have about fifteen main pages (although a couple will likely be merged soon), and only one is updated frequently (to show a table of used pumps available). We have a press release page, but it hasn't been updated in over a year. We don't have a lot of news-worthy events occur within our company (unless we were to announce when an …
This is a question that has often plagued me--in PHP, and any kind of development, really. I get obsessed with the absolute correct way to do something, and the search to find that method overshadows the need to create the end product. Often, I never find that method, and the end product is never created, or sometimes never even started.
I've learned that, in most cases, there is no single right way to do something. Important guidelines exist that must be followed, but even they leave fairly broad wiggle room. Learn as much as you can from books, but don't neglect the best teacher: experience.
When I begin learning a new technique, I usually spend a little time playing around before I get serious about design. I learn a little bit, then start coding with no intention of my work being in a final product. Most of this code will be thrown away, but the time invested is minimal. I may go through several iterations of starting, starting again, and again, and again, taking notes as I go along. In each new iteration, I'll reuse the good from the previous attempt.
Note, however, that this process is one of learning, not engineering. Currently, most of my work does pertain to learning since I'm still in school, but I doubt my method would work well in a serious job situation in which I'm expected to already know my stuff. It's also not usually suited to class assignments, which …
Awesome. Thanks for the help! This is the approach I'm going to take, then. I'm researching the session and database stuff now, and hopefully I can have a working product out soon. Again, I appreciate your input. :)
Using the same method to control pages (files) in a website is not necessarily a bad thing. Just as a CSS file can save hundreds of changes, so can include files. Dreamweaver templates deserve to die a horrible death - you're better off with proper php includes. E.g. a navigation system placed in its own include file can save a LOT of time when it comes to debugging/changes.
That's my main reason for wanting to make it all PHP. The Dreamweaver templates cause annoying problems, especially when I sometimes edit outside dreamweaver. Having a similar modularized system without the nasty effects would be the biggest benefit I can see.
If you're importing CSV files, perhaps getting to grips with MySQL would be beneficial. You just upload the CSV, let php do some processing on it - or even load it directly into MySQL. The MySQL data output will always be under control via php-generated html.
MySQL is the next step in the plan. I went with CSV at first because my supervisor (who updates the tables) is comfortable with spreadsheets, I already had some code for handling CSV files, and I wanted to get something out quickly. I managed to get a system in place within a week. I'd like to convert the backend to MySQL but keep CSV as the method for updating, for my supervisor's use. It doesn't sound too hard to do.
Personally, I'm not a big fan of CMSes as they tend to be …
I've considered that as well. Our web host has support for several CMSs, including Drupal and Joomla, built-in. I've used Joomla before, and I'm not much a fan. I'd be interested in learning Drupal, though. It seems quite powerful, but it may be overkill for what I'm planning to do. I'm looking into it, though.
Last summer I took a job working on a small company's website. At first I just added some pages they wanted, but by the end of the summer, I rebuilt it from the ground up. The original version looked like something from the nineties, complete with scrolling text and a table-based layout. The new version was made using valid strict XHTML and CSS.
The website has sixteen main pages, and all but four of them are fairly static. The non-static pages are updated in diverse ways. One contains links to PDF files that are overwritten with new information. Another is a table that my supervisor (who has very little web tech experience) updated manually by editing the XHTML file. Another is updated in a similar manner, and the last is a regular XHMTL page that is updated by just adding new divs. The last two hadn't been updated since last summer when I returned to the job last month.
To remedy the painful updating (on my supervisor's part), I started dabbling in PHP, and now I have a system to update the two table-based pages by uploading a CSV file to the server. I'm handling the other two pages a little differently, but the concept is the same. I'd like to eventually get a database backend and an AJAX frontend to make updating even easier and less error prone. In any case, I now have two PHP-driven pages, and two more will be up soon.
I've been …
<?xml version="1.0" encoding="UTF-8" ?>
<press_releases>
<press_release>
<headline>This Is a Headline</headline>
<date>7/4/76</date>
<image src="image.png" align="right" />
<body>
<paragraph>
Lorem ipsum " Latin Latin Latin "
</paragraph>
<paragraph>
pi sigma epsilon omega Greek Math Physics
</paragraph>
</body>
</press_release>
</press_releases>
I'm using PHP's event-driven parser to build a PressRelease object from the XML. It has fields for a headline, date, image source, image alignment, and body text. The body is actually an array of Strings, each representing a paragraph in the xml.
The problem is that the cdata handler fires for text up to an entity, it fires for the entity, and it fires again for text after the entity. I would rather it fire only once for such a sequence, but I would be happy if I could handle the entity separately from the cdata.
My parser worked by keeping track of the current element and performing differently when text is found. For instance, if headline is the current element, it would set $currPressRelease->headline to $text when the cdata handler is called. If there's an entity in the text, a problem arises: take the string "Lorem Ipsum " Latin Ipsum". First, headline is set to "Lorem Ipsum"; then it's set to "\""; then it's set to "Latin Ipsum," and the end result is "Latin Ipsum" when it should be the entire string.
I worked around this by simply appending $text to $headline (or whichever field is encountered) when cdata is fired, but it gets messier for more complex fields …
Yep. For instance, I recently wrote a PHP program to dynamically display tables using data read from a CSV file (a friend actually wrote a large part of the program, which I modified to suit my needs). CodeIgniter has its own Table class that provides most of this functionality out of the box. If I had been using CodeIgniter, I wouldn't have needed to write my own classes. I'd just use what's already there.
How it differs from XAMPP, WAMP, LAMP?
Those aren't really frameworks; they're software packages that install Apache, PHP, and MySQL together more easily than installing them separately (I've followed both methods, but installing XAMPP was like eating cake compared to installing each separately). A framework, on the other hand, more closely resembles an API. It's a set of prewritten code designed for a particular purpose, to speed development.
I haven't used a framework yet, but the web programming class I'm taking next fall is supposed to teach CodeIgniter.
Is there a way to handle standard XML entities with the event-driven XML parser in PHP? I'm currently using an XML file to build a collection of objects and display a page based on those objects. I'd like my CData handler to handle text that includes standard entities, but as it stands, it handles the text on either side of an entity separately. I could compensate for this if I could define an event handler for when a standard entity is encountered, but so far, my research hasn't turned up a way. I've checked the PHP manual, the book Programming PHP (second edition), and various online tutorials with no luck.
I am the web developer for a fair-sized company, and they have tasked me with finding a new web host for their store. Their previous host was ValueWeb; they have proven unreliable. I've done web development before, but I've never set up an eCommerce solution. I'm a little nervous given that the online store is a large source of income for the company. I am, in a way, responsible for large sums of money in this transition.
I'm doing research to determine the best solution to our hosting problem. Our previous host handled eCommerce in a fairly abstract way--most of the technical stuff was hidden in awkward control panels. I'd prefer more low-level access that's still user friendly. I'm only somewhat familiar with PHP, but my programming background should allow me to learn quickly, if I need. The same is true of MySQL and similar technologies--I've worked with databases, just not MySQL specifically.
Honestly, though, I'm just not sure where to start. Should my eCommerce solution be separate from the general web hosting? Should I try building something myself? What do I need to know? Any help would be appreciated. I've been poking around Google and a few IT sites, but a little guidance will go a long way in focusing my research.
Thank you for replying.
I asked this question on another website, and it's working now. I had to change the field tblParts.name to tblParts.partID because name is a reserved word in Access. Current works appropriately when I use Me.partID instead of Me.Recordset.Fields("partID").Value. The reason for this phenomenon is that Me.[field name] always matches the current record, but DAO's Recordset behavior is not clearly defined for the Current event. That's what I was told, at least.
I'm working with Access 2000. I have a form with data from a table, tblParts, and a list box with data from another table, tblRDM_Numbers. The two tables have a one-many relationship with tblParts.name as a foreign key for tblRDM_Numbers. I would like the list box to update every time the Form's record moves. The sub I wrote looks like this:
Public Sub populateRDM()
Dim strSQL As String
Dim strPart As String
strPart = Me.Recordset.Fields("name").Value
strSQL = "SELECT tblRDM_Numbers.part, tblRDM_Numbers.RDM_No " _
& "FROM tblRDM_Numbers " _
& "WHERE tblRDM_Numbers.part = '" & strPart & "';"
Me!lstRDM.RowSource = strSQL
End Sub
It works fine when I call it almost anywhere except Form_Current(). When Form_Current() calls populateRDM(), it strPart is assigned Me.RecordSet.Fields("name").Value before the record changes. Then, the record changes, and the list box contains information for the record before the change.
For example, I have three parts, Battery, Capacitor, and Resistor. I load the form, and Battery's information is displayed. The RDM numbers in the list box are those for battery. Then I move to the next record. The information for Capacitor is displayed, but the list box contains Battery's RDM numbers. I move to the next record, Resistor, but Capacitor's RDM numbers are displayed. I move back to Capacitor, but Resistor's RDM numbers are shown in the list. Etc.
Is there a way to call populateRDM() after the record moves, instead of before? It would be lovely if VBA had BeforeCurrent and AfterCurrent events, …
I am currently developing an Access 2000 database for the purchasing department at work, and I'm learning as I go. The tables are all set up. I'm trying to create forms to update the tables, but I've run into a few problems.
A simple example is the Parts table. It contains information about parts the department orders for technicians, including an ID, description, quality assurance person, etc. It's related to a separate table of OEM numbers (because we buy the same parts from multiple manufacturers, a part can have multiple OEM numbers) and a similar table of in-house ID numbers.
I would like to create a form that creates a record for the Parts table and related records in the OEM and RDM Number tables. I've tried using queries and forms in various ways, but I haven't yet discerned an answer. I also know a little VBA, but I don't know much about the Access-specific objects.
The idea I had was to bind the form to a query that takes info from the Parts, OEM_No, and RDM_No tables. This allows me to view the information I need but not update it. Then I would add a command button and modify the textbox controls in VBA to update all the tables. I'm still playing with this, but like the other methods, I keep running into dead ends.
I've had difficulties finding good documentation on Access. Most resources are for later versions or are too simplistic for my …
My knowledge of Java only extends as far as the book I'm using has explained, and the only thing it has said of the "extends" keyword so far is that the new class inherits the traits of the JApplet class. It explains inheritance in more detail two chapters later, but I haven't read that far yet (although I did skim that section for answers). I did look at the API doc for the JApplet and Container classes, though. I just didn't understand it well. I'm supposing that I need to learn more about inheritance to fully grasp this?
The Java book I'm using (Java Programming by Joyce Farrel, Thompson Course Technology), when explaining how to add components to an applet, uses the following code:
import javax.swing.*;
import java.awt.*;
public class JHello extends JApplet
{
Container con = getContentPane();
JLabel greeting = new JLabel("Hello. Who are you?");
public void init()
{
con.add(greeting);
}
}
However, it doesn't explain how a Container object can be created without using the keyword new and its constructor. I've looked in three books, several websites, and asked someone for an answer, but I haven't gotten one so far. It's really not impeding my progress through the book; I'm just curious about this.
For the purpose of this paper, I'm doing so broadly, essentially to anyone who works on software (not just with software). This doesn't include computer repair and maintenance, website design, and other jobs that don't need a fundamental understanding of how computer software works, but it does include both work in both application and theory.
Hello again, everyone. I apologize for my delay, but the teacher waited until just recently to give us the interview guidelines, despite my persistent requests. Anyone who would like feel free to answer the questions, but to directly cite your responses in my paper I will require your name, the name of the company you work for, and the state in which you live. These are the questions:
1. What training or education does a career in computer science require?
2. Are you in a particular branch of computer science? If so, what additional special training did it require?
3. What natural abilities or interests are needed for a career in computer science?
4. Is there good job availability for those who choose computer science?
5. Would you rate the opportunities for advancement as poor, fair, good, or excellent? Why?
6. Could you list a particular advantage of being in computer science? A particular disadvantage?
7. Do you have any special advice for someone interested in computer science, such as college courses to take or things to study? I plan to attend Appalachian State University, so any special advice for a student there would be appreciated.
8. Are there any current problems faced by most computer scientists?
9. Why did you choose computer science as your profession?
Thank you for your interest. The final project will be a 1000 to 1500 word paper on computer science careers, and it require a total of ten sources: four books, four non-book resources, and two interviews. I already have one interview lined up and most of the other sources. My teacher has some specific interview questions she wants us to ask, but she hasn't given them to us yet. It'll probably be a couple more weeks before she does, so I won't be able to do the interview until then.
This one's fairly well-known, as I've heard it from several sources, but I still enjoy it:
If Operating Systems Owned Airlines
UNIX Airways
Everyone brings one piece of the plane along when they come to the airport. They all go out on the runway and put the plane together piece by piece, arguing non-stop about what kind of plane they are supposed to be building.
Air DOS
Everybody pushes the airplane until it glides, then they jump on and let the plane coast until it hits the ground again. Then they push again, jump on again, and so on...
Mac Airlines
All the stewards, captains, baggage handlers, and ticket agents look and act exactly the same. Every time you ask questions about details, you are gently but firmly told that you don't need to know, don't want to know, and everything will be done for you without your ever having to know, so just shut up.
Windows Air
The terminal is pretty and colorful, with friendly stewards, easy baggage check and boarding, and a smooth take-off. After about 10 minutes in the air, the plane explodes with no warning whatsoever.
Windows NT Air
Just like Windows Air, but costs more, uses much bigger planes and takes out all the other aircraft within a 40-mile radius when it explodes.
Linux Air
Disgruntled employees of all the other OS airlines decide to start their own airline. They build the …
In my Senior English class, we were assigned a research paper based on our prospective vocation, and for it I chose Computer Science, specifically software engineering. One of the requirements of the project is that I have two interviews as sources, but I don't personally know anyone who works in that field. I know plenty of technicians and IT guys, but no one who does any programming. Would anyone here be willing to be interviewed and cited as a source in my paper? We can do it here in the forums, but I may need your full name (I'll have to check with my teacher to be sure), which you could provide privately if you prefer.
Welcome! I really enjoyed The Lord of the Rings, The Hobbit, Timeline, Prey, and Sphere. Have you read any of Michael Crichton's books?
I have indeed. In addition to the ones I listed, I've read Rising Sun, Disclosure, The Lost World, State of Fear, and Next. I've also seen The Andromeda Strain and The 13th Warrior, but not read the books they're based on. After I finish The Lion, the Witch, and the Wardrobe, I'll probably read either Congo or Eaters of the Dead.
Thanks for the warm welcomes, everyone! :)
Hello, everyone. I stumbled across this website while doing research for an English paper on the computer industry, and it looked like a nice place to I decided to sign up. I'm no newbie to forums (I've been a member of several and even moderated one), but I'm still fairly inexperienced with computers in general. I hope to learn a lot here. I found this template in a floated thread, so I'll use it for my intro:
Name: Allen, but I generally go by Mongooseman online
Nickname: Mongoose, 'Goose, MM
Height: 5'2" (approximate)
Weight: 210 (approximate)
Hair: Brown
Eyes: Brown
Location: NC
Age: 17 (soon 18)
Hobbies: Video games, reading, TV and movies, anime and manga, spending time with family and friends, and education.
Relationship Status: single
Fav Music: Classical/Orchestrated type stuff, movie/video game soundtracks, and Gospel/Bluegrass
Education: Currently a high school senior; I plan to get a BS in Computer Science after I graduate, and perhaps a MS as well.
Work: During the summer I work in the inventory department of an industrial electronics repair/remanufacture plant
Favorite Food: Mexican and Japanese food by far, but also pizza and cheeseburgers.
Favorite Movies: Original Star Wars Trilogy, The Lord of the Rings Trilogy, To Kill a Mockingbird... and I'm not a huge movie enthusiast.
Favorite TV Shows: Heroes, The 4400, and Monk.
Favorite Video Games: Zelda A Link to the Past, Link's Awakening, and …