-
Posts
14,780 -
Joined
-
Last visited
-
Days Won
43
Everything posted by .josh
-
<img[^>]*> for anything inside an <img....> tag.
-
Yeah typo. Also I didn't see the "not always number prefix part." see edit above
-
$x = explode(" - ",$var); echo $x[0]; edit: oops. didn't see the "not always prefixed with digit" $x = explode("- ",$var); echo $x[0]; or $var = "04 - blahblahblah"; preg_match("/-\s(\w*)/",$var,$match); echo $match[1];
-
rtrim($string,'/'); If it's there, it will remove it.
-
That code will go through the string given and change any number over 20 to 10. This code will match all "x fruit" patterns (number, followed by space, followed by fruit) and replace the number with the max if it's higher than the max. $fruitmax is array of fruit => max $string = "John had 3 apples, 100 Peter had 20 apples, Ralf had 8 apples. Susan had 30 oranges. Rick had 20 oranges"; echo $string."<br/>"; $fruitmax = array('apples' => 10,'oranges' => 20); foreach ($fruitmax as $fruit => $max) { preg_match_all("/(\d+)\s{$fruit}/", $string, $matches); foreach ($matches[1] as $num) { $string = ($num > $max)? str_replace("$num $fruit", "$max $fruit", $string) : $string; } // end foreach match } // end foreach fruit
-
$string = "John had 3 apples, 100 Peter had 20 apples, Ralf had 8 apples."; preg_match_all('/\d+/', $string, $matches); foreach($matches[0] as $num) { $string = ($num > 10)? str_replace($num, 10, $string) : $string; }
-
If the full path of your file is for instance /Library/WebServer/Documents/foo/bar/orders/orders.txt and you do /Library/WebServer/Documents/../orders/orders.txt that's the same as saying /Library/WebServer/Documents/bar/orders/orders.txt which will result in a 404 error or false or whatever, depending on how you're trying to access it.
-
touché
-
Everybody knows the standard is to always capitalize variable letters that correspond to your favorite Playmate's last name. You noob.
-
If you have two tables with a common field like 'date' you would refer to them like so: select tablename.columnname .... You can also assign an alias to it like so: select tablename.columnname as something.... As far as your code is concerned, other than your missing ; for mysql_query, yes, that should work. Also you probably need to capitalize username in your $row['username'], since it's capitalized in the db... edit: however, since you are using rhodesa's join, the results will look something like this: Request User_id Id Username Password blah1 1 1 joe 123 blah2 1 1 joe 123 blah3 1 1 joe 123 etc... If you're just wanting it to return this: Username Request joe blah1 joe blah2 joe blah3 Use something like my query
-
Database normalization is a technique to reduce the amount of duplicate data in a database. Making a relational database (a database structure) is an end result of normalizing a database. In other words, one way to normalize a database is to make a relational database. That is pretty much what you did there. You identified that users can have more than one request, so instead of repeating the same user info in a single table over and over again, where only the request changes, you made two different tables, with a common user id link. As rhodesa pointed out, you can use various JOIN queries to return linked table data. His query will pretty much just dump all info out from both tables. If you are just wanting to show username:request, it would look something like this: select Username, Request from Users, Work, where Users.Id = Work.User_id
-
You can like, use getelementbyid.innerhtml or whatever (javascript) to grab the info between your span tag, and use ajax to send it to the server and then php to receive it and insert it into your db. Or like, use a form.
-
Well we all know CV's just been trying to prove that he does indeed make the longest posts We all strive to be #1 at something...
-
I can understand not being sure about a command or something, and not wanting to mess something up. But that's what sandboxes are for. There's no reason why you need to test new script out on a live site, where if something goes wrong, you're screwed. But anyways, concerning this specific circumstance, I judge from the context of his post, that he knows that selecting stuff from his db is not going to damage things. After all, his question was not about the select.
-
No, it was the "I don't know them, but really, I don't care for other people, they're stupid, I sit and hope for them to die, they aren't worth the space they take up" bit, that tipped me off.
-
well the stars are the standard images that come with smf so blame them.
-
I think someone didn't get enough hugs as a child.
-
Like it matters. highest speed limit in town is 30mph. Most roads are 20mph
-
I live in a town, population around 7,000. Like 85% senior citizens. I can't walk outside without smelling perfume in the air.
-
Well I was mostly just explaining to him what ../ meant so as to give him an idea of how to find the correct path. If /Library/WebServer/Documents/ is the document root, and you're saying that your orders directory is just 'outside' of that, do you mean to say that this /Library/WebServer/orders/orders.txt is the path to the fie?
-
../ does not mean document root. It means the folder immediately above the one you're in. Example: http://www.somesite.com/folderA/folderB/folderC/somescript.php inside somescript.php: ../orders.txt is the same as http://www.somesite.com/folderA/folderB/orders.txt ../../orders.txt is the same as http://www.somesite.com/folderA/orders.txt etc...
-
Any reason why you decided to ask, before just trying it?
-
Like...you're mom? OH TEH BRUN!!1!11!11!!11!ONE1!!1!!!
-
What about the jerks (m and f alike) who pour a gallon of perfume type crap all over them, forcing me to choke and pass out?
-
EXACTLY. In the manual, the example is 'userfile' because in their example form they have You need to insert your own variable name in $_FILES['YOUROWNNAMEHERE'][...] : The one you used in your form.