Jump to content

zebe

Members
  • Posts

    24
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

zebe's Achievements

Member

Member (2/5)

0

Reputation

  1. Hi, I need to find the redirected or 'final' URL of an initial URL which has a 302 redirect in it. User goes to: www.1.com and gets redirected to www.2.com, I need to get 'www.2.com' I think this can be done using CURL. Here's what I have so far, which is returning the original link... /* * Get a web file (HTML, XHTML, XML, image, etc.) from a URL. Return an * array containing the HTTP server response header fields and content. */ function get_web_page( $url ) { $options = array( CURLOPT_RETURNTRANSFER => true, // return web page CURLOPT_HEADER => false, // don't return headers CURLOPT_FOLLOWLOCATION => true, // follow redirects CURLOPT_ENCODING => "", // handle all encodings CURLOPT_USERAGENT => "spider", // who am i CURLOPT_AUTOREFERER => true, // set referer on redirect CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect CURLOPT_TIMEOUT => 120, // timeout on response CURLOPT_MAXREDIRS => 10, // stop after 10 redirects ); $ch = curl_init( $url ); curl_setopt_array( $ch, $options ); $content = curl_exec( $ch ); $err = curl_errno( $ch ); $errmsg = curl_error( $ch ); $header = curl_getinfo( $ch ); curl_close( $ch ); //$header['errno'] = $err; // $header['errmsg'] = $errmsg; //$header['content'] = $content; print($header[0]); return $header; } Anyone know how I can modify this function to get the final redirected URL result? Thanks so much for the help. I really appreciate it.
  2. Hi, I was just wondering if anyone out there knew of a good tutorial, or method to figure out the users that are currently accessing an application, basically the way this forum does it. I have a database application where a session called username is instantiated after a user logs in. I was wondering if there is a way to determine all the active username sessions and display them to show which users are logged into the system? Any help would be appreciated!
  3. Changed the `acapella` column to a varchar(1) type, ran it again and got the same unknown column in where clause error...
  4. Yes it is called student_involvement. I can extract first name last name etc fine, but the problem arises when I try to do a where clause on the integer fields...
  5. Yes, I have a form that was placing data into the fields. If a user checked that activity it would store a 1 in the respective field, 0 otherwise. All the int fields are storing are basic binary true false data from checkboxes. When I browse, those fields have 0's and 1's in them, so there is data in there...
  6. Screenshot is attached [attachment deleted by admin]
  7. Just hardcoded it as requested and that is throwing the same error as well... Not sure what's up. The table exists and the columns do as well...
  8. Hi, I'm trying to run a query like the following example: [code] $activity = $HTTP_POST_VARS["activity"]; $sql = "SELECT first, last, email FROM student_involvement WHERE " . $activity . " = 1"; $result = mysql_query($sql) or die(mysql_error()); [/code] The variable $activity is pulling a column name from a predefined select list of activities. Each one of these fields is an int field and if it is true it will have a 1 false a 0. The query fails: SELECT first, last, email FROM student_involvement WHERE acapella = 1 EXPORT ERROR:Unknown column 'acapella' in 'where clause' Does anyone know why this is failing? The columns exist, I can pull general data from that table, but it seems to throw errors when I try to implement a WHERE clause... Thanks for all of your help in advance![b][/b]
  9. None of these techniques seem to work. When I have 14:00:00 initially, I get 14:30:00, not 13:30:00 as desired... Any other ideas? Thanks again for your help!
  10. Hi, I have a variable that is storing a time value that has been retrieved from a database. It is in the format of: HH:MM:SS. What i need to do is subtract a half hour from this value, does PHP have any way of doing this? I was thinking about using explode to get the hours and seconds and then using conditionals to determine how to reformatt it, but that seems bulky to me... Just wondering if anyone has a more efficient solution. Thanks for the help!
  11. Hi, I am writing a script that needs to sort by a field which contains a time value. I need to sort it in order of earlies to latest. The field type is a varchar. People have been putting in am/pm characters in this field as well and when I go to sort it comes out something like this: 8:45am 8:45am 8:45am 9:15am 9:30am 9:30am 9am 9am In my query I have the following: [code]ORDER BY REPLACE(bus_leaves_uri, ':', '')" [/code] I was trying to take out the ":" thinking that was the problem with the ordering. Does anyone know a better mysql function that will actaully sort this type of data correctly? Thanks for any help!
  12. zebe

    Cast() Question

    Thanks! That is indeed the problem... Anyone know a "hack" around the CAST() version problem? I'm running MySQL 3.23.40
  13. Hi, I am working on a database that has a table of class sections. Within this table there is a field called section code, i.e. the class number. Normally I would have made this field have type int, but I needed to make it a varchar field because there are about 6 sections that have non numerical section codes. On the original server I was able to order by using the CAST() function on the section_code field: [code]$sql = "SELECT id, section_code, instructor, ins_email, ins_phone, mentor_1, mentor_2, mentor_1_email, mentor_2_email, day_time, location, LC_focus FROM uri_101_sections ORDER BY CAST(section_code as unsigned) "; [/code] I just recently moved this database to a new server and it no longer functions in the same way, in fact I get the following error: [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]You have an error in your SQL syntax near '(section_code as unsigned) ' at line 2[/quote] Does anyone know why this could be occurring or have an alternate solution for this problem? Thank you so much for any help, I appreciate it!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.