KevinM1
Moderators-
Posts
5,222 -
Joined
-
Last visited
-
Days Won
26
Everything posted by KevinM1
-
This will probably be a long post, so feel free to go the tldr; route. Like I said in the 'Get to know your fellow coder' thread, I was born physically disabled. I use an electric wheelchair for mobility. Obviously, with the limitations imposed on me because of my disability, any employment I could possibly obtain would have to be something far more mental than physical. Going into some computer-related field seemed to be the obvious choice, as I've been using some form of computer since I was 3 or 4 years old. I still remember playing those crappy edutainment games on my family's VIC-20 in the living room. Those games helped me to learn reading and math at an early age. I actually went into college to get my computer science degree. Unfortunately, I learned the hard way that there's a big difference between knowing how to use a computer, and knowing how to successfully program one. I did all right in my intro C++ classes, but everything quickly came screeching to a halt when I got to the assembly/low-level C programming class. I took that class twice, and failed both times. Deciding to not waste what college I had already completed, I decided to get a quick and simple liberal arts degree and take the one and only course on web development my college offered, which was basically a survey of website development course. We spent about a week on each topic -- XHTML, JavaScript, DHTML, Perl, and, honestly, that's about it. I graduated in the winter of 2004 with my bachelors in communication, and two minors -- one for music, one for computer information and technology. While in the latter days of my college career, I noticed that my friend -- who also failed out of computer science, only to move on and get a degree in anthropology -- was doing some freelance scripting while we were hanging out in the Student Environmental Action Coallition/Peace & Justice League office (damn hippie ). I was fascinated, as the scripting language he was using allowed him to get his chocolate in my peanut butter, and my peanut butter in his chocolate...err, I mean, it allowed him to switch from script to markup and back again (the food joke is me trying to parody a TV ad that airs here in the States). He told me that it was PHP, and I decided to start learning it. This was back in 2002 or so. Unfortunately, I didn't have the time to start learning PHP until after I graduated. Papers, assignments, and a stupid plant biology class took up most of my time at that point. So, I've been learning PHP off and on since 2005. I've really only put it to good use since last November, as that's when I got my part-time job. I also fell behind a bit by falling into the same trap that businessman and bills_money fell into -- there were so many technologies I wanted to learn (PHP, MySQL, JavaScript, AJAX, ASP, etc) that I burnt myself out. In trying to learn everything at once, I really learned nothing at all. I'm pretty good procedurally. OOP still eludes me, on a tangible level. I understand (and agree with) its underlying philosophy, but transforming examples in a book into a real system still baffles me. But I'm sticking with it. I still tend to lose the forest for the trees every so often. I'm comfortable doing traditional form/database stuff, but freeze a bit when it comes to building a calendar or pagination. I'm not good at coming up with my own algorithms for those kinds of things. Hopefully that'll come with time and experience. So, yeah. There I am, in text form.
-
You're not thinking this through. The age of consent isn't just some arbitrary number that some old, stuffy people picked just for fun. Generally speaking, the age of consent is the age at which society feels young people can make reasonably informed decisions about their own health (assuming you live in a country that's not ruled by religious dogma). It is arrived at after much debate and discourse. And, like most things involving the law, the age of consent can be changed (lowered) if the people feel it needs to be changed. There is wisdom to be found in the "You'll understand when you're older" truism. People don't say it because they're brainwashed, they say it because they've gained enough life experience to realize that they most likely made some poor decisions as a teenager, some of which may have had long lasting effects (teen pregnancy, for one, to say nothing of diseases). This isn't about older people trying to stop teens from having fun, which seems to be what you're implying. Rather, it's about older people trying to enforce some boundaries as, inevitably, some older people will attempt to exploit the young. Teens are vulnerable because they think they can make rational, informed decisions on matters of this level of importance. Unfortunately, most cannot. Instead, they succumb to the pressures of teen life. I've seen it myself -- a 14 year old girl 'dating' a 21+ year old guy, because he drives, can get her alcohol, and generally makes her look cool in the eyes of her peers ("OMG, she's dating a college guy!"). She convinces herself that he really does care for her, but in reality he's just with her for the cheap, easy thrill. This scenario played itself out a lot when I was in high school. Consent laws are made, in part, to protect naive teens and children from the scumbags who would exploit them. Is this all patronizing? Perhaps. But, in the long run, having consent laws is beneficial to society as a whole. RE: locking this thread -- freedom of speech doesn't apply in this case. The PHP Freaks can do what they wish with whatever messages you write as it's their message board. It's something you're going to have to get used to, as most businesses don't exercise complete freedom of speech either.
-
Can't believe I didn't see that... I thought my example had quotes. Yours did, but one in my thread in the Application Design subforum didn't. Because of that, I thought they were optional. It's funny...using the correct syntax fixes a lot of problems!
-
Okay, it's now working. Apparently, in JSON, you need quotes around the name of the property you're trying to set. D'oh!
-
Here's a more important question: why use $row_count at all? You're already using mysql_num_rows(). Why not just go: <?php $query = "SELECT * FROM listings WHERE category = '{$_GET['id']}'"; $result = mysql_query($query); $numrows = mysql_num_rows($result); if($numrows){ while($row = mysql_fetch_assoc($result)){ $id = $row['id']; $lines = stripslashes($row['lines']); $markets = stripslashes($row['markets']); $opportunity = stripslashes($row['opportunity']); $listings .= '<div id="list"><table width="100%"><tr><td class="listID"><a href="NEED_LINK?id='.$id.'">Listing ID: '.$id.'[/url]</td></tr><tr><td class="listLine">Product Lines: '.$lines.'</td></tr><tr><td class="listLine">Target Markets: '.$markets.'</td></tr><tr><td class="listLine">Sales Opportunity: '.$opportunity.'</td></tr></table></div>'; } } else{ $listings = '<div>Sorry, no listings under '.$category.' matchining your criteria were found.</div>'; } ?>
-
Do you define $row_count anywhere? You should set it to 0 before your for-loop.
-
Yeah, that's the thing that's getting me, though. The array indexes are equal to the value that the select element currently has. So, if I select welcome message, the array index should be 1. In terms of putting them into a hash, there's still some confusion. I'm thinking of a hash as unique key => value. That's why I considered my array setup a hash. Even though the keys were numeric, they were unique and bound to the greater context of the form. With that said, I'm having a hard time visualizing how to hash my hash, so to speak. Are you suggesting that I make a separate hash for the ids? Something like: var hash = new Array(); hash['Welcome'] = 1; hash['Approved'] = 2; . . . Or am I completely misreading you?
-
I'm lost. I quite literally have no idea what you're saying here. I'm thinking the uid would be the value I'm currently using for my array indexes, but I'm not sure what you're trying to tell me in terms of what to do with them. Sorry.
-
Well, I'm much closer than I was before. I've changed the JS inside my PHP file to: <?php $configQuery = "SELECT * FROM sbclassified_mails WHERE id != 4 ORDER BY id ASC"; $configResult = mysql_query($configQuery); ?><script type="text/javascript"> var mailSettings = new Array(); <?php while($row = mysql_fetch_assoc($configResult)){ ?> mailSettings[<?php echo $row['mailid'];?>] = {from : '<?php echo $row['fromid']?>', subject : '<?php echo $row['subject']?>', mail : '<?php echo $row['mail']?>'}; <?php } //end while-loop ?> </script> The mail values in the JSON work now because I fixed my input validation/escaping. So, I'm left with JSON objects like: var mailSettings = new Array(); mailSettings[1] = {from : 'webmaster@rextrader.com', subject : 'Welcome to RexTrader.com', mail : 'Hi <fname> <lname>,\nWelcome to RexTrader.com.\nYour registration information is as follows:\n\nUsername:\t<username>\nPassword:\t<password>\nEmail:\t\t<email>\n\nThanks for being part of our website.\n\nRegards,\nAdmin\nFor login click <loginurl>'}; I kept the objects in an array because that seems to be the easiest way for me to get to them with my external file. That being said, I can't seem to get a handle on the objects within that file. I've tried an alert box, but I get undefined values. Specifically, this code: alert('Array values -- Reply address: ' + mailSettings[value].from + ' Mail Subject: ' + mailSettings[value].subject); Returns: The 'value' variable comes from a select element, which lets the user choose which e-mail to view/edit. So, the question remains: how can I get into the heart of my JSON objects? I'll post all of my external file and my PHP script, if you wish.
-
Hmm...maybe I should use some JSON. I'll try it next. I think I know how to solve that as well. Hopefully my next response will be a big, green 'Solved' checkmark.
-
My problem is a bit involved, so this will be a pretty long post. It stems from my thread in the 'Application/Design Layout' subforum (http://www.phpfreaks.com/forums/index.php/topic,163951.0.html), so those interested in helping me should probably read through that first to get the background info. I'm trying to set some preliminary values in my form-switching JavaScript. So, in order to do that, I've hard-coded some JS in my PHP script: <?php $configQuery = "SELECT * FROM sbclassified_mails ORDER BY id ASC"; $configResult = mysql_query($configQuery); ?><script type="text/javascript"> var mailSettings = new Array(); <?php while($row = mysql_fetch_assoc($configResult)){ ?> mailSettings[<?php echo $row['mailid'];?>] = new Array('<?php echo $row['fromid'];?>', '<?php echo $row['subject'];?>', '<?php echo nl2br($row['mail']);?>'); <?php } //end while-loop ?> </script> As you can see, I'm trying to store the mail settings that were saved in the database in a two-dimensional hash (the index of the mailSettings array, while numeric, isn't sequential -- it's a long story). My problem is that I'm getting an unterminated string literal with the $row['mail'] values. I'm thinking that this error is stemming from the length of those values -- I'm trying to store a fairly large chunk of text in there, and they have linebreaks and tabs (although I tried combating against that with PHP's nl2br function). I've double-checked my quotes, and I can't see a problem there. Here's what the source code shows: <script type="text/javascript"> var mailSettings = new Array(); mailSettings[1] = new Array('webmaster@rextrader.com', 'Welcome to RexTrader.com', 'Hi <fname> <lname>,<br /> Welcome to RexTrader.com.<br /> Your registration information is as follows:<br /> <br /> Username: <br /> Password: <br /> Email: <br /> <br /> Thanks for being part of our website.<br /> <br /> Regards,<br /> Admin<br /> For login click <loginurl>'); . . . </script> Any ideas? Thanks in advance!
-
I'm trying to install PHP onto a Windows XP Pro laptop, but it's been giving me issues. What I've done so far: 1. Installed IIS from my Windows XP Pro CD 2. Downloaded the 5.2.4 installer from PHP.net 3. Ran the installer, with the 'No web server' option 4. Changed the cgi.force_redirect setting to 0 in the php.ini file I tried setting the environment variables/paths, but it appears as though the installer automatically configured that for me. I'm now at the step where PHP.net says that: But I don't know how to change those user permissions. All I do know is that I cannot view a simple PHP test file on localhost yet. Please help.
-
Sweet, thanks!
-
Is there a quick, easy way to reverse what htmlentities() does? I've searched the online manual for a built-in function, and so far haven't found one.
-
That's not a problen of GET, it's a problem with the logic you used to build your script. GET, for the very reason you stated, is potentially dangerous because users can change its value in the URL. Since PHP is often used in conjunction with a database, these changes of input could lead to a user (intentionally or not) hijacking your database. Because of that, you need to validate that what you're GETting is legit, and turn away all other invalid inputs. In your example, it seems that you only want to accept a carInfo value of 1. So, you'd do something along the lines of: <?php $carInfo = $_GET['carInfo']; if(is_numeric($carInfo) && carInfo == 1){ //access the database and proceed as normal } else{ //bad input, turn away user header('denied.php'); //access denied site } ?>
-
I use Notepad++ on Windows, GEdit on Ubuntu.
-
I'm really picky when it comes to music. I actually annoy my friends and family with my musical tastes and habbits. Let me start off by saying I enjoy silence. I'm typically surrounded by people for the vast majority of the day, mostly due to my physical disability. So, to me, silence is a much needed retreat from just having to deal with people. I'm not someone who needs background noise because they feel uncomfortable in silence. When I listen to music, I tend to be an active listener. I don't find much point to turning on an album, only to talk over it, or not really pay attention to it. That misses the point, IMO. I find that I can't identify with a lot of popular music. I can't stand country music, and most rap, hip-hop, and r&b sound the same to me. Even most rock bands bore me now. I think my apathy stems from the signal-to-noise ratio. Most of what I've heard in my life is that annoying, play-it-safe-to-sell-albums crap that the radio serves most of the time. I get accused of not having an open mind, but I don't think that's the case. I've definitely been exposed to many genres of music, and many artists within those genres, it's just that the vast majority of it, at the very least, tends to bore the crap out of me. My favorite band, at the moment, is probably Tool, even though they are quickly becoming formulaic. I'm anxiously awaiting Maynard's Puscifer album, as the clips I've heard sound a bit different from his Tool and A Perfect Circle faire. I like Pink Floyd. I like early Live, before they decided to become a completely spineless adult contemporary group. I like(d) Stabbing Westward, sans their self-titled album. I like NIN. I liked Rammstein's first two albums. I liked the Dave Matthews Band until the album after "Before These Crowded Streets." That's all I can think of at the moment.
-
I prefer tableless layouts for two main reasons: 1. Readable code, as you don't have to deal with nested tables. 2. Less code overall, which ties into reason #1. Like others have said, tables are great for tabular data. I use tables for just that. But for page layout, they are beyond clunky to use. Why deal with all of the extra hurdles -- table rows, table cells, cells that span multiple rows or columns -- when you can just throw a div in the correct space? No tables also makes code far easier to maintain. I don't have to dig through layers of nested tables to edit the right code. I just find the right div (which is easier to do as they don't come with the <tr>, <td> baggage that tables have). Yes, div's can be nested. But I prefer dealing with them rather than tables, nested or not. It just makes sense to go with, IMO, the easier, more efficient route. I have (and am currently) rewritten sites that used table-based layouts. In every case, the new code is much easier to read, easy to edit/maintain, and the overall length of the code is anywhere between 35% - 50% less than the original. Sounds like win to me. But, to each their own. No one's saying you have to abandon tables. It's just that a lot of serious developers have because of the myriad benefits a tableless layout provides.
-
[SOLVED] Using PHP to rewrite bits of a JavaScript file
KevinM1 replied to KevinM1's topic in Application Design
I haven't played with JSON yet. From what I've seen, it's basically just property:value pairs, correct? In any event, it's nice to learn that internal and external JavaScript can interact with each other. -
[SOLVED] New to PHP.. Where am I going wrong here?
KevinM1 replied to ManOnScooter's topic in PHP Coding Help
You don't need the while-loop if you're sure that you only want to get one row back from the database. My version of this would be: <?php $dbCon = mysql_connect("localhost", "root", "administrator") OR die("Could not connect:" . mysql_error(()); mysql_select_db("test", $dbCon) OR die("Could not select correct table!"); $query = "SELECT details FROM test WHERE first_name = 'scooter'"); $result = mysql_query($query); if($result){ $row = mysql_fetch_assoc($result); $details = htmlentities($row['details']); } else{ $details = "No details found"; } ?> <html> <body> <table> <tr> <th>Details:</th> </tr> <tr> <td><input type="text" name="q" size="16" value="<?php echo $details;?>" /></td> </tr> </table> </body> </html> -
[SOLVED] PHP session and header redirect problem... HMMmmm
KevinM1 replied to bri0987's topic in PHP Coding Help
I tend to use it as a failsafe, only. I always go the validate/process input --> output (if necessary) route. -
[SOLVED] New to PHP.. Where am I going wrong here?
KevinM1 replied to ManOnScooter's topic in PHP Coding Help
Looks like you forgot a semi colon for the value in our input tag. Try: <input type="text" name="q" size="16" value="<?php echo $row["details"];?>"/> -
[SOLVED] PHP session and header redirect problem... HMMmmm
KevinM1 replied to bri0987's topic in PHP Coding Help
An easy way to work around header problems is to use output buffering. Like premiso said, header errors tend to pop up because something - even whitespace - is output from your script before you make the header call. If you buffer your output, then you really don't have to worry about when your output is sent, as you'll have direct control over it. The easiest way to do it is to merely put ob_start(); as the very first line of code in your script. This initializes the buffer. At the end put ob_end_flush(); which sends everything stored in the buffer to the screen. -
[SOLVED] Using PHP to rewrite bits of a JavaScript file
KevinM1 replied to KevinM1's topic in Application Design
Apologies for the late reply. So, basically you're saying that my external file will be able to read the values I set via PHP in the document head (providing I link to the file after setting those values)? I always get confused on whether or not an external JS file can access variables/values set separately inside a script-tag in HTML. -
Yeah, Tom's a tool. I use MySpace for two reasons: 1. My friends are on it (for some reason) 2. I like being able to put music on my profile with little hassle. I'm currently digging the Santogold song L.E.S Artistes, which I found on NHL 08. Damn you, EA Trax.