markvaughn2006
Members-
Posts
108 -
Joined
-
Last visited
Everything posted by markvaughn2006
-
Please help me, I can't figure this out.. If a user's input is- "Hello my name is Mark and I want to make http://news-libraries.mit.edu/blog/wp-content/uploads/2008/01/money.jpg" How would i make it output "Hello my name is Mark and I want to make (display the picture)" I can find the image link with- https?://[\w./]+\/[\w./]+\.(bmp|png|jpg|gif) just not sure how to tie it all together, any help would be greatly appreciated even if it's just point my me in the right direction! Thanks guys
-
sorry .... here it is <?php function makeClickableLinks($text) { $text = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)', '<a href="\\1">\\1</a>', $text); $text = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_\+.~#?&//=]+)', '\\1<a href="http://\\2">\\2</a>', $text); $text = eregi_replace('([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})', '<a href="mailto:\\1">\\1</a>', $text); return $text; }?> to use - echo makeClickableLinks($text); messy but you can figure it out
-
Ok, just gotta post this, this has got to be the easiest least frustrating way to do this.. <?php function makeClickableLinks($text) { $text = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)', '<a href="\\1">\\1</a>', $text); $text = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_\+.~#?&//=]+)', '\\1<a href="http://\\2">\\2</a>', $text); $text = eregi_replace('([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})', '<a href="mailto:\\1">\\1</a>', $text); return $text; } much easier than i expected!
-
sorry for being such a noob.. but how do i echo a users input and allow hyperlinking?? Right now if a person puts http://example.com somewhere in their message you can't click on it...thanks for any help
-
Thanks for the help! but would there be any way to just capture the last result in a variable? Like if the results were: (122,121,119,118,115,110,109,107,106,104) Capture 104 into a variable and then on the next page just use ORDER BY timemsg DESC LIMIT 104,10 to show the next 10 results with a lower value than 104?? Thanks again!!
-
Ok I know how to display the first or last 10 results of a query... $result = mysql_query("SELECT * FROM messages ORDER BY timemsg DESC LIMIT 10"); In a perfect world all the rows ID's would be in perfect order (i.e.- 10,9,8,7,6,5,4,3,2,1), so to display messages 30 to 40 I would just do LIMIT 30,10 but because of certain unforseen situations the actual results will end up being more like- 457 455 454 453 449 448 447 419 418 410 So I can display the last 10 results in descending order but then to show the "previous 10" results (using the above numbers for an example), I'm thinking I need to somehow capture the last result in this query (410) so when you hit "previous 10" link it passes it through GET to the next page and the next page will use something like LIMIT $start,10 to display the 10 results with before "410" and so on. Any idea how to do this, I don't think it should be that hard, just can't figure it out. Sorry, if this is in wrong thread, feel free to move to MYSQL board if it belongs there.. Thanks for any help!!
-
aha!...thats putting me on the right path! Resolved...for now.
-
whoops... here is the code <?php $resultfav = mysql_query("SELECT * FROM favorites WHERE owner='$username'") or die(mysql_error()); while ($rowfav = mysql_fetch_array($resultfav)) { echo '<form target="_self" method="post" action="board.php"><input type="submit" value="Go" />'." - ".ShortenText($rowfav['board']).'<input type="hidden" name="boardtitle" value="'.$rowfav['board'].'" /></form>'; } ?> What I'm trying to do is make it like if you click on my name on phpfreaks it will take you to my profile, so.. you click on the board title on my site and it will take you to that board, but there is no url to take you directly there so it will have to go to board.php and use the posted board title to select * from that board and display it.
-
I'm making a custom forum, the below code displays all of a user's favorite boards with a submit button next to it to take them to that board. How could i get rid of the submit button and make the board title be clickable and post the value $rowfav['board']?? thanks in advance!! <?php $resultfav = mysql_query("SELECT * FROM favorites WHERE owner='$username'") or die(mysql_error()); while ($rowfav = mysql_fetch_array($resultfav)) { echo '<form target="_self" method="post" action="board.php"><input type="submit" value="Go" />'." - ".ShortenText($rowfav['board']).'<input type="hidden" name="equip" value="'.$rowfav['item_name'].'" /></form>'; } So ideally, it would display all the board titles and when you click the title, it will take them to board.php which will display info about the board and will know what board it is through posting the board title ?>
-
Post Request w/ Socket Connection
markvaughn2006 replied to markvaughn2006's topic in PHP Coding Help
anyone?? please!! -
I'm pretty noob so please don't kill me I'm trying to track my websites search rank in google, I know there are others ways to do this but I really need to do it like this if possible.. so in the below example, where would i put http://google.com/ and where would i put what I'm searching for?? is google.com the host? and the search the path? If i can get the results i'm pretty sure i can extract the info i'm looking for, just not really sure about the whole socket thing... THANK YOU!!!! <?php /* ** The function: */ function PostRequest($url, $referer, $_data) { // convert variables array to string: $data = array(); while(list($n,$v) = each($_data)){ $data[] = "$n=$v"; } $data = implode('&', $data); // format --> test1=a&test2=b etc. // parse the given URL $url = parse_url($url); if ($url['scheme'] != 'http') { die('Only HTTP request are supported !'); } // extract host and path: $host = $url['host']; $path = $url['path']; // open a socket connection on port 80 $fp = fsockopen($host, 80); // send the request headers: fputs($fp, "POST $path HTTP/1.1\r\n"); fputs($fp, "Host: $host\r\n"); fputs($fp, "Referer: $referer\r\n"); fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n"); fputs($fp, "Content-length: ". strlen($data) ."\r\n"); fputs($fp, "Connection: close\r\n\r\n"); fputs($fp, $data); $result = ''; while(!feof($fp)) { // receive the results of the request $result .= fgets($fp, 128); } // close the socket connection: fclose($fp); // split the result header from the content $result = explode("\r\n\r\n", $result, 2); $header = isset($result[0]) ? $result[0] : ''; $content = isset($result[1]) ? $result[1] : ''; // return as array: return array($header, $content); } /* ** The example: */ // submit these variables to the server: $data = array( 'test' => 'foobar', 'okay' => 'yes', 'number' => 2 ); // send a request to example.com (referer = jonasjohn.de) list($header, $content) = PostRequest( "http://www.example.com/", "http://www.jonasjohn.de/", $data ); // print the result of the whole request: print $content; // print $header; --> prints the headers ?>
-
This is for work actually (geek squad). We have to fill out this online php form at work over and over again to set up these new laptops, we log on to this website and have to select all this stuff. I was wondering if there is a way that I could set up a php page/code on one of my websites so that when you went to it, it would redirect you to the geeksquad website/form AND fill out the page with the info?? Possible? if so, how?? Thank you guys so much, you have been extremely beneficial and helpful!!!!
-
[SOLVED] rand (1000, 1025)(2000,2025)(3000,3025)
markvaughn2006 replied to markvaughn2006's topic in PHP Coding Help
cool thanks, that'll work!! -
On the rand() function is there a way to have it pick a random number between say... 1000-1025 AND 2000-2025 AND 3000-3025, etc... so possible outcomes could be 2014, 1023, 1005, 3002, etc... all from this one rand() I know thats weird , just have a specific reason for wanting to do this... Thanks in advance!!
-
DOH! thanks man.....
-
This one has really got me stumped... I need to display everybody with the location =$userlocation and wanted_lvl=1. But.. I need to also somehow include an IF that will check a field from the mysql query against a field in the logged in users row.. So what this boils down to is I need to display everyone who's location equals $userlocation and wanted_lvl equals 1 but only show the people that who have less "stealth" than the logged in user has "vision". So it would show some people who have a lower stealth than your vision but it wouldn't show the people that have a higher stealth than your vision. <?php $result = mysql_query("SELECT user_name, location_message FROM users_tbl WHERE location='$userlocation' AND wanted_lvl='1'") or die(mysql_error()); while ($row = mysql_fetch_array($result)) { echo '<form target="actions" method="post" action="includes/report.php"><input type="submit" value="Report" /><font color="red">'.$row['user_name'].'</font><input type="hidden" name="reported" value="'.$row['user_name'].'" /></form>'; } ?> Thanks for any help!! Sorry if this in the wrong forum, but it's more the php than the mysql i'm having a problem with
-
i guess the problem i'm having is actually because its a two part loop....i'm trying to recreate this from memory,(at school atm..) i think i'm approaching this problem the wrong way too... I'm making a game, where you get energy every x minutes...so.. if you use up all your energy and then don't sign back in till like a week later or something it will check your refill time to see if it is less than time(), if it is then it will add 3600 to your refill time and give you 10 energy, but the refill time will still be less than time() so it needs to keep checking if refill time < time() and while it is add 3600 to refill time && add 10 to energy...the way i have it set up now, it doesn't loop so really in this situation everytime you refresh it will add 10 to your energy and add an hour to your refill time until either max energy or refill time> time()... but when i tried to do the while loop for this, the page would just go white, and look like it got stuck... any idea? maybe there is a smarter way to do this?? thanks for helping!! i'll post more specific if still not solved when i get home
-
I'm using godaddy hosting, and like a dumba$$ i've been working with one db on one hosting account and another db on a different hosting account, it works totally fine but I am wanting to drop one of my accounts, so i need to transfer one of the db's. I exported said db in sql format and then created a new db on the hosting that i want to keep, then when i hit import and selected the sql file i downloaded, it gave me all kinds of errors saying it couldn't access the db, or something, excuse me i know i'm committing a cardinal sin by not providing the exact error to you, but i have no idea how to transfer, can someone that uses godaddy give me a point in the right direction to accomplish what I'm trying to do?? Thanks guys!
-
I'm sure this is childsplay but it is stumping me, everytime i try what I think would make this work, the page hangs... what am i doing wrong here?? <?php $number = 5; ?> <?php while ($number < 10){ $number = $number + 1} ?> <?php echo $number //hoping for it to be 10 ?> before you ask, i'm trying to figure out the principal to make this work, I'm not actually trying to make a number less than 10 become 10, but I need to know how to make this work to do some things. Thanks!!
-
cool thanks!
-
cool it worked! thanks a lot!! Whats the reason for.. "You should also wrap myusername in single quotes (it's not a constant, am I right?), and then wrap the whole session variable in curly brackets."?? and no it is not a constant
-
How do you echo a link in a variable form while? Thanks guys!! <?php $result = mysql_query("SELECT * FROM locations WHERE owned='$_SESSION[myusername]'") or die(mysql_error()); while ($row = mysql_fetch_array($result)) { echo "<a href="$row['link']">$row['title']</a>"; echo "<br/>"; } ?> ERROR is... Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/properties.php on line 175
-
Is there a way to use a custom submit button instead of the regular html form button?? AND is there a way to have all the functionality of the code below but instead of having a submit button, there is a <a href link?? Thanks for any help!! <?php echo '<form target="remove link" method="post" action="sub/removelink.php"><input type="submit" value="Remove" />'.$row['quicklinktitle1'].'<input type="hidden" name="remove" value="'.$row['quicklinktitle1'].'" /></form>'; ?>
-
omg i'm an idiot...auto increment was not set. Sorry for wasting your time and thanks for helping me...lol
-
the columns for my events table are (id, type, from, to, time) my intended command is... <?php mysql_query("INSERT INTO events (type, from, to, time) VALUES('$type', '$from', '$to', '$time' ) ") or die(mysql_error()); ?> and the error is... Duplicate entry '0' for key 1 I don't want to have to define the "id" field since it is the primary key, not null, auto incrementing field. Do I have to do some kind of 'count' command and add 1 to the highest number in the 'id' column and then insert some kind of $nextid variable that is the higest id+1?? Thanks for any help, I didn't really think this would be stumping me like this...