RussellReal
Members-
Posts
1,773 -
Joined
-
Last visited
Everything posted by RussellReal
-
well most new people parse using preg_match_all, but I use strpos()/substr() it runs alot faster.. http://php.net/strpos http://php.net/substr http://php.net/preg_match_all
-
[SOLVED] only showing a value if it equals something?
RussellReal replied to shadiadiph's topic in PHP Coding Help
<?php require("../global/admin_functions.php"); $query = "SELECT `thumbnail4`,`thumbnailtype4` FROM `zloads` WHERE `intProductID` = '{$_GET['adid']}' LIMIT 1"; $result = mysql_query($query); if ($r = mysql_fetch_assoc($result)) { $data = $r["thumbnail4"]; $type = $r["thumbnailtype4"]; header( "Content-type: $type"); print $data; } else { header("Content-Type: image/png"); $source = file_get_contents("../pix/noimage.png"); print $source; } ?> ok bro.. try that.. and try both EXISTING images.. and NONEXISTING images.. if anything it will show the warning for non existing images.. -
[SOLVED] Using switch to call arrays from seperate file
RussellReal replied to spidermann's topic in PHP Coding Help
not to be rude.. but neith of your posts make much sence.. I can help you.. but seeing real code not dummy text would be really helpful.. and is just a TIIIINY bit confusing, because I don't see any function declarations, and $mode can't call any variable since its a variable itself..? :S I'd really like to help you but I don't want to say anything since I don't completely understand what you mean lol -
[SOLVED] only showing a value if it equals something?
RussellReal replied to shadiadiph's topic in PHP Coding Help
<?php require("../global/admin_functions.php"); $query = "SELECT thumbnail4,thumbnailtype4 FROM zloads where intProductID=".$_GET['adid']." LIMIT 1"; $result = mysql_query($query); if ($r = mysql_fetch_assoc($result)) { $data = $r["thumbnail4"]; $type = $r["thumbnailtype4"]; header( "Content-type: $type"); print $data; } else { header("Content-Type: image/png"); $source = file_get_contents("../pix/noimage.png"); print $source; } ?> -
<?php echo date('Y-m-d',strtotime('2008-12-27 +1 month')); ?> this should be what you'd probably want <?php echo date('Y-m-d',strtotime("{$mydate} +{$addmth} month")); ?>
-
Transition of resources(database connection) across pages
RussellReal replied to dvd420's topic in PHP Coding Help
hello, I don't quite understand what you mean.. but, as you may know as php exits, it destroys any resources and variables that has been created so once php exits, you can't share the previous resource with another page.. you just need to re-connect to the database on the next page.. unless you mean share the resource with other pages rthat you are including.. which you shouldn't have a problem with.. -
file_get_contents or cURL http://php.net/file_get_contents http://php.net/curl
-
well yes, that would mess you up aswell.. you should ALWAYS use mysql_real_escape_string any POST or GET variable which your end user can manipulate and send back to your server, which gets put into a sql query, should always be escaped to ensure security aswell as avoid errors..
-
to be honest.. I really didn't read a book.. or use any tutorials.. I just kind've browsed php.net everytime I needed to find a function lol.. also, looking @ php codes that were already written kinda made me curious as to WHAT MAKES THIS SCRIPT DO WHAT IT DOES.. basically lol if you want to keep in touch, heres my email/MSN: RussellonMSN [AT] hotmail.com
-
not sure bro, but I know you can use dlls also.. you're gonna have to wait until like the SERIOUS PRO phpers start to come on lol I don't work with dlls or com objects, never needed to =\.. sorry man
-
okay.. assuming you want ALWAYS at max 10 page links at the bottom. <? include("Connect.php"); $page = ((!is_nan($_GET['page']))? $_GET['page']:1); $sql = "SELECT * FROM `mytable` ORDER BY `id` ASC LIMIT ".(($page - 1) * 25).",25"; $sql2 = mysql_fetch_assoc(mysql_query("SELECT count(*) As num FROM `mytable`")); $query = mysql_query($query); $start = ((($a = ($page - 5)) < 1)? 1:$a); $pages = ($sql2['num'] / 25); $end = ((($a = ($page + 4)) > $pages)? $pages:$a); $range = range($start,$end); $links = array(); if ($page > 1) $links[] = "<a href=\"Records.php?page=".($page - 1)."\">Prev</a>"; foreach ($range as $k => $v) { $links[] = (($v == $page)? $v:"<a href=\"Records.php?page={$v}\">$v</a>"); } if ($page < $pages) $links[] = "<a href=\"Records.php?page=".($page + 1)."\">Next</a>"; echo implode(" ",$links); ?> THERE MAY BE A FEW ERRORS.. AS I HAVN'T TESTED THIS..
-
the server will never set a wrong date..
-
anytime bro
-
oh sorry, js and php mixup there CANT KEEP IT ALL IN ITS PLACE IN THE WONDERFUL MIND OF RUSSELL
-
include("Connect.php"); $page = ((!is_nan($_GET['page']))? $_GET['page']:1); $sql = "SELECT * FROM `mytable` ORDER BY `id` ASC LIMIT ".(($page - 1) * 25).",25"; $query = mysql_query($query);
-
note: mysql_real_escape_string() is weird, it only works if you connect to a mysql database, so make sure you have a database connection going.. THEN, before you do your little query thing $query = "SELECT * FROM `tableName` WHERE `whatever` LIKE '%$whatever%'"; you wanna do $whatever = mysql_real_escape_string($whatever); $query = "SELECT * FROM `tableName` WHERE `whatever` LIKE '%$whatever%'"; you should apply mysql_real_escape_string in this fashion to EVERY variable which you are going to pass to a query, this way you avoid any errors in the future
-
use mysql_real_escape_string when you're doing SELECT * FROM `tableName` WHERE `whatever` LIKE '%$whatever%' if $whatever contains an apostraphy (?) " ' " the query will ultimately look like: SELECT * FROM `tableName` WHERE `whatever` LIKE '% whatever lol ' o%' which will terminate the ' too early, leaving extra characters outside of the ' which is causing you the error, this is what is known as "mysql injection" so you should ALWAYS secure your mysql queries with mysql_real_escape_string()
-
there is a much simpler way.. <? $het = new Array( "hello how are you?", "I said \"howdy partner\" and he said \"HELLO FRIEND!\"" ); $highlightArray = new Array("hello","howdy"); $with = new Array(); foreach ($highlightArray as $k => $v) { $with[$k] = "<b>".$v."</b>"; } $het = str_ireplace($highlightArray,$with,$het); ?>
-
php has com objects, you could use a com object connection to connect to the driver application and activate/retrieve data from it, however.. I never used com objects, and probably never will, but php.net has an example of how to communicate with microsoft word http://us2.php.net/manual/en/class.com.php
-
LIMIT 0,25 LIMIT 25,25 what you could do is.. LIMIT ((page - 1) * 25),25 that would do.. lets say page is 3 (3 - 1) = 2 2 * 25 = 50 start from 50 and get 25 rows.. being 51 - 75
-
d.shanker.. rewrites take requests and redirects either silently or fully (depending on structure). these will ofcourse affect your link solution.. try this arums <ifModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_URI} !^(?=.*?\.css).*$ RewriteRule ^source/electronics/?$ /?target=source&id=1 [L,QSA] </ifModule>
-
okay, nats Your server is a campus server.. this means that only computers on the SAME campus can access this via intranet.. now, unless your school is somehow EXACTLY where two time zones meet, than its pretty safe to say.. the server time will always be the server time.. wh ether uploaded from the guy in 1A or the girl in 2C. That being said.. whenever a file is uploaded.. set the `time` field to time() that will give a timestamp.. or you can do date("F jS, Y h:iA"); that will return something like June 3rd, 2008 12:32AM
-
idk about anybody else.. but that looks nice to me =o
-
$query = "UPDATE captions SET `image` = '{$file1name}', `caption` = '{$_POST['caption1']}' WHERE `image` = '{$file1name}'";
-
like nate suggests, there must be a user database where each user's information is stored.. E.G. Name, UserName, PassWord.. make everybody re-register.. but make a new field.. TimeZone field.. which would be like -5 -4 -3 -2 -1 0 1 2 3 4 5 than get your server's timezone, and calculate the difference.. either that.. or make your server's time the STANDARD time.. and let everybody know your server is for example.. -3GMT then when sum1 uploads it.. they'll know if they're -5GMT (like me) that if its 2:00 in the database for that file.. it was really uploaded @ 12:00.. furthermore.. instead of changing and shifting time, for each individual.. having 1 SET time, to gauge all the time measuring is more effective for a business/database anyway