Jump to content

andrew_biggart

Members
  • Posts

    363
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by andrew_biggart

  1. Well preferable I would like the job numbers to be sequential for each category. Basically A user will enter a job into a txt box select a category and submit the job to a database. A unique sequential job number should then be created like this category-123456.
  2. Yes I have looked into it now. I have used this <?php echo str_pad("456", 6 , "0"); ?> which displays 456000 but how would I make it display 000456?
  3. But then you could end up with a six digit number and the 0's padded infront to of it. (0000023456) I just want my auto increment to start at 000001 and add one every time it adds a new record.
  4. I would like to create a Job Numbering system for all of my jobs. Job number format : print-001232 I would like the job numbers to be sequential. So we will have a drop down list with three categories. which will form the first part of the job number. (print- ) and then I would like the 6 digits after it to be sequential starting from 000001. What is the best way of going about doing this?
  5. Ok I have got this but it is just displaying an infinite amount of the same tweet. Help Please? <?php $username = "la__academia"; $limit = "2"; $twitter_url = "http://twitter.com/statuses/user_timeline/$username.xml?count=$limit"; $buffer = file_get_contents($twitter_url); $xml = new SimpleXMLElement($buffer); $status_item = $xml -> status; $statuses = $xml -> statuses; $count= count(array($statuses)); $status_id = $xml -> status -> id; $user_item = $xml -> status -> user; $user_id = $xml -> status -> user -> screen_name; $description = $status_item -> text; $status_time = $status_item -> created_at; $status_img = $user_item -> profile_image_url; $description = preg_replace("#(^|[\n ])([\w]+?://[\w]+[^ \"\n\r\t< ]*)#", "\\1<a href=\"\\2\" target=\"_blank\">\\2</a>", $description); $description = preg_replace("#(^|[\n ])((www|ftp)\.[^ \"\t\n\r< ]*)#", "\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>", $description); $description = preg_replace("/@(\w+)/", "<a href=\"http://www.twitter.com/\\1\" target=\"_blank\">@\\1</a>", $description); $description = preg_replace("/#(\w+)/", "<a href=\"http://search.twitter.com/search?q=%23\\1\" target=\"_blank\">#\\1</a>", $description); while ($count <= $limit) { echo " <div class='tweet-wrapper'> <div class='tweet-img'> <a href='http://www.twitter.com/la__academia' target='_BLANK'><img src='$status_img' alt='La Academia Twitter' style='width:30px height:30px;' /></a> </div><!-- tweet-img --> <div class='tweet-text'> <p class='tweet-p'>$description</p> <p class='tweet-time'>$status_time . <a href='http://twitter.com/?status=@$user_id%20&in_reply_to_status_id=$status_id&in_reply_to=$user_id' target='_BLANK' class='tweet-reply'>Reply</a></p> </div><!-- tweet-text --> <div class='cleaner'></div> </div><!-- tweet-wrapper --> "; } ?>
  6. Sorry to bump this but it has had 17 views and not one reply or solution.
  7. Everything you need is on this website. Just follow that tutorial step by step and you will get it working. Any issues just google it. For the registration form use this tutorial http://www.phpeasystep.com/phptu/15.html. If you are happy with this solution please click solved
  8. You will find everything you need here! http://www.phpeasystep.com/phptu/6.html
  9. What about this? <?php mysql_connect("localhost", "lee", "leecopter"); mysql_select_db("lee"); $username = mysql_real_escape_string($_POST['username']); $check = mysql_query("SELECT username FROM users WHERE username='$username'"); $check_num_rows = mysql_num_rows($check); if (strlen($username)<=1) echo "Choose a username"; else if (strlen($username)<=3) echo "Username is too short"; else { if ($check_num_rows==0) echo "Username is availible!"; else if ($check_num_rows==1) echo "Username has already been taken"; } ?>
  10. Try this <?php mysql_connect("localhost", "lee", "leecopter"); mysql_select_db("lee"); $username = mysql_real_escape_string($_POST['username']); $check = mysql_query("SELECT username FROM users WHERE username='$username'"); $check_num_rows = mysql_num_rows($check); if ($username=="") echo "Choose a username"; else if (strlen($username)<=3) echo "Username is too short"; else { if ($check_num_rows==0) echo "Username is availible!"; else if ($check_num_rows==1) echo "Username has already been taken"; } ?>
  11. Can you post your code on here? Its easier to read that way. Also have a look at this post http://www.phpfreaks.com/forums/php-coding-help/adding-a-count-and-while-loop-using-xml-data/ of my mine and see if you can solve my issue while I try and solve yours. Thanks
  12. Hi I have currently written some code which uses of the Twitter API and extracts the information required to display my most current tweet on my website. This is all working perfectly but at the minute it is only displaying one tweet and I would like it to display as many as the variable $limit is set to. I have tried numerous count with while loops but just cannot seem to get my head around the logic of it. Here is the code im currently using which displays one tweet. <?php $username = "my_twitter_username"; $limit = "2"; $twitter_url = "http://twitter.com/statuses/user_timeline/$username.xml?count=$limit"; $buffer = file_get_contents($twitter_url); $xml = new SimpleXMLElement($buffer); $status_item = $xml -> status; $status_id = $xml -> status -> id; $user_item = $xml -> status -> user; $user_id = $xml -> status -> user -> screen_name; $description = $status_item -> text; $status_time = $status_item -> created_at; $status_img = $user_item -> profile_image_url; $description = preg_replace("#(^|[\n ])([\w]+?://[\w]+[^ \"\n\r\t< ]*)#", "\\1<a href=\"\\2\" target=\"_blank\">\\2</a>", $description); $description = preg_replace("#(^|[\n ])((www|ftp)\.[^ \"\t\n\r< ]*)#", "\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>", $description); $description = preg_replace("/@(\w+)/", "<a href=\"http://www.twitter.com/\\1\" target=\"_blank\">@\\1</a>", $description); $description = preg_replace("/#(\w+)/", "<a href=\"http://search.twitter.com/search?q=%23\\1\" target=\"_blank\">#\\1</a>", $description); echo " <div class='tweet-wrapper'> <div class='tweet-img'> <a href='http://www.twitter.com/la__academia' target='_BLANK'><img src='$status_img' alt='La Academia Twitter' style='width:30px height:30px;' /></a> </div><!-- tweet-img --> <div class='tweet-text'> <p class='tweet-p'>$description</p> <p class='tweet-time'>$status_time . <a href='http://twitter.com/?status=@$user_id%20&in_reply_to_status_id=$status_id&in_reply_to=$user_id' target='_BLANK' class='tweet-reply'>Reply</a></p> </div><!-- tweet-text --> <div class='cleaner'></div> </div><!-- tweet-wrapper --> "; ?> Thanks for any help.
  13. You can ignore this as I havn't included the function. $date = strtotime($status_item -> created_at); $dayMonth = date('d M', $date); $year = date('y', $date); $message = $row['content']; $datediff = date_diff($theDate, $date);
  14. Ok never mind that last post I have solved all of the I've issues by doing everything a different way. If you are interested I will post the working code below. <?php $username = "la__academia"; $limit = "2"; $twitter_url = "http://twitter.com/statuses/user_timeline/$username.xml?count=$limit"; $buffer = file_get_contents($twitter_url); $xml = new SimpleXMLElement($buffer); $status_item = $xml -> status; $user_item = $xml -> status -> user; $description = $status_item -> text; $status_time = $status_item -> created_at; $status_img = $user_item -> profile_image_url; $description = preg_replace("#(^|[\n ])([\w]+?://[\w]+[^ \"\n\r\t< ]*)#", "\\1<a href=\"\\2\" target=\"_blank\">\\2</a>", $description); $description = preg_replace("#(^|[\n ])((www|ftp)\.[^ \"\t\n\r< ]*)#", "\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>", $description); $description = preg_replace("/@(\w+)/", "<a href=\"http://www.twitter.com/\\1\" target=\"_blank\">@\\1</a>", $description); $description = preg_replace("/#(\w+)/", "<a href=\"http://search.twitter.com/search?q=%23\\1\" target=\"_blank\">#\\1</a>", $description); $date = strtotime($status_item -> created_at); $dayMonth = date('d M', $date); $year = date('y', $date); $message = $row['content']; $datediff = date_diff($theDate, $date); echo "<p><img src='$status_img' alt='profile pic' /> $status_time<br /> $description</p>"; ?> What I would like to do is add a while loop to this code now so that I can get as many tweets as is set in the $limit variable. At the minute the minute it is only displaying 1 tweet at a time. Thanks in advance.
  15. Hi, I have got a problem with pulling tweets from twitter. It is currently working to an extent but I'm trying to do a str_replace so that I can convert characters like "&lt" into "<" etc. But at the moment it is still displaying the "&lt" instead of "<" what am I doing wrong? I am using the following code to fetch and display my tweets. <?php $username = "la__academia"; $limit = "2"; // Number of tweets to pull in. /* These prefixes and suffixes will display before and after the entire block of tweets. */ $prefix = "<a href='http://www.twitter.com/la__academia' class='twitter-link'>La Academia Tweets</a>"; // Prefix - some text you want displayed before all your tweets. $suffix = ""; // Suffix - some text you want displayed after all your tweets. $tweetprefix = "<p>"; // Prefix - some text you want displayed before each tweet. $tweetsuffix = "</p><span class='tweet-sep'></span>"; // Suffix - some text you want displayed after each tweet. $feed = "http://search.twitter.com/search.atom?q=from:" . $username . "&rpp=" . $limit; function parse_feed($feed, $prefix, $tweetprefix, $tweetsuffix, $suffix) { $feed = str_replace ("<", "<", $feed); $feed = str_replace (">", ">", $feed); $feed = str_replace (""", "\"", $feed); $feed = str_replace ("'", "'", $feed); $clean = explode ("<content type=\"html\">", $feed); $amount = count($clean) - 1; echo $prefix; for ($i = 1; $i <= $amount; $i++) { $cleaner = explode("</content>", $clean[$i]); echo $tweetprefix; echo $cleaner[0]; echo $tweetsuffix; } echo $suffix; } $twitterFeed = file_get_contents($feed); parse_feed($twitterFeed, $prefix, $tweetprefix, $tweetsuffix, $suffix); ?> I would also like to know how to get the and display the time etc for the tweet. Thanks Andrew
  16. I have also checked the file permissions of all the folders and they are all 777!!!
  17. Ok I have removed the @ but I am still getting the same thing, Error while uploadin your image! Please try again! So the image is not saving but why?
  18. Ok I have finally got rid of my syntax errors with this upload script. Now im getting the error uploading your image. My folders are called project_files and project_thumbs. This is my script <?php $results = ""; error_reporting(E_ALL); ini_set("display_errors", 1); //Auto Thumbnail Function function create_thumbnail($source,$destination, $thumb_width) { $size = getimagesize($source); $width = $size[0]; $height = $size[1]; $x = 0; $y = 0; if($width> $height) { $x = ceil(($width - $height) / 2 ); $width = $height; } elseif($height> $width) { $y = ceil(($height - $width) / 2); $height = $width; } $new_image = imagecreatetruecolor($thumb_width,$thumb_width) or die('Cannot initialize new GD image stream'); $extension = get_image_extension($source); if($extension=='jpg' || $extension=='jpeg') $image = imagecreatefromjpeg($source); if($extension=='gif') $image = imagecreatefromgif($source); if($extension=='png') $image = imagecreatefrompng($source); imagecopyresampled($new_image,$image,0,0,$x,$y,$thumb_width, $thumb_width,$width,$height); if($extension=='jpg' || $extension=='jpeg') imagejpeg($new_image,$destination); if($extension=='gif') imagegif($new_image,$destination); if($extension=='png') imagepng($new_image,$destination); } //Get Extension Function function get_image_extension($name) { $name = strtolower($name); $i = strrpos($name,"."); if (!$i) { return ""; } $l = strlen($name) - $i; $extension = substr($name,$i+1,$l); return $extension; } //Random Name Function function random_name($length) { $characters = "abcdefghijklmnopqrstuvwxyz01234567890"; $name = ""; for ($i = 0; $i < $length; $i++) { $name .= $characters[mt_rand(0, strlen($characters) - 1)]; } return "image-".$name; } $images_location = "/project_files/"; $thumbs_location = "/project_thumbs/"; $thumb_width = "100"; $maximum_size = "5000000"; //Check And Save Image if($_POST) { if($_FILES['image']['name'] == ""){ $results = "Please select the image you would like to upload by clicking browse"; } else{ $size=filesize($_FILES['image']['tmp_name']); $filename = stripslashes($_FILES['image']['name']); $extension = get_image_extension($filename); if($size > $maximum_size) { $results = "Your file size exceeds the maximum file size!"; } else if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) { $results = "Only the following extensions are allowed. 'jpg', 'jpeg', 'png', 'gif'."; } else { $image_random_name=random_name(15).".".$extension; $copy = @copy($_FILES['image']['tmp_name'], $images_location.$image_random_name); if (!$copy) { $results = "Error while uploadin your image! Please try again!"; } else{ create_thumbnail($images_location.$image_random_name,$thumbs_location.$image_random_name, $thumb_width); $results = "Your image has been uploaded!"; } } } } ?> and the form <html> <head> <title>test</title> </head> <body> <?php echo $results; ?> <form action="#" method="post" enctype="multipart/form-data"> <input type="hidden" name="MAX_FILE_SIZE" value="5000000" /> <input type="file" name="image" /> <input type="submit" value="Upload Image" /> </form> </body> </html>
  19. What kind of email address are you trying to send it to? Is it hosted on the same server? or is it hotmail gmail etc? If its not try adding something like this. $headers = "From: $from\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: multipart/mixed;\r\n" . " boundary=\"{$mime_boundary}\"";
  20. So where would I echo the $result ? Thanks again for your help.
  21. Sorry my bad. <?php error_reporting(E_ALL); ini_set("display_errors", 1); $images_location = "project_files/"; $thumbs_location = "project_thumbs/"; $thumb_width = "100"; $maximum_size = "5000000"; //Auto Thumbnail Function function create_thumbnail($source,$destination, $thumb_width) { $size = getimagesize($source); $width = $size[0]; $height = $size[1]; $x = 0; $y = 0; if($width> $height) { $x = ceil(($width - $height) / 2 ); $width = $height; } elseif($height> $width) { $y = ceil(($height - $width) / 2); $height = $width; } $new_image = imagecreatetruecolor($thumb_width,$thumb_width) or die('Cannot initialize new GD image stream'); $extension = get_image_extension($source); if($extension=='jpg' || $extension=='jpeg') $image = imagecreatefromjpeg($source); if($extension=='gif') $image = imagecreatefromjpeg($source); if($extension=='png') $image = imagecreatefromjpeg($source); imagecopyresampled($new_image,$image,0,0,$x,$y,$thumb_width,$thumb_width,$width,$height); if($extension=='jpg' || $extension=='jpeg') imagejpeg($new_image,$destination); if($extension=='gif') $imagegif($new_image,$destination); if($extension=='png') imagepng($new_image,$destination); } //Get Extension Function function get_image_extension($name) { $name = strtolower($name); $i = strrpos($name,"."); if (!$i) { return ""; } $l = strlen($name) - $i; $extension = substr($name,$i+1,$l); return $extension; } //Random Name Function function random_name($length) { $characters = "abcdefghijklmnopqrstuvwxyz01234567890"; $name = ""; for ($i = 0; $i < $length; $i++) { $name .= $character[mt_rand(0, strlen($characters) - 1)]; } return "image-".$name; } //Check And Save Image if(isset($_POST['upload_image'])) { if($_FILES['image']['name'] == ""){ echo = "Please select the image you would like to upload by clicking browse"; } else{ $size=filesize($_FILES['image']['tap_name']); $filename = stripslashes($_FILES['image']['name']); $extension = get_image_extension($filename); if($size > $maximum_size) { $result = "Your file size exceeds the maximum file size!"; } else if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) { $result = "Only the following extensions are allowed. 'jpg', 'jpeg', 'png', 'gif'."; } else { $image_random_name=random_name(15).".".$extension; $copy = @copy($_FILES['image']['tmp_name'], $images_location.$image_random_name); if (!$copy) { $result = "Error while uploadin your image! Please try again!"; } else{ create_thumbnail($images_location.$image_random_name,$thumbs_location.$image_random_name, $thumb_width); $result = "Your image has been uploaded!"; } } } } ?> I am also trying out another tutorial as well which isnt going to well so if this looks redundant let me know and I will post the latest script. Thanks for your help.
  22. Ok I have re written a new script but im having trouble with it as well. It will upload the image but once it gets to 100% and loads again I am getting the blank screen. I think the issue is when it tries to save the image. My database has the following columns. image_id, file_url, thumb_url, project_name, project_text, project_type. My folders are called project_files and project_thumbs. This is the php : <?php $project=$_GET['project']; // Check project is selected if($project != '') { //Check a form has been submitted if(isset($_POST['upload_image'])) { // Fetch the image array sent by preupload.php $photos_uploaded = $_FILES['image']; // Fetch the image caption array $photo_captions = $_POST['caption']; // File type array $photo_types = array( 'image/pjpeg' => 'jpg', 'image/jpeg' => 'jpg', 'image/gif' => 'gif', 'image/bmp' => 'bmp', 'image/x-png' => 'png' ); while($counter <= count($photos_uploaded)) { if($photos_uploaded['size'][$counter] > 0) { if(!array_key_exists($photos_uploaded['type'][$counter], $photo_types)) { $result_final .= 'File ' . ($counter + 1) . ' is not a photo<br />'; } else { // Save the image details to db $sql="INSERT INTO project_images (file_url, project_name, project_text, project_type) VALUES ('$photos_uploaded', '$project', '$photo_captions', 'image')"; $result=mysql_query($sql); $new_id = mysql_insert_id(image_id); // New Id generated // Get the filetype of the uploaded file $filetype = $photos_uploaded['type'][$counter]; // Get the extension for the new name $extension = $known_photo_types[$filetype]; // Generate a new name $filename = "$new_id.$extension"; // Update information $sql2="UPDATE project_images SET file_url = '$filename' WHERE image_id='$new_id'"; $result2=mysql_query($sql2); move_uploaded_file($photos_uploaded['tmp_name'][$counter], $images_dir . '/project_files/' . $filename); //Auto thumbnail start $size = GetImageSize($images_dir . "/project_files/" . $filename); // Wide Image if($size[0] > $size[1]) { $thumbnail_width = 100; $thumbnail_height = (int)(100 * $size[1] / $size[0]); } // Tall Image else { $thumbnail_width = (int)(100 * $size[0] / $size[1]); $thumbnail_height = 100; } $thumbnail_width = <Preset Width> $thumbnail_height = <Preset Width> * <height_dimension_of_original_image> / <width_dimension_of_original_image> $thumbnail_width = <Preset Height> * <width_dimension_of_original_image> / <height_dimension_of_original_image> $thumbnail_height = <Preset Height> $gd_function_suffix = array( 'image/pjpeg' => 'JPEG', 'image/jpeg' => 'JPEG', 'image/gif' => 'GIF', 'image/bmp' => 'WBMP', 'image/x-png' => 'PNG' ); $function_suffix = $gd_function_suffix[$filetype]; $function_to_read = 'ImageCreateFrom' . $function_suffix; $function_to_write = 'Image' . $function_suffix; // Read the source file $source_handle = $function_to_read($images_dir . '/project_files/' . $filename ); if ($source_handle) { // Let's create a blank image for the thumbnail $destination_handle = ImageCreate($thumbnail_width, $thumbnail_height); // Now we resize it ImageCopyResized($destination_handle, $source_handle, 0, 0, 0, 0, $thumbnail_width, $thumbnail_height, $size[0], $size[1]); } // Let's save the thumbnail $function_to_write($destination_handle, $images_dir . '/project_thumbs/' . $filename); ImageDestroy($destination_handle); // Update information $sql3="UPDATE project_thumbs SET thumb_url = '$filename' WHERE image_id='$new_id'"; $result3=mysql_query($sql3); if($result3){ echo"Your image has been uploaded successfully!"; } else { echo "Your image has not been uploaded please try again!"; } } } } }// End check form submit } else { echo"Please select a project!"; } ?>
×
×
  • 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.