Jump to content

Lyleyboy

Members
  • Posts

    149
  • Joined

  • Last visited

Everything posted by Lyleyboy

  1. Hi all, I was wondering if there is a way (Sure there is) of showing a message or an image while a page is loading. The issue is that I have a big table and I'm running some queries against it. Obviously the query results don't appear immediately but in the mean time the page doesn't display anything. Any thoughts?
  2. Ok, Another thought. Will this work on a joined table query?
  3. Flippin marvellous. Thanks. How do I mark as solved?
  4. The very quick way would be to pop them into into a mysql table. Each record in the table could then have an id (i.e. 1, 2 or 3) Then using rand find a random number between 1 and 3 and then run a query to find the record where the id = your random number. Just one thing to point out is that the random number thing is not actually random so it's entirely possible that No 3 will be output far more times than 1 or 2 thus this client being very upset. If you want to do it properly you need to add a flag field to the table and tick it at each use then use the one after next time. Hope that helps
  5. Hi all, Tried a slightly different way. $sql="SHOW COLUMNS FROM `messages`"; $result = mysql_query($sql) or die(mysql_error()); while ($get_info = mysql_fetch_row($result)) { foreach ($get_info as $column) { echo $column; } } and got Nearly there but also kind of not. How do I get shut of the rubbish. I just want the emboldened bit msg_idint(11)NOPRI Thanks in advance.
  6. Morning all, I have a question regarding the ability to show the column names from my table/query. What I'm looking to do is to be able to have my users enter their own query via a builder (Which I haven't built yet). I've found a little test script from the net but it shows them in an array. My code is <?php include('includes/inc.conn.php'); mysql_select_db("discover_messaging"); $result = mysql_query("SHOW COLUMNS FROM `messages`"); if (mysql_num_rows($result) > 0) { while ($row = mysql_fetch_assoc($result)) { print_r($row); } } ?> Which outputs Is there a way to have the field names come out of the array so that I can do something like? <table> <tr> <td>msg_id</td> <td>msg_to</td> etc ... Thanks all.
  7. Zanus, Oh I see. Sorry. Iv'e been a bit of a muppet there haven't I? Doh!
  8. I would guess that you may need to have a word with your hosting company. Doesn't seem right that it should slow the whole site. I use sessions extensively and don't see any problems.
  9. Hi all, I'm looking for some guidance. I am putting together a kind of build your own query thing. In doing so I have come to one fairly major problem. I not going to know what field names should be outputted in advance. Is there a way I can find the field names from the query using php? Thanks in advance.
  10. thanks. I'll give that a whirl
  11. Hi all, I have this code that uploads a photo to the site. The issue seems to be that it wont upload an image that is more than about a megabyte. There is a bit in there to say how big and I have set it to 1000000KB which (Unless I'm going daft) is 100MB or 1GB so that should be ok. Can some one take a look please and help me out before I quit php and go off and be a road sweeper. Code that does the upload //define a maxim size for the uploaded images in Kb define ("MAX_SIZE","1000000"); //This function reads the extension of the file. It is used to determine if the file is an image by checking the extension. function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } //This variable is used as a flag. The value is initialized with 0 (meaning no error found) //and it will be changed to 1 if an errro occures. //If the error occures the file will not be uploaded. //checks if the form has been submitted if(isset($_POST['Submit'])) { //reads the name of the file the user submitted for uploading $image=$_FILES['image']['name']; //if it is not empty if ($image) { //get the original name of the file from the clients machine $filename = stripslashes($_FILES['image']['name']); //get the extension of the file in a lower case format $extension = getExtension($filename); $extension = strtolower($extension); //if it is not a known extension, we will suppose it is an error and will not upload the file, //otherwise we will do more tests if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) { //print error message echo 'Unknown extension!'; $errors="1"; } else { //get the size of the image in bytes //$_FILES['image']['tmp_name'] is the temporary filename of the file //in which the uploaded file was stored on the server $size=filesize($_FILES['image']['tmp_name']); //compare the size with the maxim size we defined and print error if bigger if ($size > MAX_SIZE*5024) { echo 'You have exceeded the size limit!'; $errors="1"; } //we will give an unique name, for example the time in unix time format $image_name=time().'.'.$extension; //the new name will be containing the full path where will be stored (images folder) $newname="upload/".$image_name; //we verify if the image has been uploaded, and print error instead $copied = copy($_FILES['image']['tmp_name'], $newname); if (!$copied) { echo 'Copy unsuccessfull!'; $errors="1"; }}}} Full code <?php // Site area setup session_start(); $_SESSION['sitearea'] = "Galleries"; //Setup errors to be 0 $errors = "0"; //Setup instructions path $inst_path = "../includes/instructions/inst_galleries_upload.php"; //Turn off warnings error_reporting(E_ALL ^ E_NOTICE); //Include the header bar include('../includes/main_head.php'); //Now include the nav bar include('../includes/main_nav.php'); //Include the conn include('../includes/inc.conn.php'); //Check my users details $username = $_SESSION['username']; $query = "SELECT * FROM users WHERE username = '$username'"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ //Set up my vars $userover18 = $row['over18']; } $gallery_id = $_POST['gallery']; $query = "SELECT * FROM galls_galleries WHERE gall_gall_id = '$gallery_id'"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ //Set up my vars $over18 = $row['over18']; $gallery_name = $row['gallery']; } //*****************Page content********************* if ($inst_path > ""){ ?> <div class="instructions"> <?php include($inst_path); ?> </div> <div class="log_nav" onmouseover="this.className='log_nav_on'" onmouseout="this.className='log_nav'" style="float:right;" id="inst"> Help </div> <?php } ?> <h1><img src="../images/nav_gallery.png" alt="Galleries Icon" width="50px"/> Upload to our photo galleries</h1> <p> Fill out all the details below to upload the picture. Don't forget to tag the images with keywords. </p> <p> <?php //Do some nice little validation of the form entries $sub_gallery = $_POST['gallery']; $sub_title = $_POST['title']; $sub_tags = $_POST['tags']; $sub_image = $_POST['image']; if (isset($_POST['Submit'])){ if ($sub_gallery < "1" || $sub_title < "1" || $sub_tags < "1" || isset($sub_image)){ echo "<span class='errors'>Whoops, the form wasn't quite filled out properly<br/><br/>"; $errors="1";//Sets the errors to 1 in any case if($sub_gallery < "1"){ echo " - You didn't enter a gallery! Where we goona put the piccy if you don't tell us?<br/>"; $errors="1"; } if($sub_title < "1"){ echo " - You didn't enter a title. What are we gonna call it then?<br/>"; $errors="1"; } if($sub_tags < "1"){ echo " - You didn't enter any tags. Please enter some so we can find it later.<br/>"; $errors="1"; } if(isset($sub_image)){ echo " - You didn't select a file. Give me something to work with here.<br/><br/></span>"; $errors="1"; } } } //define a maxim size for the uploaded images in Kb define ("MAX_SIZE","1000000"); //This function reads the extension of the file. It is used to determine if the file is an image by checking the extension. function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } //This variable is used as a flag. The value is initialized with 0 (meaning no error found) //and it will be changed to 1 if an errro occures. //If the error occures the file will not be uploaded. //checks if the form has been submitted if(isset($_POST['Submit'])) { //reads the name of the file the user submitted for uploading $image=$_FILES['image']['name']; //if it is not empty if ($image) { //get the original name of the file from the clients machine $filename = stripslashes($_FILES['image']['name']); //get the extension of the file in a lower case format $extension = getExtension($filename); $extension = strtolower($extension); //if it is not a known extension, we will suppose it is an error and will not upload the file, //otherwise we will do more tests if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) { //print error message echo 'Unknown extension!'; $errors="1"; } else { //get the size of the image in bytes //$_FILES['image']['tmp_name'] is the temporary filename of the file //in which the uploaded file was stored on the server $size=filesize($_FILES['image']['tmp_name']); //compare the size with the maxim size we defined and print error if bigger if ($size > MAX_SIZE*5024) { echo 'You have exceeded the size limit!'; $errors="1"; } //we will give an unique name, for example the time in unix time format $image_name=time().'.'.$extension; //the new name will be containing the full path where will be stored (images folder) $newname="upload/".$image_name; //we verify if the image has been uploaded, and print error instead $copied = copy($_FILES['image']['tmp_name'], $newname); if (!$copied) { echo 'Copy unsuccessfull!'; $errors="1"; }}}} //If no errors registred, print the success message if(isset($_POST['Submit']) && $errors=="0") { echo "<br/><b>File Uploaded Successfully! Have another go!!<br/><br/></b>"; //Lets resize the image (Fingers crossed) //Validate it if($sub_image > ""){ include('SimpleImage.php'); $image = new SimpleImage(); $image->load($newname); $image->resizeToWidth(500); $image->save($newname); } //Update the table //Verify vars $title = $_POST['title']; $tags = $_POST['tags']; $path = $image_name; //Check if the night has been changed if (isset($new_night)){ $night = $_POST['new_night']; } //Kill injections // night title tags path active network $gallery_id = mysql_real_escape_string($gallery_id); $gallery_name = mysql_real_escape_string($gallery_name); $title = mysql_real_escape_string($title); $tags = mysql_real_escape_string($tags); $path = mysql_real_escape_string($path); //Over18 galleries do not need to be moderated neither do Administrators if ($over18 == 'on' || $_Session['admin'] == 'on' || $_session['s_admin'] == 'on'){ $active = "on"; $over18 = "on"; } else { $active = "off"; $over18 = "off"; } //Check for swearings include('../includes/functions/swear_filter.php'); $title = swear_filter($title); $tags = swear_filter($tags); //tags year $year = date('Y'); $tags = $year . " " . $tags; mysql_query("INSERT INTO galls (gallery_id, gallery, title, tags, path, uploaded_by, gall_over18, active) VALUES('$gallery_id', '$gallery_name', '$title', '$tags', '$path' , '$username', '$over18', '$active') ") or die(mysql_error()); } else { echo "<span class='errors'>Nothing was uploaded, please fix the errors to continue. Please reselect the gallery!</span>"; } ?> <form name="newad" method="post" enctype="multipart/form-data" action=""> Which gallery would you like to upload the photo to? <select name="gallery" class="nav_form"> <option value="">-- Choose --</option> <?php //am I over 18? if ($userover18 == 'on'){ $qry = "SELECT * FROM galls_galleries"; } else { $qry = "SELECT * FROM galls_galleries WHERE over18<>'on'"; } $query = $qry; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo "<option value='" . $row['gall_gall_id'] . "'>" . $row['gallery'] . "</option>"; } ?> </select><br/><a href="requestgallery.php">Or click here to request a new gallery</a><br/> Choose the image to upload<br/> <input type="file" name="image" class="buttons" onmouseover="this.className='buttons_on'" onmouseout="this.className='buttons'"/><br/><br/><br/> What is the title of the image<br/> <input type="text" name="title" size="60" class="nav_form" value="<?php echo $sub_title; ?>"/><br/><br/> Enter some tags so that folks can search for this photo later like "Rafting bbq dave camp tent" (Doesn't need the " marks.)<br/> <input type="text" name="tags" size="60" class="nav_form" value="<?php echo $sub_tags; ?>"/><br/><br/> <input name="Submit" type="submit" value="Upload image" class="buttons" onmouseover="this.className='buttons_on'" onmouseout="this.className='buttons'"/> </form> <?php //*****************Page content********************* //Inlcude the footer bar include('../includes/main_footer.php');
  12. Go for Vimeo. Free and easy. They even supply the embed code.
  13. You don't need php for this. Try Googling for EMBED SWF. You will probably need the video on your server or maybe use a hosting site like Vimeo.
  14. Do you get any error messages?
  15. Thanks for your help. I'd guess that should fix it. Thanks again
  16. No the rel was just my thought of the best way to do it. I could just go with %ADDRESS% So what I'd like to now do is to 1, Say, Which template do you want to use? 2, Open that template and replace the details. Some from the DB and some from a form like the letter's body. I can set up a template picker without too much difficulty it's just then replacing the details from both the form and based on a mysql query. Sorry if I was a bit vague at the beginning. This is just developing as we talk.
  17. They will be uploading the template. I want to then read the rel='address1' and replace it. So <p rel='address1'>PLACEHOLDER</p> and I replace the PLACEHOLDER like <p rel='address1'>1 A Street, A Town</p>
  18. The idea is that the user can upload a html document which is effectivly a letter but in HTML format. Then we can use some cool code (Which I clearly can't write yet!) to replace some details like the address and event name etc etc. So really we're creating a template so it can be re used but there won't be a finite number of documents so I don't to sit there and code each template so it can be read by php.
  19. May give it a miss then. Got to be a better way...
  20. Firstly I should explain that I'm not too good at this. The point is to create a kind of cut down CMS. So the client uploads a page that has say a <p> tag with a rel='para1' It doesnt have to be a rel by the way, a class could work too. My code can then be like a back end. I can then pull all the details of that element i.e. the content of the <p> and put it into a form. Then save it back out. I hope that makes sense...
  21. Hi all, I have a prospective question. I have no code yet as this is just an idea. Does anyone know a way whereby I can access the data stored in an HTML rel tag for instance. <a href='www.google.co.uk' rel='Link to google'>Google</a> How could I extract the Thanks in advance.
  22. FIXED IT. It turned out that some of the email fields are null but the IS NOT NULL was returning them anyway. How shoddy is that? May have to go with >1 rather than is not null Apologies for wasting time. Thanks for your help.
×
×
  • 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.