Jump to content

GingerRobot

Staff Alumni
  • Posts

    4,082
  • Joined

  • Last visited

Everything posted by GingerRobot

  1. It seems to me that the problem must lie elsewhere. The method darkfreaks showed is the way to do it. Perhaps there it is something silly like a typo thats causing you problems. If possible try posting all the code. And yes, the tags you need are the tags(without the spaces)
  2. Firstly, by titling your post as "php expert needed for this one" you are sure to alienate people. As you said yourself, you have no experience in php, so how can you possibly decide what problem might need an 'expert'. Second, if you want someone to do this for you (and i assume that is the case, given the rather naff attitude - 'Basically what I'm looking for is the solution to my problem, not just a suggestion' ), then try the freelance forum.
  3. It'll be something along the lines of: <?php $sql = "SELECT COUNT(*) FROM `yourtable` WHERE `email`='$email' AND `username`='$username'"; $result = mysql_query($sql) or die(mysql_error()); $num = mysql_result($result,0); if($num != 1){ echo 'The information you entered does not match any account!'; }else{ //process password reset } ?>
  4. Right, so you only want to insert this record into the database if all the files they attempt to upload are actually successful? I think what you want to do is increment a counter each time the upload is successful, and compare this to the number of files which were supposed to be uploaded: <?php //This is the directory where images will be saved $path = '../images/'; //This gets all the other information from the form $name=$_POST['name']; $suburb=$_POST['suburb']; $price=$_POST['price']; $content=$_POST['content']; $content2=$_POST['content2']; $agentmobile=$_POST['agentmobile']; $agentemail=$_POST['agentemail']; $uploadFile0=($_FILES['uploadFile0']['name']); $uploadFile1=($_FILES['uploadFile1']['name']); $uploadFile2=($_FILES['uploadFile2']['name']); $uploadFile3=($_FILES['uploadFile3']['name']); $uploadFile4=($_FILES['uploadFile4']['name']); $uploadFile5=($_FILES['uploadFile5']['name']); $uploadFile6=($_FILES['uploadFile6']['name']); $uploadFile7=($_FILES['uploadFile7']['name']); $uploadFile8=($_FILES['uploadFile8']['name']); // Connects to your Database mysql_connect("localhost", "root", "*********") or die(mysql_error()) ; mysql_select_db("gcproperty") or die(mysql_error()) ; // Uploads Images $uploadNeed = $_POST['uploadNeed']; // start for loop $copied = 0;//the number of files successfully uploaded for($x=0;$x<$uploadNeed;$x++) { $file_name = $_FILES['uploadFile'. $x]['name']; //test $Size = $_FILES['uploadFile'. $x]['size']; //Test Check $Valid = false; if(valid_ext($file_name)) { echo "valid ext"; $Valid = true; }else{ echo "invalid Type"; } echo "<br>"; if(valid_size($Size)) { echo "valid size"; }else{ $Valid = false; echo "invalid Size"; } if($Valid) { // strip file_name of slashes $file_name = stripslashes($file_name); $file_name = str_replace("'","",$file_name); if(file_exists($path . $file_name) ) { echo "<br>The file {$file_name} already exists."; }else { $copy = move_uploaded_file($_FILES['uploadFile'. $x]['tmp_name'], $path . $file_name); $copied++;//increment our counter } } } // check if successfully copied if($copied == $uploadNeed) { print "<meta http-equiv=\"refresh\" content=\"0;URL=property_added_successfully.php\">"; //Writes the information to the database mysql_query("INSERT INTO `employees` VALUES ('$name', '$suburb', '$price', '$content', '$content2','$agentmobile', '$agentemail','$uploadFile0','$uploadFile1', '$uploadFile2', '$uploadFile3', '$uploadFile4', '$uploadFile5', '$uploadFile6', '$uploadFile7', '$uploadFile8')") ; }else{ echo "<br>$file_name The File(s) could not be uploaded!<br>The file must be under 1 meg and be of a valid extension type, jpeg, jpg, png or gif!<br /> <br /> Please go <a href=\"property_add.php\">back</a> and try again"; } // end of loop //***FUNCTIONS //filter extensions function valid_ext($file_name) { $valid = array("jpeg","jpg","png","gif"); $extension = strtolower(substr($file_name,-3,3)); return (in_array($extension, $valid)); } //filter by size, function valid_size($size) { return ($size <= 1048576); } ?>
  5. To search for just cars: SELECT * FROM `yourtable` WHERE `type`='car' For just caravans: SELECT * FROM `yourtable` WHERE `type`='caravan'
  6. Actually, the first query would not match your first example. It would only match the exact text 'car'. It is no different from a query such as: WHERE `type` = 'car' le007: fyi, the % character is used to match any number of any character. You can use the underscore character to match any character, but just once.
  7. Well ive no idea if this is actually what you wanted - im getting more and more lost by your description, but this would produce a table with 3 columns, a list in each: <?php $str = ', 6 Disc CD Player, DVD Player, Heated Seats, On-Star Navigation System, Play Station 3 Gaming Center, Dual Heat And Air, Rear Camera Monitor, Leather Seats'; $bits = explode(',',$str); $array = array(); foreach($bits as $k =>$v){ $v = trim($v); if(!empty($v)){ $array[] = $v;//the new array only contains those not empty strings } } $num = count($array); $cols = 3; $per_col = ceil($num/$cols); $i=0; echo '<table border="1"><tr>'; foreach($array as $v){ if($i==0){ echo '<td valign="top"><ul>'; } echo '<li>'.$v.'</li>'; if(++$i == $per_col){ echo '</ul></td>'; $i = 0; } } echo '</tr></table>'; ?>
  8. Not 100% sure what you're trying to achieve. I think you wanted something like: <?php $str = 'Driver Presets, 6 Disc CD Player, DVD Player, Heated Seats, On-Star Navigation System, Play Station 3 Gaming Center, Dual Heat And Air, Rear Camera Monitor, Leather Seats'; $bits = explode(',',$str); echo '<ul>'; foreach($bits as $v){ $v = trim($v); if(!empty($v)){ echo '<li>'.$v.'</li>'; } } echo '</ul>'; ?>
  9. Sounds like your looking for a suga daddy...then once he suggests something sexual youve got him. Still dont trust ya ..sorry Sheesh, take a chill pill. What is it to you if someone isn't who they say they are? Bonjour et bienvenue kellz (french i can do, but ill skip the german )
  10. Err..why not just make the field in the database an auto increment, primary key field? Would be much easier. Not only that, but there is of course the possibility of an infinite loop with the way you are doing it at the moment. If you had the majority of your numbers already taken, it could take an awful long time to find a unique one.
  11. Yes, firstly you need to get the contents of the website. In most cases, file_get_contents() will do - though in more complex cases, you'll need to use cURL. Then, you'll need to use regular expressions to find the links: preg_match() or ereg() There's also a sub forum for regex: http://www.phpfreaks.com/forums/index.php/board,43.0.html
  12. It wouldn't surprise me if youtube have an API for this anyway. Google youtube API - there's definately something there, but i can't see what it is. I would have a look myself, but im at school and youtube is blocked.
  13. Try: <?php $config['theme']='default'; //Style Initialization $config['html']='./theme/'.$config['theme'].'/html.php'; $config['html2']='./theme/'.$config['theme'].'/html2.php'; include('./theme/'.$config['theme'].'/styleinfo.php'); ?> You should quote array keys which are strings - otherwise you will recieve an undefined constant notice if you have error reporting set to include notices. Second, in your previous code you defined $config as an array (implicitly by using the key, 'them'), then changed it to a string, since you gave no key in this line: $config ='./theme/$config[theme]/html.php'; You then change it back to an array in the following line. The end result: an array with only one element. Lastly, strings inside single quotes are treated as literals. The following code: <?php $foo = 'bar'; echo '$foo'; ?> Produces the text: $foo - not the variables contents, bar. When echoing a variable, you either use concatenation(as i did - using the . to 'piece together' the bits of your string), or use double quotes.
  14. You should be able to do if you enclose the field name in backticks (`). You'd probably be better off not using the # character however.
  15. Erm, you already are retrieving one field from the row - you are definingwhich field you want (in the first case money, in the second bullets) rather than selecting everything (*). I assume you mean you only want to retrieve one particular row, rather than all of them? In which case, you probably want to add a WHERE clause to your query. You probably want to only select a particular user based on an id: $result = @mysql_query("SELECT money FROM users WHERE id = '$userid'"); In which case, you'd have no need for the while loop and can simply use: $row = mysql_fetch_array($result); echo $row['money']; There were a lot of 'probably's in that, but since i dont actually know what you're trying to do, i can't offer anything more specific.
  16. With all due respect, i have better things to do with my time than wait for a marquee to scroll across so i can find out what your problem is.
  17. Try changing the echo line to: echo '<img src="../images/'.$row_Recordset1['photo'].'" alt="image" width="150" />';
  18. You dont need to escape a semi colon in a string. This works fine: <?php echo ';'; ?>
  19. In what way? If you simply want to know the number of times that a page had been (re)loaded, then just add in a piece of code to update a total in a database. If you wanted the number of (re)loads broken down into users, you'll have to start storing IP addresses etc.
  20. Out of interest, why would you want to?
  21. Haha, true. On the down side, i'd look rather like a tit as an 18 year old trying to learn to ride a bike! I blame my parents, they gave away my bike before i properly learnt to ride it. Im deprived
  22. I never learnt to ride a bike... Slightly off topic i know, but just thought i'd throw that in there
  23. Hmm, you learn something new every day. I didn't realise that you dont recieve an undefined constant notice if you use the first method inside a double quoted string.
×
×
  • 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.