premiso
Members-
Posts
6,951 -
Joined
-
Last visited
-
Days Won
2
Everything posted by premiso
-
Check out smarty on google. That is probably the most widely used template system with a ton of documentation. That should help you get rolling on your templates. I think you can even store smarty templates in DB and retrieve that way without having 100 files on your server (I know VBB uses templates in DB) Anyhow hope that get's you rolling with templates.
-
[SOLVED] how to add value to a filed every 24 hours?
premiso replied to berry05's topic in PHP Coding Help
Use a timestamp column in the database table. IE column named "nextincrease" and set that to be 24hours from now. The next time it is called you would do if nextincrease < time() then add 50 and set nextincrease = time() + (60*60*24); Hope that helps. -
[SOLVED] what is the best way to display a query result?
premiso replied to trampolinejoe's topic in PHP Coding Help
<?php $result = mysql_query(" SELECT COUNT(*) FROM orders WHERE product = 'MonkeyBars' AND status = 'paid'"); $row = mysql_fetch_array($result); ?> We have <?php echo $row[0]; ?> in stock. Something like that should work. -
Are you sure the variables are set correctly and that Y is not y? Just checking, also I think you need a ; after the echo (unsure of that but yea).
-
Unfortunately I lost all my old scripts due to a harddrive crash or else I would post it here. I do know the file had to be under 2mb's and I had to use the set_time_limit (setting it to 900) then about every 100 records output a "." to the screen or else the browser itself would time out. You may also be able to do this using the php command line, that way you do not have to worry about the browser timing out, just the script. Anyhow, good luck.
-
Should, although I would do this <?php $numTimes = (isset($_POST['times']) && is_numeric($_POST['times']))?$_POST['times']:10; for ($i=0; $i < $numTimes; $i++) { echo '<object width="$setwidth" height="$setheight""><param name="movie" value="http://www.youtube.com/v/$url&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/$url&hl=en&fs=1$autoplay" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="$allowfullscreen" width="$setwidth" height="$setheight"></embed></object>'; } ?> That way if it isset and is numeric it is set to that value, else it is defaulted to 10.
-
Yep, that would be the way to go IMO. And yea, I am always with ya, at least you tried and it will keep the honest people honest without disrupting them much.
-
<?php $numTimes = 10; for ($i=0; $i < $numTimes; $i++) { echo '<object width="$setwidth" height="$setheight""><param name="movie" value="http://www.youtube.com/v/$url&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/$url&hl=en&fs=1$autoplay" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="$allowfullscreen" width="$setwidth" height="$setheight"></embed></object>'; } ?> Will display it 10 times on the page.
-
True, but then if someone decodes that and sees that check, they could easily just tell people about it and viola. They don't even need to decrypt but one page to figure that out. I am just saying, if you are going to encrypt it I would do more than just a domain check. I would also make a hash in there for that domain (check the domain via the referrer on your end) that has to ping to a license deal on your server and check if that hash is valid for the domain requesting it. Either way though, if they decrypt the code they will probably remove the checks. I am just saying that I would have a licensing system in there to help make it a bit harder than just setting that server variable like done above... The main issue is just being able to be decoded, it really puts you off at how easy someone can do it and steal your script and use it.
-
Usually $end means you are missing a ; or } or ?> Since your code goes in and out of PHP so much with braces etc, I will let you figure out where it is. At least now you know what to look for. And check around line 123, most likely above it 1-5 lines but even below it and see what is there and what might be causing the problem.
-
Do you want it to display like that code 20 times every x seconds? If so, javascript would be the way to set this up, not necessarily ajax but if you code in the JScript it should work. Also the slee might work, but the page would not finish loading until all the items have been displayed and chances are the browser would time out.
-
I know when I had to do a database that 1as 10 MB's, I could rarely do more than 500 rows at a time, So what I did was read the file 500 lines, then delete that out of the file and put it into a new file "completed". Then just refreshed the script until it was all done. Unfortunately browsers do timeout and usually anything over 500 rows of processing, since reading the file, parsing the data and inserting it into SQL takes time, it is better to do it in increments, or do it via command line. The reason I needed to do it via php was I needed to re-create the table structure from the old db to the new one and the old one was in csv format. Another thing you could do is instead of executing the queries, write the SQL to a file then just import that file via command line also.
-
<?php require_once 'rss/rss_fetch.inc'; $url = 'http://mysite.com/rss' ; $rss = fetch_rss($url); if ( $rss and !$rss->ERROR) { $i=0; foreach ($rss->items as $item ) { if ($i > 2) break; echo ' <p><a href="' . $item[link] . '" target="_blank"><b>' . $item[title] . '</b></a><br / >'; echo '<i>Publish Date: ' . $item[pubdate] . '</i><br / >'; echo $item[ description ] . ' </p>' ; $i++; } } else { echo '<b>RSS Error: ' . $rss->ERROR . ' </b><br / ><br />' ; } ?> Should work. Another variation is: <?php require_once 'rss/rss_fetch.inc'; $url = 'http://mysite.com/rss' ; $rss = fetch_rss($url); if ( $rss and !$rss->ERROR) { for($i=0; $i < 3; $i++) { $item = $rss->items[$i]; echo ' <p><a href="' . $item[link] . '" target="_blank"><b>' . $item[title] . '</b></a><br / >'; echo '<i>Publish Date: ' . $item[pubdate] . '</i><br / >'; echo $item[ description ] . ' </p>' ; } } else { echo '<b>RSS Error: ' . $rss->ERROR . ' </b><br / ><br />' ; } ?> That might be more preferred but yea.
-
A side note even a whitespace is considered not empty. <?php if(isset($_RESULT['PSTU62']) && !empty(trim($RESULT['PSTU62']))) { echo $RESULT['PSTU62']."<br />"; } ?> The trim function will remove any whitespaces. Here is another variation, that may be better suited that way you the variable exist if not it is null you then use the is_null function to check. And it is trimmed in the definition. <?php $pst = isset($_RESULT['PSTU62'])?trim($_RESULT['PSTU62']):null; if(!is_null($pst) && $pst != "") { echo $RESULT['PSTU62']."<br />"; } ?>
-
[SOLVED] how to show data from tables for certain users
premiso replied to berry05's topic in PHP Coding Help
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <style type="text/css"> <!-- .style1 { font-size: 18px; font-weight: bold; color: #FF0000; } .style2 { font-size: 16px; font-weight: bold; color: #000000; } --> </style> </head> <body> <p class="style1">STATS:</p> <p class="style2">Gold: <?php mysql_connect ("localhost","root",""); mysql_select_db ("game"); $sql = "select * from users WHERE userid = " . intval($_GET['userid']); $result = mysql_query ($sql); while ($row = mysql_fetch_array($result)) { $gold= $row["gold"]; $water= $row["water"]; $food= $row["food"]; $health= $row["health"]; $point= $row["points"]; } echo "$gold<br>"; ?> </p> <p class="style2">Water: <?php echo "$water<br>"; ?></p> <p class="style2">Food: <?php echo "$food<br>"; ?></p> <p class="style2">Health: <?php echo "$health<br>"; ?></p> <p class="style2">Points: <?php echo "$points<br>"; ?></p> <p class="style2"> </p> </body> </html> Missed the ; for some values, should work. -
EASY if you have half a brain (SQL Order By - 2 different values)
premiso replied to johnsmith153's topic in PHP Coding Help
ORDER BY age, name Should work, show us the query. -
Just adding on, I would check to see if it exists first. <?php if(isset($_RESULT['PSTU62']) && !empty($RESULT['PSTU62'])) { echo $RESULT['PSTU62']."<br />"; } ?> That way it does not display the index undefined error when that value isn't there.
-
[SOLVED] how to show data from tables for certain users
premiso replied to berry05's topic in PHP Coding Help
Only because I am bored, I decided to help a little. This is assuming that you do have a column for userid in table users: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <style type="text/css"> <!-- .style1 { font-size: 18px; font-weight: bold; color: #FF0000; } .style2 { font-size: 16px; font-weight: bold; color: #000000; } --> </style> </head> <body> <p class="style1">STATS:</p> <p class="style2">Gold: <?php mysql_connect ("localhost","root",""); mysql_select_db ("game"); $sql = "select * from users WHERE userid = " . intval($_GET['userid']); $result = mysql_query ($sql); while ($row = mysql_fetch_array($result)) { $gold= $row["gold"] . "<br />"; $water= $row["water"] . "<br />"; $food= $row["food"] . "<br />"; $health= $row["health"] . "<br />" $point= $row["points"] . "<br />" } echo "$gold<br>"; ?> </p> <p class="style2">Water: <?php echo "$water<br>"; ?></p> <p class="style2">Food: <?php echo "$food<br>"; ?></p> <p class="style2">Health: <?php echo "$health<br>"; ?></p> <p class="style2">Points: <?php echo "$points<br>"; ?></p> <p class="style2"> </p> </body> </html> That should help you out, I did $_GET for demonstration purposes, but that can be changed later on to SESSION when you get it setup. -
[SOLVED] how to show data from tables for certain users
premiso replied to berry05's topic in PHP Coding Help
Your missing the point, you need to define the userid on login in session. Then when you call that query use the session variable of userid in place of currentuserid. That will allow you to pull up the records only for that user id. Given that I am not sure how your script is suppose to work or does work, it may already be done. But also as rev pointed out I would use just one query as the first query will give you the items you need, no need for multiples. -
I know how to replace things, but how do you only allow stuff? Probably should create a new topic. ereg will answer you question on how to test if certain items are in a variable/not in.
-
[SOLVED] how to show data from tables for certain users
premiso replied to berry05's topic in PHP Coding Help
Instead of just doing SELECT * FROM users, why not change it to SELECT * FROM users WHERE userid = currentuserid That way you only get the current user's information. The kicker is you need to know the userid, so like rev said, use a session when the user logs in to store his id and pull it out. session_start should provide examples. -
[SOLVED] how to show data from tables for certain users
premiso replied to berry05's topic in PHP Coding Help
Show us some code and we can probably help ya. -
Do some debugging, echo out $curdir and see where it is sending you to. Are the files that you want to be included in that directory?
-
Wouldn't exactly work. <?php echo $_SERVER['HTTP_HOST'] . "<br />"; $_SERVER['HTTP_HOST'] = "BLAH"; echo $_SERVER['HTTP_HOST']; ?> All I Would need to do is make a mock up of your script and include the file after I set the server variable to what I want. Sucks I know.