-
Posts
14,780 -
Joined
-
Last visited
-
Days Won
43
Everything posted by .josh
-
Can't account for spaces in my database when echoing out data?
.josh replied to mcc_22ri's topic in PHP Coding Help
The way I understand it, you have in your database "las vegas" and you want to be able to put into the address bar ../las-vegas and treat the city as "las vegas" right? Assuming your mod rewrite is working correctly and it is putting it into that u url param...this will allow you to do ../las-vegas or ../las%20vegas <?php include('init.php'); // connection to database // if city exists... if (isset($_GET['u'])) { // decode and replace hyphen with space $city = str_replace('-',' ',urldecode($_GET['u'])); // if value contains only letters, numbers or spaces... if ( preg_match('~^[a-z0-9 ]+$~i',$city) ) { // select data from database... $data = mysql_query("SELECT State, City FROM cars WHERE City='$city'" ); if (mysql_num_rows($data) > 0) { while ($row = mysql_fetch_assoc($data)) { echo $row["City"]; } } } } ?> -
Warning: unlink(img.jpg) [function.unlink]: No such file or directory
.josh replied to gilestodd's topic in PHP Coding Help
if ( is_file("img/albumOne/".$_POST['fileToDelete']) ) { unlink("img/albumOne/".$_POST['fileToDelete']); } -
looking at the syntax helps, but is not good enough. So you spelled it right...so what? Do you actually have a database on your server, did you check that? Do you have error reporting turned on? Are you checking the results of your query? You can't just eyeball!
-
so at the very top of your script, outside of all conditions, if you put the following: echo "<pre>"; print_r($_POST); echo "</pre>"; You see the data you submitted? If yes...okay, where in your script do you actually connect to your database? I see a whole lot of database queries happening... do you actually connect to/select your database somewhere? Did you test your queries to see if they are returning what they are supposed to be returning, or if they are throwing an error? (turn error reporting on by adding error_reporting(-1); to top of script or echo mysql_error after each query). [/code]
-
where are you defining existing_username() and valid_match() ? Also, I *assume* that valid_match and existing_username() both perform db queries...and then you have yet another query to get and assign user id to a session var...why not do a single query?
-
Warning: unlink(img.jpg) [function.unlink]: No such file or directory
.josh replied to gilestodd's topic in PHP Coding Help
wrap your unlick in a is_file condition. -
Yeah I will be the first to say that I don't know as much as I would like, but even then I am still learning because my profession forces me to expand my knowledge and understand of development. Like many other professions, things are constantly growing and changing, so a huge part of your profession is constantly researching and learning new things, keeping up with the technology and concepts behind things. So I by no means consider myself an expert at things either...but I've been around the block a few times, I've picked up a few tidbits of wisdom here and there... One thing I have learned over the years is that what looks good on paper is usually never applied in real life, because its just not feasible. Too much red tape to cut through, hoops to jump, etc... even if for the sake of argument we accept that OOP is some kind of end-all-be-all perfection and everything else is crap, that doesn't mean a damn thing when you have a boss that tells you you have exactly n amount of time to do xyz and no you cannot change a b c or d. You work with what you have. So what is the perfect paradigm? The one that gets the job done under the circumstances you are in. OP is just another inexperienced coder who found a shiny toy and is bragging about it. Give him enough time and experience in the real working world, he will see that the on-paper universe is not the same as real life, that even "In a perfect world, this would be true" .. even this statement is bupkis.
-
hmm how long is your captcha val? looks like you get that error if the length is less than 6, so it's got to be at least 7 chars long. change this: if(ele.val().length < 6) { to this: console.log(ele); console.log(ele.val().length); if(ele.val().length < 6) { then look in your console log (or change console.log(...) alert(...) if you have no idea what i'm talking about). What are you seeing?
-
I've been coding for ~28 years now, ever since I was just knee-high to a grasshopper. My profession involves coding. Glad to know despite all that, I'm still an amateur. But hey maybe one day I'll make it to the big boys' table.
-
Can you track what file a database insert came from?
.josh replied to xwishmasterx's topic in PHP Coding Help
and if it's on windows, just navigate to your base dir in the normal windows file explorer and search for "insert before" and it will list files that contain it. -
Can you track what file a database insert came from?
.josh replied to xwishmasterx's topic in PHP Coding Help
what kind of system/server is your script on? If it's on *nix and you have command line access, you can do grep -r "insert into" basedirofscriptshere and it will return files and lines that "insert into" appears, will help you narrow it down. -
no clue. The people I personally know who live in singapore, I know them from a different context. If they happen to have an account here and are active, I wouldn't know. I doubt it though, as they aren't coders.
-
Can't account for spaces in my database when echoing out data?
.josh replied to mcc_22ri's topic in PHP Coding Help
where are you echoing it? are you echoing it inside this condition: if (ctype_alnum($city)) { ? Did you see my post about that condition? -
I don't, but I know people who do.
-
Can't account for spaces in my database when echoing out data?
.josh replied to mcc_22ri's topic in PHP Coding Help
oh and another thing I noticed... you wrap your query in a if (ctype_alnum($city)) {...} condition. Well spaces and hyphens will cause that condition to fail, no query made. -
Can't account for spaces in my database when echoing out data?
.josh replied to mcc_22ri's topic in PHP Coding Help
Well I know echoing it out wouldn't change anything... I was sort of asking you to post what it output so that we can see it, since we don't have access to your site to see for ourselves... -
Can't account for spaces in my database when echoing out data?
.josh replied to mcc_22ri's topic in PHP Coding Help
echo "<pre>"; echo $_GET['u']; echo "</pre>"; What does that output for 2-word values? -
LoL yeah Phil pointed that out to me, so I'll give him that. But yeah regardless, unhealthy obsession w/ OOP for sure... I mean I like seeing when someone first discovers something and it first clicks with them. The excitement and joy and all that jazz is kind of cute, but when it starts turning into "..and all else is shit" ... yeah, calm down sparky...
-
Can't really see what's wrong, from the code you provided. Most likely the issue is server-side. Captcha is usually done by outputting the image, but also with a session variable that keeps track of the generated captcha code/phrase. Then when the form is submitted, your server-side code compares the submitted captcha code/phrase to the session variable. You said that you are able to enter in the captcha code/phrase, so I assume that you are seeing random captcha image outputting. Did you verify that your reguser.php is receiving your inputted captcha code/phrase (do you see it in the post request? are you using the correct $_POST['captcha_code'] variable?) What is your reguser.php script comparing the posted value to? As mentioned, it would usually be a session variable something like $_SESSION['captcha_code'] . Did you echo it out to verify that it is what it is supposed to be?
-
Wow man...you started a whole new thread to be told the exact same thing you were told from your other thread. What part of "no" don't you understand? You're just an OOP fanboy and that's fine, but not at the expense of calling all else amateur, noob, etc.. because then you just come off as a pretentious douchebag. Also, it shows your noobness. I sorta feel sorry for you.. I bet when the next big paradigm comes along, either your heart is going to break, or you'll jump on that bandwagon and try to say the same things about OOP as you are saying about Procedural, not having learned a damn thing. edit: there I even added a poll, maybe that will help you, since it's more visual.
-
How do I display select content in an unordered list?
.josh replied to wait's topic in PHP Coding Help
no problem! -
How do I display select content in an unordered list?
.josh replied to wait's topic in PHP Coding Help
From your PM, it sounds like there is no pattern to the links per-se; instead you need to be able to output arbitrary links. Here is adjusted code for being able to specify arbitrary links: $list = array( 'cars' => array( 'Car 1' => 'path/to/cars1.php', 'Car 2' => 'path/to/cars2.php', 'Car 3' => 'path/to/cars3.php', ), 'trucks' => array( 'Truck 1' => 'path/to/trucks1.php', 'Truck 2' => 'path/to/trucks2.php', 'Truck 3' => 'path/to/trucks3.php', ), 'motorcycles' => array( 'Motorcyle 1' => 'path/to/motorcycle1.php', 'Motorcyle 2' => 'path/to/motorcycle2.php', 'Motorcyle 3' => 'path/to/motorcycle3.php', ) ); ?> <div id="left-nav"> <?php if ( isset($leftnav)&&isset($list[$leftnav]) ) { ?> <ul> <li><h3><?php echo ucfirst($leftnav) ?></h3></li> <?php foreach ($list[$leftnav] as $label => $link) { ?> <li><a href="<?php echo $dots($link); ?>"><?php echo $label ?></a></li> <?php } ?> </ul> <?php } ?> </div> -
php doesn't let you perform multiple queries. I think the least amount of work you can do will involve using exec or system and run a mysql import via command line. But if that's not an option, you're going to have to parse .sql to grab each sql query individually..which sounds like you tried to do but didn't parse it correctly. It may be easier for you to separate exports, one for structure and one for data, and export the data as csv. That might make it easier for you to read the data line by line and insert, using fgetcsv
-
you should be selecting the level by user name or id or whatever you have that uniquely identifies the user. ..where user_name='$username' ..where user_id='$userid' or however you have it setup.
-
How do I display select content in an unordered list?
.josh replied to wait's topic in PHP Coding Help
okay, well there you have it then. I did use dots(...) instead of $dots(...) (no $) so you'll have to change that.