premiso
Members-
Posts
6,951 -
Joined
-
Last visited
-
Days Won
2
Everything posted by premiso
-
Extract data from $row into database. Simple thing i think...
premiso replied to cs.punk's topic in PHP Coding Help
First off, you do not put functions inside quotes: $result = "mysql_query($con,$query)" $row = "mysql_fetch_array($result)"; Both should be: $result = mysql_query($con,$query) $row = mysql_fetch_array($result); Second when using variables inside of strings that are arrays: $query = "SELECT * FROM shop_stock WHERE Item = '{$_POST[item]}' "; You use { } to surround them. Fix those issues and then see if you still have that question. -
preg_match Would be a function you want to look into. I believe there maybe this exact deal somewhere on these forums or on the user comments section at the link to the left. If I knew regex better I would post one, but yea.
-
It is done in flash. They just need 1 flash app, then they feed it the location of the song they want to play. Not hard to do, you can probably google to find the script.
-
Umm post the code. Chances are it is due to a column issue...
-
Is there a project that is 100% working on the first day?
premiso replied to closed_tag's topic in Miscellaneous
Nope, not always. Exploits, bugs, and changes in code will screw it up. And chances are once you are done you find features you want to add, thus begins the development phase again. So even if it is 100% working, you will probably end up changing it. But it all depends on the size as stated before. What type of project are you working on? In my project management class in college they taught UML, with Use-Case form of designing and planning out the timeline in Visio. The hardest part of a project, in my opinion is the planning process cause you want to make sure you cover your basis, but you will never always cover it so you keep re-planning and modifying the timeline with the new feature or the item you forgot etc. So yea, it all depends on the project. EDIT: It also depends on the coder(s). -
It will carry automatically if you assign it to $_SESSION['username']. Then just access it that way.
-
In php...this is one way. <?php $timePlus2 = time()+3600*24*2; ?> Would get you a timestamp of +2days, You can also use the strtotime function, but yea. Either would work.
-
[SOLVED] Correct syntax for while loop? Zend disagrees.
premiso replied to MadnessRed's topic in PHP Coding Help
In the format of the array fetching it should be... while($row = mysql_fetch_array($query)){ If you are however checking if one value equals another, such as... $i=0; $x=0; while ($i == $x) { $i++; echo "Should execute once."; } You would use the == operator. Reasoning, the = is an assignment operator. So while you are allowed to assign a value to $row loop. Where as if you switched it to == (equal checker) the loop will never run cause $row probably does not equal the returned value of fetch_array. -
Try coding a logout feature and use that. See if it still shows you logged in after logging out.
-
Search MYSQL Database using PHP Page then Use results.......
premiso replied to mdemetri2's topic in PHP Coding Help
Post code. -
Almost every website hides their directories cause the world does not need to see it. However, if their webserver is setup to show directories you will get an html page list of the directories. If they do not have that, you would have to have FTP permission to the site to get all the filenames etc. If they do not have it in a list somewhere, you cannot get their directory listing.
-
You could use $_SERVER['HTTP_HOST']... <?php $redirectTo = "http://" . $_SERVER['HTTP_HOST'] . "/index.php?action=register"; header("Location: " . $redirectTo); ?> However your redirect code is invalid, it should be ? for the first argument then & for subsequent arguments... IE: ?action=register or ?action=register&uname=bob etc.
-
Probably not, due to the fact if it is not setup to be displayed you cannot display it. If it is setup to be displayed you need to just fetch the page and parse out the link/file locations.
-
[SOLVED] call_user_func_array not setting objects
premiso replied to droberts's topic in PHP Coding Help
I do not think you can dynamically instantiate a class like that with $controller....I also do not see a "controller" class. $name is not being used anywhere either..... -
PHP GURUS: How would you go about reading the source of an HTML page?
premiso replied to virtuexru's topic in PHP Coding Help
<?php $string = '<input type=hidden name=asd value="a490b986af96b1937b9d6ba6796acd11">'; list(,$string) = split("name=asd value=\"", $string); list($value) = split("\"", $string); echo $value; ?> That would be the easiest. This can be done with regex, but I suck at that so yea. -
Hello All! I am wondering what anyone on here uses for a blog templating script. I currently host a blog website and I am in the process of revamping/updating the code. Currently the user's templates use what is called "Easy Template System", which is way outdated (2004 I believe). I was thinking of Smarty, but I do not think that bulky of a template system. PHP I think is out of the question for the most part, as this is just general users I want it to be as simple as possible for them. I really would not mind implementing one that is already in mass production like a Blogger Template System for PHP, although my search has yielded failed results. If you have a system you use or an idea of one for me to implement I am all ears! Thanks. Just a note, if there is code already made, that is great. But just the idea of one is easy enough for me to implement, no need to break your heads trying to write code for me
-
PHP GURUS: How would you go about reading the source of an HTML page?
premiso replied to virtuexru's topic in PHP Coding Help
How indepth do you want to go? file puts the page into an array line by line file_get_contents puts it into a string and works with less code than cURL but is slower. User preference imo. -
Here is my take at this... <?php function clean($field, $type="string", $html=false){ if ($html) $field = strip_tags($field); if (get_magic_quotes_gpc()) $field = stripslashes($field); switch ($type) { case "int": $field = (int)$field; break; default: case "string": $field = mysql_real_escape_string($field); break; } return $field; } ?> That should work for about anything. You can add more cases to do extra checking etc. The HTML was added cause if you run a blog or something like that, you want to allow html to be passed through. As for your original function, I would add the get_magic_quotes_gpc check in there, so incase it is already off there is no need to strip slashes. But I would actually separate out the "cleaning" portion and put that into a new function like, validate() cause they are really 2 different items, cleaning something just makes it database enterable, validating something is making sure that the stuff that should be allowed is there and disallowed is not there.
-
Modulus does not just divide, it returns the remainder. 1/2 returns .5 as the remainder. 2/2 returns 0 as the remainder. 0/2 returns 0 as the remainder, 1 returns .5 as the remainder, rinse and repeat.
-
Templating, itself, is a big debate. It all depends on the type of application you want, whether or not Smarty would be good for you. For a system that say allows a user to create their own template, where you do not want to allow access to certain php functions, and frankly do not want them to use php at all, that is what Smarty imo was designed for. For the regular site, yea go berserk on using php files with php code to template it, but for user template interaction, it does provide a barrier net and yes a user has to learn to use the right tags, but I would rather have them do that than just all them to code in PHP. Anyhow, there may be better alternatives to smarty, that was just an example.
-
Why not use an already made system such as Smarty ?
-
<table width="95%" border="0" cellspacing="0" cellpadding="1" class="boxtitle"> <?php $sql = "SELECT * FROM thelist WHERE username = '$uid' ORDER BY jpted"; $rs = mysql_query($sql); $i=0; while($row = mysql_fetch_array($rs)) { extract($row); $bground = "some style"; if (($i%2) == 0) $bground = "somealretnatestyle"; $i++; ?> <tr class="<?php echo $bground; ?>"><td> <a href="editaj.php?jid=<?php echo $id; ?>"> <?php echo $jtitle; ?> </a></td> <td> <?php echo $city; ?>, <?php echo $state; ?> </td> <td><a href="editaj.php?jid=<?php echo $id; ?>"> Edit </a></td> <td><a href="editaj.php?jid=<?php echo $id; ?>&del=yes"> Delete </a></td> </td></tr> <?php } ?> </table> And a side note, the % operator is the modulus operator if you want to look up on it. http://us2.php.net/manual/en/language.operators.arithmetic.php
-
Question about Query pulling from Several Tables
premiso replied to limitphp's topic in PHP Coding Help
songID does cause it is a foreign key which links the 2 tables together. As long as songname is not duplicated you are golden. Is there a way to connect the foreign keys in the two tables, so mysql knows they are linked? Kind of like how ms access did it, in the relationship view...where you see all the tables and you connect the arrows to primary and foreign keys? Not that I know of. It would be nice so you just delete one record and could have it trinkle down, but yea. As far as I know, nope. You can find some tutorials that mimic this behavior but yea... http://www.google.com/search?hl=en&q=mysql+relationships+foreign+key+linked+tables&btnG=Search http://www.weberdev.com/ViewArticle/Managing-Foreign-Key-Relationships-In-MySQL-Using-SQLyog -
if (!isset($_SESSION['test_logged_in']) || !$_SESSION['test_logged_in']) { die("You are not logged in."); } Put that at the top of the protected page.