-
Posts
14,780 -
Joined
-
Last visited
-
Days Won
43
Everything posted by .josh
-
hrmm..okay, so you already have a database, and you are wanting to phrase a query to pull specific information based on your criteria? I mean, I could help you on some php code to sort through it all if you do a query for everything first, but that's not really efficient. I think you'll probably find the sql forum more useful so I'm going to go ahead and move your thread over there. One of the resident database experts should be able to help you out there.
-
Okay I'm not quite sure I'm understanding this 100% but it seems to me that what you are saying is that for each row of your table, you want it to look like this, right? Group1FirstNameLastNameBusinessNameGroup2 BobSmithBobSmithCrayolaCrayola JohnDoeJohnDoeBubbleGumBubbleGum BobSmithBobSmithBubbleGumBubbleGum If that is the case, first off, I don't really see why you would need the Group2 column, as it is virtually identical to the businessname column...2nd, Group1 would be made simply by concatonating your Firstname and Lastname variables. I don't really know how you have anything else setup, but it seems you would do that in the information entering process, in the part of your script that creates the new entry; just make a new temp var $group1 = $firstname . $lastname; etc... if that's not what you're saying then..uh, please elaborate further.
-
[SOLVED] Ok so I rewrote my question/problem to make it more clear
.josh replied to prcollin's topic in PHP Coding Help
yes. But if there is a file in that directory with the same name, it will overwrite it. -
If I do anything officially official I usually cross all my t's and dot all my i's, but I have hundreds of little script projects/messing arounds/hobbies that I don't really bother with "formal" things on.
-
Think your quote pretty much says it all... it's not necessary but it's more efficient.
-
can you show an example using example data?
-
Best option is to obfuscate your script using an encryption program like from zend or sourceguardian etc...just google "encrypting php" or w/e.
-
The reason why some people tend to mix the two together is for security reasons. People like to hijack/fake session info, so coders like to store that info in the db and then verify the info (like the session id) against what's in the database at the time. Also, they are "mixed" so-to-speak, because many things you do, use both of them. For instance, You would use the db to hold information about someone, like their name, address, password, etc.. and you would have the user login to your site and you would use a session to hold that information from page to page to keep them "logged in." Sessions are most commonly used for signifying whether someone is "logged in" or "logged out" (though there are many many other uses for it). If you know a thing or two about computers, think of a database as the computer's rom or harddrive, and think of sessions as the ram. If you're just looking to do something simple, non-data sensitive, forget the whole database thing, as it is overkill. Based on your original post, all you need is something as simple as this: page1.php <?php session_start(); $_SESSION['somevariable'] = "blah"; echo "<a href = 'page2.php'>go to next page</a>"; ?> page2.php <?php session_start(); echo $_SESSION['somevariable']; ?>
-
[SOLVED] I've changed the PHP code and now it doesn't work
.josh replied to Wizard4U's topic in PHP Coding Help
Mr. Wizard4U, can you please be so kind as to give us an update as to what you have tried to do, as far as fixing your code (other than shoving it at us and asking for a magic wand to be waved)? Because at this point in time, based on your most recent comment, I would suggest seeking a freelancer (please go to freelance forum). We aren't here to do your work for you. -
Same way as you insert something into any other data field, except that the values you insert can only be "yes" or "no". Are you asking how to insert data into your table? Please make use of the search field or google, as that is a very common, very basic question.
-
You could make a loop....? I think that's what you're wanting to do...right? I'm seeing several queries in this code, so are you trying to somehow condense all that code into one query, or are you wanting to repeat that entire block of code over and over again? Need more info please.
-
well, to be honest, I'm not 100% certain of your querying style there...I mean, there's many ways to do the same thing, but that's not how I would do it, so I'm unfamiliar with the inner workings of for instance mysql_fetch_object etc.. however... Right off the bat though I would say your actual query string is only going to return a password. I guess that's what you're shooting for, but then you have: $row=mysql_fetch_object($st); $em=$row->email_address;// email is stored to a variable $em isn't going to be assigned anything, because you only queried for a password, based on the name/email. The only info that $st is going to hold is the password. Here's how I personally would code getting the password: <?php // connect to database $conn = mysql_connect('localhost', 'db_username', 'db_password') or die(mysql_error()); $db = mysql_select_db('db_name',$conn) or die(mysql_error()); //dummy vars $name = "John"; $email = "[email protected]"; $query = "select password from tablename where name = '$name' and email = '$email'"; $rs = mysql_query($query, $conn) or die(mysql_error()); if ($info = mysql_fetch_array($rs)) { $pass = $info['password']; // here is the password } else { echo "no password found."; } ?> But that's assuming you just want a straight forward query based on the user putting in his name and email, and then he gets his password retrieved.
-
first off, try putting an echo $first_name . '<br>'; echo $email_address; above your $query = .... to see if your variables are holding what they're supposed to be holding. If they aren't...
-
You have to use nested for() or foreach() loops. example: for ($x = 0; $x < 10; $x++) { for ($y = 0; $y < 10; $y++) { echo $blah[$x][$y] . "<br>"; } // end y } // end x
-
the problem is your in_array arguments are reversed. It's in_array(needle, haystack)
-
Hey art, Using an array to pass multiple values from a form is a very common question that not only comes up a lot, but you will also find it inside people's code snippets in practically every other thread...because like 99% of forms have multiple values to be passed, and it's just more logical to use an array instead of individual variables. I pointed you in the right direction with my other post. This post is me suggesting you use the search function for a very common coding practice. Good luck and happy coding
-
I made a separate post because I know you're reading: How about trying a little } after that return, and before your next function. That might possibly be it, because without that, it's like, trying to use your variable in two different ways.
-
umm, well I can't really be more specific than that without pouring over your entire code (which I'm not about to do sorry lol) I mean, I'm not necessarily seeing a problem with the code that you provided, so you're probably gonna have to backtrack and see what argument you're trying to pass to your functions. You just have to go through your code and make sure you didn't do anything like declare your variable somewhere else that's under the same jurisdiction as in this function (like a global variable) etc... p.s.- using $string in more than one function doesn't necessarily mean anything. They are both local variables that are trashed when the function breaks...but it might mean something if you have, as mentioned, a global version of it somewhere.
-
You need to update the database (run the query) for each checkbox value that's posted. Most people do this by passing the checkbox data in an array instead of an individual variable for each one, and then either loop through the array (putting the query inside the loop) or rephrasing the query (it really depends on the data etc.. as to what's best).
-
I think the problem has to do with you declaring a variable as one type (by virtue of assigning something to it, of course), and then trying to use it as a different type. I think.
-
I like the interactive quizzes/tutorials idea 448191 suggested. Also, I'd like to see the freelance forum removed from the boards, and put onto the main site somehow.
-
Okay so my brother calls me and says he went to turn on his computer and it starts up a system recovery, prompting him to skip or go ahead with it. He says if he opts to go ahead, it starts the process and when it's done, it restarts his computer, but it starts the system recovery all over again. He says if he opts to skip it, it restarts his computer, and same thing; system recovery. He says that it does not give any kind of error message or reason behind this system recovery. I am in no way shape or form any kind of expert when it comes to this area of computers, so I'm appealing to you guys to see if anybody might know what might be causing this, or point me in the right direction as far as googling or something. Any ideas?
-
The Super Cool Mostly Official Frankenstein-Code Game Thread!
.josh replied to .josh's topic in Miscellaneous
okay I thought I'd make a new post instead of editing the last one, since it's on a new page. Okay, It's all about.. Bride of Franky! <?php $relatives = array('mother', 'father', 'sister', 'brother','uncle', 'auntie'); $verbs = array('dislikes', 'sits on', 'licks', 'sucks', 'looks like', 'does', 'discusses the pros and cons of Web 2.0', 'loves', 'caresses', 'slides onto', 'hates', 'kisses', 'learns PHP with', 'has an AJAX interface with'); $animals = array('dogs', 'cats', 'horses', 'birds', 'giraffes', 'elephants', 'hippos', 'hamsters', 'gerbils', 'monkeys'); $adjectives = array('abhorrent','abject','abnormal','abrasive','absorbed','absurd', 'abusive','acrid','agonizing','ambiguous','ancient','apathetic', 'average','bad','barbarous','bawdy','belligerent','berserk', 'bizarre','black','boorish','brash','brawny','burly', 'callous','cold','colossal','combative','crabby','craven', 'crazy','creepy','crooked','cynical','demonic','deranged', 'devilish','direful','dirty','disagreeable','draconian','drunk', 'dysfunctional','erratic','evasive','evil','filthy','flippant', 'gaudy','giant','gigantic','greedy','grotesque','grouchy', 'gruesome','grumpy','guiltless','hellish','horrible','huge', 'hulking','icky','immense','irate','jaded','jittery', 'macho','maddening','malicious','mammoth','maniacal','massive', 'mighty','mindless','moaning','moldy','murky','mysterious', 'nasty','nauseating','noxious','oafish','obscene','psychotic', 'rabid','ruthless','sassy','scary','smelly','snobbish', 'snotty','spooky','threatening','tightfisted','tough','towering', 'trashy','ugly','unbecoming','unsightly','vagabond','vengeful', 'venomous','vulgar','wicked','wrathful','wretched'); function insult($secondary_person) { global $relatives; global $verbs; global $animals; $r_size = sizeof($relatives) - 1; $v_size = sizeof($verbs) - 1; $a_size = sizeof($animals) - 1; $r_rand = rand(0, $r_size); $v_rand1 = rand(0, $v_size); $v_rand2 = rand(0, $v_size); $a_rand = rand(0, $a_size); $insult = "Your {$relatives[$r_rand]} {$verbs[$v_rand1]} $secondary_person and {$verbs[$v_rand1]} {$animals[$a_rand]}"; return $insult; } class Greeting { function Greeting() { echo "Hello World!"; } } interface Singleton { public static function getInstance(); } interface Actor { public function speak(); public function meet($person); public function eat($animalArr); } abstract class Intestant_Abstract { abstract public function input($input); abstract public function output(); } class Stomach extends Intestant_Abstract implements Singleton { private static $instance; public static function getInstance() { if (!isset(self::$instance)) { self::$instance = new self; } return self::$instance; } private function __construct(){ } public $kilosOfFood; public function input($input){ $this->kilosOfFood += strlen($input); echo 'Franky liky to eats '.$input.'..<br />'; if($this->kilosOfFood > (strlen(implode('',$GLOBALS['animals']))/1.5)){ $this->output(); } } public function output(){ echo '<br />Bhaarf..<br />'; } } class Guts implements ArrayAccess, Singleton { private static $instance; public static function getInstance() { if (!isset(self::$instance)) { self::$instance = new self; } return self::$instance; } private function __construct(){ } private $intestants; public function add($name){ $this->intestants[$name] = call_user_func(array($name, 'getInstance')); } public function remove($key) { unset($this->intestants[$key]); } public function offsetExists($offset) { return isset($this->intestants[$offset]); } public function offsetGet($offset) { return $this->intestants[$offset]; } public function offsetSet($name, $value) { $this->add($name); } public function offsetUnset($offset) { unset($this->intestants[$offset]); } } class Franky implements Actor { private $person; public function meet($person){ $this->person = $person; } function eat($animals){ shuffle($animals); $guts = Guts::getInstance(); $guts->add('Stomach'); $guts['Stomach']->input(next($animals)); } public function speak($insult_them = false){ if($this->person == null){ $greet = new Greeting(); echo '<br />'; } else { echo 'Hello '.$this->person.'!<br />'; if ($insult_them) { echo insult($this->person) . '<br />'; } } } } if (isset($_POST['relativeName'])) { $relativeName = $_POST['relativeName']; $relativeType = $_POST['relativeType']; $h = new Franky; $h->speak(); $h->meet($relativeName); $h->speak(true); $h->eat($animals); $h->eat($animals); $h->eat($animals); $h->eat($animals); $h->eat($animals); $h->eat($animals); $h->eat($animals); $h->eat($animals); $monstername = $adjectives[array_rand($adjectives)]; echo "<br/>Franky wants to marry your $relativeType.<br/>"; echo "$relativeName will join the monster family and<br/>"; echo "$relativeName's monster name will be $relativeName the $monstername.<br/>"; } else { $person = $relatives[array_rand($relatives)]; echo <<<FORMINT What's your $person's name?<br/> <form action = '{$_SERVER['PHP_SELF']}' method = 'post'> <input type = 'text' name = 'relativeName' size = '10'> <input type = 'hidden' name = 'relativeType' value = '$person'> <input type = 'submit' value = 'submit'> </form> FORMINT; } ?> -
The Super Cool Mostly Official Frankenstein-Code Game Thread!
.josh replied to .josh's topic in Miscellaneous
<placeholder>