-
Posts
14,780 -
Joined
-
Last visited
-
Days Won
43
Everything posted by .josh
-
What you have there is perfectly legitimate, however, depending on what your goal is, you could conceivably use something like JOIN to streamline your results. Offhand, it looks like you have two separate tables, one for account info and one for "game" or "content" info and the info from each table for the user has the common denominator of if rider_id and id (it looks like each table holds the same information). So, you could possibly use something like JOIN, INNER JOIN, LEFT JOIN, etc.. (lookup relational databases) to streamline. I'm going to go ahead and move this to the sql forum though, as those guys over there are much more knowledgeable in that area.
-
execute action with php when a link to leave a page is clicked
.josh replied to CBR's topic in PHP Coding Help
^ right. PHP is parsed on the server and then sent to the client, so you need a client-side script to do something like that. Alternatively, depending on what exactly you're trying to accomplish (in relation to your content), you could possibly setup a condition or something to check something or other and run the query at the beginning of the destination page(s). -
well then I suggest alternatively you could pass a token from page to page via sessions and check for the token upon each page load. So..if user were to manually enter in the address from the url...no token is generated/passed.
-
$max = 100; // some random number to be counted to $counter = 0; // initialize counter for ($x = 1; $x < $max; $x++) { // loop to count to whatever // % is called modulus it divides $x by 4 and returns a remainder if ($x % 4 == 0) { // if the remainder is 0.... $counter++; // add 1 to the counter } // end if } // end for
-
I would also suggest scrapping the whole idea of passing your variables through the url. Rather, maintain what areas the users have access to in your database. Have one "display" or "control" page that queries your database based on user's info. Have your query select relevant info and display a single page based on the user's level etc... In short, passing variables through the url should never ever ever be used unless it is completely harmless...like for pagination.
-
the keyword you are looking for is "pagination"
-
LoL I have dabbled in flash quite a bit, myself.
-
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.