-
Posts
14,780 -
Joined
-
Last visited
-
Days Won
43
Everything posted by .josh
-
[SOLVED] Check if Variable is set to a specific string
.josh replied to sageauk's topic in PHP Coding Help
the value will be found in $_GET['link'] so just use it in a condition to do whatever you want it to do for example: <?php // example 1 if($_GET['link'] == 'form2') { // do something } // example 2 $array = array('form1','form2','form3'); if (in_array($_GET['link'], $array)) { include "{$_GET['link']}.html"; } ?> -
Haha well... what do you expect when you just say something is amazing? If it's so amazing then shouldn't it inspire you to be more descriptive, like, saying "it's amazing" just doesn't seem to do it justice sort of thing? Perhaps it isn't as amazing as you make it out to be
-
[SOLVED] connecting to mySQL and executing querys
.josh replied to simonpatp's topic in PHP Coding Help
As far as what your actual problem is: you're trying to add your db argument to your mysql_connect. That's not where it goes. You need to select it with mysql_select_db. Look at dropfaith's example. -
Fresh baked french bread. It's such a simple thing to make. You mix the stuff together, knead it out, let it rise, knead and rise. You can smell the yeast eating up the sugars and releasing the gas; something about that smell makes me feel at home. And when it bakes and comes out of the oven all crispy on the outside, soft on the inside... smell of it, sound of the crust crackling, the crunch and slight chewiness... Get a good slab of sharp cheddar to slice off, serve them with a simple prepared meat like sausage pieces or seared cube meat chunks or roasted turkey legs. Get some friends and family around a campfire singing and dancing and hopefully you have a musician or two to play a guitar or flute. Makes me feel tribal or gypsy like I'm living in simpler times. I know that goes beyond the food but food is not just something you put in your mouth it's an atmosphere enhancer just like the ambiance of restaurants or the movie you're watching while eating or the music going on in the background or whatever.
-
Haha well like I said, I don't mind stopping at some McFood place if the occasion necessitates it, but I like to cook. People tell me I'm pretty good at it, actually. Tell me I need to open a restaurant or somethin'. I probably would if I had the cash. Name it and I can probably make it completely from scratch without a cookbook, sort of thing.
-
First error I see is your form uses the POST method but you are trying to grab vars from the GET method.
-
who owns domains? what stopping me from selling them?
.josh replied to Orionsbelter's topic in Miscellaneous
non-profit, i.e. they don't make a profit. Their expenses match their revenues. It doesn't mean everybody works for free. Exactly. Non-Profit != people don't get paid. They still get to charge money to pay to run their business, from bills to supplies to salaries etc... and even then if the income exceeds the expenses it just gets rolled into other things. All it really means is you write the numbers down on the paper differently. -
who owns domains? what stopping me from selling them?
.josh replied to Orionsbelter's topic in Miscellaneous
You know, $2500 really isn't crap in the business world. -
So...moving a file from one folder to another is a daunting task?
-
Okay no, you don't get it. It's just like using posted variables from a form, but instead you are using $_GET instead of $_POST. Your deletenews=$newsid is being assigned to $_GET['deletenews'] not $deletenews. So you have to check for $_GET['deletenews'] and you have to use that in your query, or at least assign $_GET['deletenews'] to $deletenews before using $deletenews. Look at this post I recently made for some other thread. It gives a simple example of a delete link and how to check for it and delete a row in your database with it.
-
You have deletenews as a var to be passed in your url (the links generated in your while loop). But you have if (isset($deletenews)) { is there somewhere before there that has something like this? $deletenews = $_GET['deletenews']; because vars passed through the url get put into the $_GET array.
-
If you want people to help you, you need to make an effort to type like a normal human being. Nobody is an expert but that's a disrespectful joke of a post.
-
Well as far as displaying extra things like delete buttons, you don't really need to change your login.php at all. Everybody logs in the same, unless you were wanting to like, redirect them to an entirely different page, based on their userlevel.
-
I'm leaning toward what Andy is saying, as well. But, failing that... == is case sensitive. Perhaps you have for instance jack instead of Jack in your db?
-
Pretty much what bendude said (He posted while I was typing ) Make another column in your user account table called accesslevel or some such thing. Simple int type is fine, since you will just be using 0,1,2... In your script, you would have users login/navigate as usual. But wherever you want to edit/delete something, you would just insert some condition code to show links or whatever, based on accesslevel. For example if you have a script that list names, you could do something like this (assuming you're logged in): // simple code example... // check if need to delete something if ($_GET['id']) { // force type casting to prevent foul play. All you really need to do when expecting an int $id = (int) $_GET['id']; // make sure user has access level so reg users can't just append url and trigger if ($_SESSION['accesslevel'] == 1) { $sql = "delete from names where id = $id"; $result = mysql_query($sql); } // end if accesslevel } // end if get id // get info from table and list...assumes there is an id associated with row $sql = "select name, id from names"; $result = mysql_query($sql); while ($list = mysql_fetch_assoc($result)) { // echo the name no matter what echo "{$list['name']} "; // assuming 0 is reg member 1 is admin if ($_SESSION['accesslevel'] == 1) { // echo a delete link echo "<a href='{$_SERVER['PHP_SELF']}?id={$list['id']}'>delete</a>"; } // end if accesslevel echo "<br />"; } // end while
-
Toxic does not necessarily mean lethal. It means harmful in general. All the chemicals (preservatives, synthesized fats/sugars, food colorings, etc...) are not good for your body. And yet, that's what makes it so yummy. It's kind of like moths to flames, lol. Anyways... I'm down for eating pretty much anywhere, but if I had a choice I'd go for a good sandwich. But that usually involves me making it myself. If I'm going for healthy, I go for a wheat sandwich roll, cracked pepper chicken or turkey (cut super thin), sharp cheddar or swiss, lettuce tomatoes red onions yummy. If I'm going for tasty, I go for a hot meat and cheese combo like pastrami salami and corned beef with swiss and pepperjack thrown on some nice asiago cheese french bread and put under the broiler for a couple mins mmmmm (drooling now, I think I know what I'm making for lunch ). Or if I'm going for something simple and fast, I like a spicy sausage halved and topped with peppered mustard and sharp cheddar, put on a baguette.
-
[SOLVED] Set a link in your signiture
.josh replied to Flames's topic in PHPFreaks.com Website Feedback
@zanus: code tags bro [url=http://www.somesite.com]somesite[/url] -
Give an example of what you need to use wildcards for. If it's for selecting stuff from a database, your database has built-in regex functions/operators/symbols. If it's trying to find patterns in strings, php has built-in regex functions that include wildcard operators/symbols.
-
$sql = "select count(approve) as totals from downloads group by approve"; $result = mysql_query($sql); $unapproved = mysql_result($result, 0, 'totals'); $approved = mysql_result($result, 1, 'totals'); edited: forgot 3rd argument in mysql_result
-
There's a reason why the software industry is focusing on services rather than products. It's just too easy to obtain and use your product without paying for it, and too hard to keep people from doing so.
-
wow I'm gonna give it a try I've never used linux before this sounds like the perfect thing to get my feet wet before jumping in.
-
[SOLVED] Get data from database and diplay in a table
.josh replied to ericburnard's topic in PHP Coding Help
- Use <?php instead of <? shorttags do not work on all server configurations. - Use mysql_fetch_assoc instead of mysql_result. mysql_result is terrible and only real use for it is if you are wanting to "look ahead" to the next row, which is pretty much never. Also it gets rid of having to use mysql_numrows. - I'd also avoid using @ as it suppresses errors (proper error handling is a better method). Not really gonna type out error handling routines for you or nothin', but controlling what is being output when things go wrong is a lot more secure. Many default error messages will reveal info about your system, setup, var names, table info, etc.. that someone could use against you. - mysql_close is not really necessary either, as php will automatically close it when the script finishes executing. Only really useful if you are only using connection at beginning script and there's a ton of script to execute after that, but even then, the resources used is negligible. - I also like to assign my mysql_connect and mysql_select_db to a variable and include it as the optional 2nd argument in mysql_query. Not strictly necessary for a simple script with only one connection; more a matter of discipline. - Also, you should avoid using * in your query unless you are going to use all of the columns. You only use 'department' in your loop so only select department. Doing so will cut down on script query/execution time and resources used. <?php include ('db.php'); errorhandlingfunction() { // stuff for handling errors here } $conn = mysql_connect($host,$username,$password) or errorhandlingfunction(); $db = mysql_select_db($database) or errorhandlingfunction(); $query="SELECT department FROM departments"; $result=mysql_query($query, $conn) or errorhandlingfunction(); echo "<table><tr>"; $x = 1; while ($list = mysql_fetch_assoc($result)) { echo "<td>{$list['department']}</td>"; echo ($x % 5 == 0)? "</tr><tr>" : ""; $x++; } echo "</tr></table>"; ?> There's always room for improvement, but anyways, there's my 2 cents. -
All my php files has .tpl extension is there any editor to work on that
.josh replied to anushka's topic in PHP Coding Help
Ah apparently .tpl has become a generic extension for template style files since last I seen it. Yeah what wildteen said...if it's just plain old text you should be able to open it in any text editing software. If you are unable to do so or if it looks like garbage when you open it, then chances are it's for a very specific software that stores it in their own proprietary format. Probably some SDK of some kind. As far as which one...who knows? Better for you to ask the person/place you got it from. My gut says look towards Borland if you don't have any other leads. -
All my php files has .tpl extension is there any editor to work on that
.josh replied to anushka's topic in PHP Coding Help
You sure that's php? I thought .tpl was associated with pascal. -
[SOLVED] Get data from database and diplay in a table
.josh replied to ericburnard's topic in PHP Coding Help
<?php echo "<table><tr>"; $x = 1; while ($x < 26) { echo "<td>$x</td>"; echo ($x % 5 == 0)? "</tr><tr>" : ""; $x++; } echo "</tr></table>"; ?>