-
Posts
86 -
Joined
-
Last visited
Contact Methods
-
Website URL
http://www.lancaster-web-designer.co.uk
Profile Information
-
Gender
Male
-
Location
UK
mat3000000's Achievements

Member (2/5)
0
Reputation
-
Absolutely perfect script, worked a treat. Thanks!
-
Hi, I think there should be a very easy way to do what I want to do. I just can't think of it! I have the number of pages returned in a variable called $pages. I want to add a link to every page like at the bottom of google. Example, there are three pages, links echoed like: 1 2 3 Thanks in advance
-
Using the 'Less Than' symbol in query problem
mat3000000 replied to mat3000000's topic in MySQL Help
Thank You, I am now using 'HAVING' and it seems to work fine. -
I have a query to search jobs. It also works out the distance from the user to the job: SELECT ((ACOS(SIN('$b_lat' * PI() / 180) * SIN(`lat` * PI() / 180) + COS('$b_lat' * PI() / 180) * COS(`lat` * PI() / 180) * COS(('$b_long' - `long`) * PI() / 180)) * 180 / PI()) * 60 * 1.1515) AS `distance`,username,sector,job,pay,reqexp, jobtime, hours, hourscat,days,description FROM `jobs` WHERE sector='$sector' AND job='$job' AND validated='1' AND `distance` < 80 ORDER BY `distance` DESC; I am getting an error when running this, however, when I remove the "AND `distance` < 80" clause it works fine. Whats the problem here??
-
It will add the 'FILES' folder if it isn't there, but just refreshes the page, displaying no errors, without adding anything to the folder??? As you can probably see I have three file slots for users, I want to fill the next available slot up, and if no slots, display error 2 ($e=2; - Delete a file to make space) //^^GET VARIABLES SUCH AS USERNAME ETC. if(isset($_POST['uploadfile'])){ if(is_dir("files/$username/FILES/")){}else{mkdir("files/$username/FILES/");} if (is_uploaded_file($_FILES['file']['tmp_name'])) { $name = $_FILES['file']['name']; if ($file != "application/pdf" || substr(strrchr($file, '.'), 1) != "pdf" || substr(strrchr($file, '.'), 1) != "jpg" || $file != "image/jpeg" || $file != "image/pjpeg") { $errors[] = 'File must be in PDF or JPEG format'; } else if($_FILES['file']['size'] > 256000){$errors[] = 'File must be under 250KB';} else { $name1 = substr($name, 0, strrpos($name, '.')); $ext = strtolower(substr(strrchr($name, '.'), 1)); $name = $name1.'.'.$ext; $res = mysql_query("SELECT username,file1,file2,file3 FROM `files` WHERE `username`='$username'"); $row = mysql_fetch_array($res); $f1 = $row['file1']; $f2 = $row['file2']; $f3 = $row['file3']; if($f1==''){ $result = move_uploaded_file($_FILES['file']['tmp_name'], "files/$username/FILES/$name"); if ($result == 1){ $time = time(); $t=1; mysql_query("UPDATE files SET file1='$name', file1_val='0', file1_added='$time' WHERE username='$username'"); }else $e=1; }else if(empty($f2)){ $result = move_uploaded_file($_FILES['file']['tmp_name'], "files/$username/FILES/$name"); if ($result == 1){ $time = time(); $t=1; mysql_query("UPDATE files SET file2='$name', file2_val='0', file2_added='$time' WHERE username='$username'"); }else $e=1; }else if(empty($f3)){ $result = move_uploaded_file($_FILES['file']['tmp_name'], "files/$username/FILES/$name"); if ($result == 1){ $time = time(); $t=1; mysql_query("UPDATE files SET file3='$name', file3_val='0', file3_added='$time' WHERE username='$username'"); }else $e=1; }else{$e=2;} } } }
-
Ahh, OK.
-
I'm guessing there isn't a way then?
-
Probably your best way is to just delete the whole folder with: public static function deleteDir($dirPath) { if (! is_dir($dirPath)) { throw new InvalidArgumentException('$dirPath must be a directory'); } if (substr($dirPath, strlen($dirPath) - 1, 1) != '/') { $dirPath .= '/'; } $files = glob($dirPath . '*', GLOB_MARK); foreach ($files as $file) { if (is_dir($file)) { self::deleteDir($file); } else { unlink($file); } } rmdir($dirPath); } Or something similar, then remake the folder using mkdir(); Sorry if this isn't the answer you were looking for, but I didn't understand your question really.
-
I have a site where a user can upload a PDF CV file. Before it is published I want it to be moderated using simple whiteout boxes. I want to page where an admin can view/edit the PDF and save it in one click (+ send user email + Set record in DB to '1') without downloading it, so obviously it has to be on my server. I have to use PHP. I have a linux server. I could do the solution in ASP using http://www.pdfescape.com/webmasters/ but is there a solution for PHP?
-
Getting This Error, anyone know why? (Line 410 is the line after my page code ends) Here is my code... function URL() { $pageURL = 'http'; if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";} $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; } else { $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; } return $pageURL; } $url = URL(); if(empty($errors)){ $sort = $_GET['sort']; $s = $_GET['s']; $limit=15; if($sort == 'Distance') {$query = "SELECT ((ACOS(SIN('$b_lat' * PI() / 180) * SIN(`lat` * PI() / 180) + COS('$b_lat' * PI() / 180) * COS(`lat` * PI() / 180) * COS(('$b_long' - `long`) * PI() / 180)) * 180 / PI()) * 60 * 1.1515) AS `distance`,username,sector,job,description,pay,reqexp, jobtime, hours, hourscat FROM `staff` WHERE sector='$sector' AND job='$job' "; if(!$hrs==''){$query .= "AND hourscat='$hrs' "; if(!$pay==''){$query .= "AND pay>='$pay' "; if(!$jobtime==''){$query .= "AND jobtime='$jobtime' "; $query .= "ORDER BY `distance` DESC"; } $numresults=mysql_query($query); $numrows=mysql_num_rows($numresults); // If we have no results if ($numrows == 0) { $rslts = "<br /><tr><td>Sorry, there are currently no customer advertisements on our system</td></tr>"; } if ($numrows > 0){ // next determine if s has been passed to script, if not use 0 if (empty($s)) { $s=0; } //Get Results $query .= " limit $s,$limit"; $result = mysql_query($query) or die("The search failed"); // begin to show results set $count = 1 + $s ; $rslts = ''; // now you can display the results returned while ($row= mysql_fetch_array($result)) { $username = $row['username']; $sector = $row['sector']; $job = $row['job']; $desc = $row['decription']; $exp = $row['reqexp']; $pay = $row['pay']; $jobtime = $row['jobtime']; $hours = $row['hours']; $distance = round($row['distance'],1); $rslts .= "<br /><table class='profilebox' style='padding:10px;'> <tr> <td width='120' height='120' align='center'><a href='viewjob.php?user=$username' style='border:none;'> <img src='/bus/files/$username/profilepic/tn_profilepic.jpg'</td> <td width='40'> </td> <td width='190'> $sector - $job<br /><br /><br /> Experience Required: $exp years<br /><br /> Pay: £$pay /hr<br /></td> <td width='40'> </td> <td width='70'><br /><br /><br />Hours: £$hours<br />Job Time: $jobtime</td> <td width='40'> </td> <td valign='bottom' align='right' width='160'> Distance: $distance miles </td> </tr> </table> "; $count++ ; } $currPage = (($s/$limit) + 1); //break before paging $rslts .= "<br />"; // next we need to do the links to other results if ($s>=1) { // bypass PREV link if s is 0 $prevs=($s-$limit); $prree ="<b><a class='np' href='$url&s=$prevs'><< Previous Page</a></b>   "; } // calculate number of pages needing links $pages=intval($numrows/$limit); // $pages now contains int of pages needed unless there is a remainder from division if ($numrows%$limit) { // has remainder so add one page $pages++; } // check to see if last page if (!((($s+$limit)/$limit)==$pages) && $pages!=1) { // not last page so give NEXT link $news=$s+$limit; $nachste = "<b><a class='np' href='$url&s=$news'>Next Page >></a></b>"; } $a = $s + ($limit) ; if ($a > $numrows) { $a = $numrows ; } $b = $s + 1 ; $pages123 = "<table width='93%' align='center'><tr><td height='30' valign='bottom'><p class='np'> $prree $nachste </p><p style='font-size:10px;'>Showing results $b to $a of $numrows</p></td></tr></table>"; } echo $pages123 . $pageslist . $rslts . $pages123; }//end $numrows >0 ?>
-
mysql real escape sting HELP + Text area line break help???
mat3000000 replied to mat3000000's topic in PHP Coding Help
Thanks for your help. Just for the record I am using this to turn off magic quotes: if (get_magic_quotes_gpc()) { $process = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST); while (list($key, $val) = each($process)) { foreach ($val as $k => $v) { unset($process[$key][$k]); if (is_array($v)) { $process[$key][stripslashes($k)] = $v; $process[] = &$process[$key][stripslashes($k)]; } else { $process[$key][stripslashes($k)] = stripslashes($v); } } } unset($process); } and I am using htmlentities() and nl2br() which seemed to work. Thank You!!!! -
mysql real escape sting HELP + Text area line break help???
mat3000000 replied to mat3000000's topic in PHP Coding Help
I do not host on my own server, is here a function I can use that will simulate it being off? -
I am having problems with these slashes. They keep showing up when I echo data.... The code is to update a field in a mysql database table. Here is my code: $query = mysql_query("SELECT * FROM `bus` WHERE username='$username'"); $row = mysql_fetch_array($query); $bio = $row['about']; $bio = str_replace("<br />","\r\n",$bio); if(isset($_POST['submit'])){ if(empty($errors)){ if($password == $pass){ $about1 = mysql_real_escape_string($_POST["about"]); $about1 = str_replace("\r\n","<br />",$about1); mysql_query("UPDATE bus SET about='$about1' WHERE username='$username'"); }else{$errors[] = 'Incorrect Password';} } } When I run this and put: About: I'm very tired today It's been very hard I get the about1 string as: I\\\'m very tired today\r\nIt\\\'s been very hard Why???
-
Reading Image Code And Storing In Database
mat3000000 replied to N-Bomb(Nerd)'s topic in PHP Coding Help
I looked into this a while ago and found it very annoying. I then reverted to the method I currently use on my site. Simply store the image in a directory on your server, if you are uploading the function you would use would be move_uploaded_file(), then you can get the images in one array from a whole directory using the glob() function with *.jpg Look up a file upload tutorial on google, they are everywhere and most will use this method.