-
Posts
3,584 -
Joined
-
Last visited
-
Days Won
3
Everything posted by JonnoTheDev
-
Cookie problem and yes i don't have any tags before the setcookie
JonnoTheDev replied to trasseli's topic in PHP Coding Help
how do you know there is no cookie set. have you tried to print the value setcookie("user", "joe bloggs", time()+3600); print $_COOKIE['user']; -
How to make PHP files Serve to ASP.Net files
JonnoTheDev replied to jagatworld's topic in PHP Coding Help
Yes If your using HTTP POST access the data using $_POST So as an example your asp file will post 4 bits of data and the php will add a user to the database if($_POST['action'] && $_POST['action'] == 'createacct') { $username = mysql_real_escape_string($_POST['username']); $password = mysql_real_escape_string($_POST['password']); $name = mysql_real_escape_string($_POST['name']); // connect to database and insert the new user $x = mysql_connect(); mysql_select_db(); mysql_query("INSERT INTO users....... } get the idea your form names / values action | createacct username password name -
If you have yum its easier yum install php-gd Then restart apache
-
if your files are wmv then how do you plan on displaying them?
-
This is not meant to display the image. It gets the filesize from the header. Why are you trying to display the image. I thought you were trying to check if a file exists / get the size of the file.
-
function getSizeFile($url) { if (substr($url,0,4)=='http') { $x = array_change_key_case(get_headers($url, 1),CASE_LOWER); if ( strcasecmp($x[0], 'HTTP/1.1 200 OK') != 0 ) { $x = $x['content-length'][1]; } else { $x = $x['content-length']; } } else { $x = @filesize($url); } return $x; } print getSizeFile("http://www.google.co.uk/intl/en_uk/images/logo.gif");
-
Yes you can use fopen() but only if the remote server allows this. What is wrong with checking the HTTP header with the URL as I said. Heres some code. Try it out: <?php function httpHeader($url) { $urlParts = parse_url($url); $fp = fsockopen($urlParts['host'],80,$errno,$errstr,10); $out = "GET ".$url." HTTP/1.1\r\n"; $out.= "Host: ".$urlParts['host']."\r\n"; $out.= "Connection: Close\r\n\r\n"; fwrite($fp,$out); $content = fgets($fp); return $content; } $url = "http://www.google.co.uk/intl/en_uk/images/logo.gif"; print httpHeader($url); ?>
-
Then I would use the HTTP status code to check the file exists. From the url http://yoursite,com/files/000.wmv - if it returns a 200 then the url is fine. If it returns a 404 then the file does not exist. Test it out here http://www.seoconsultants.com/tools/headers.asp Then write a PHP script to do it, not that hard.
-
how can you change session data after session_write_close ?
JonnoTheDev replied to koolaid's topic in PHP Coding Help
No, not at all. As my previous post. Once you call session_start() you have an active session. To add data to the session you simply use $_SESSION['name'] = "neil"; easy. No need to commit anything. If I want to overwrite that value: $_SESSION['name'] = "koolaid"; Just make sure that session_start() is at the top of all pages where you are using a session. Sessions remain persistent through all your pages until you destroy it or it times out: unset($_SESSION['name']); -
miles off. you have code within your echo statement. <?php if ($row_rs_positions['active'] == 'Yes') { do { echo '<div class="displayjobs"> <div class="jobheading"> <p><a href="careers.php?positionid='.ucwords($row_rs_positions['positionid']).'">'.ucwords($row_rs_positions['title']).'</a><strong> - <span class="style5">Added'.ucwords($row_rs_positions['date']).'</span></strong></p> </div> <div class="jobdesc"> <p>'.ucwords($row_rs_positions['summary']).'.... <a href="careers.php?positionid='.ucwords($row_rs_positions['positionid']).'">View Position</a></p> </div> </div>'; } while($row_rs_positions = mysql_fetch_assoc($rs_positions)); } else{ echo '<div class="jobopenings"><p align="center">Thank you for your interest in Laser Dynamics. Currently we do not have any job openings within The Company. We are, however, always accepting resumes and applications. If you would like to be considered for a future position here at Laser Dynamics, please submit a resume and application <a href="submitapp.php">here</a>.</p></div>'; } ?>
-
how can you change session data after session_write_close ?
JonnoTheDev replied to koolaid's topic in PHP Coding Help
Page 1 session_start(); $_SESSION['blah1'] = "whatever"; $_SESSION['blah2'] = "i love my dog"; Page 2 session_start(); $_SESSION['blah1'] = "whenever"; $_SESSION['blah2'] = "i love my cat"; That is it. session_id() not needed. Why you are throwing the session Id through the url I dont know -
how can you change session data after session_write_close ?
JonnoTheDev replied to koolaid's topic in PHP Coding Help
Why are you using this function? session_write_close(); Also session_start(); should be called prior to any other code -
To note, you should not be containing variables within quotes or object properties either. They are not printed strings. $AuthorID[$x][0]= "$row->created_by"; $AuthorID[$x][0]= $row->created_by;
-
file_exists() takes a server path not a url. Extract the filename from the url and specify the path i.e. /var/www/html/myfiles/media/00001.wmv
-
echo $i."<br />";
-
Instead of a counter $x as the array key use the authors id. $Authors[$row->id] = $row->name;
-
Again http://recaptcha.net/
-
Won't work. A simple delay would get past this. Bots are cleverer than this and designed to mimic a human. Bots usually read the form prior to submitting. Field names will be extracted. Math questions are the easiest to get through. Any other type of questions a real user may not know the answer to also. The best method is recaptcha http://recaptcha.net/
-
You will have to re-create your database on your new host.
-
At least its 15:45 in the UK, nearly home time, come on!
-
I find it more interesting fixing other peoples code than what i'm supposed to be working on at work right now.
-
Ill let you off this time
-
Again you are setting the array key to 0 Change to $i = 0; foreach($rows as $row) { echo "<li>$row->title ($row->publish_up)</li>"; $Authors[$i]= $row->created_by; echo "Author's id: $row->created_by"; $i++; }
-
This $out.'/$1/$2 change to $out.'/$1$2 Nearly there
-
You are setting the array key to 0 each time Change to $i = 0; foreach($rows as $row) { echo "<li>$row->title ($row->publish_up)</li>"; $Authors[$i]= "$row->created_by"; echo "Author's id: $row->created_by"; $i = $i + 1; }