Jump to content

wisewood

Members
  • Posts

    226
  • Joined

  • Last visited

    Never

Everything posted by wisewood

  1. Try this: SELECT * FROM Technology WHERE keywords like '%$HTTP_GET_VARS[$KS]%' ORDER BY last_name
  2. Something along the lines of... // Get the last row from the table before entering the new one. SELECT * FROM table ORDER BY (unique id number field) DESC LIMIT 1 // Compare the content with the variables you've just submitted if($db_variable=="$_POST[variable]") { // dont enter into the database } else { // DO ENTER into the database }
  3. This is fully tested and works with my test data. You'll need to chop and change a few variables and field names etc but it does the job. I created to test entries in a database, and two associated images in a directory called images. When i ran the script with the $prodid variable set to something valid in the database, the file, and the database record were deleted. [code] <?php // Ignore this bit // Just connecting to the database include('../intranet/projects/test_datacon.php'); // For this example i'm using static variables // Yours will be called from elsewhere. $productid = "1235"; $filedir = 'images'; $query1 = "SELECT * FROM products WHERE prodid = $productid"; $result1 = mysql_query($query1); $num = mysql_num_rows($result1);     for($i=0;$i<$num;$i++)     {         $image = mysql_result($result1,$i,"image");         $prodid_query = mysql_result($result1,$i,"prodid");                  unlink("$filedir/$image");         $delete = "DELETE FROM products WHERE prodid = $prodid_query";         $result2 = mysql_query($delete);         if($result2==1) { echo "Record & Image were deleted";}     }      ?> [/code]
  4. i'm currently working on something for you... but i just noticed in your mysql queries you have WHERE whatever = ($variable) should these brackets really be there? I've never seen anyone use brackets in this way before.
  5. thats what i said...
  6. i've heard the short version (<?) will be going in the next major release too. Funny though, until now i never realised this would impact on my use of <?=... though when you think about it, its obvious lol. Thanks ken. (my hero)
  7. cunning.
  8. This will put <?=$variable?> on the screen. echo "<?=$variable?>"; This will put the value of $variable on the screen. echo "$variable"; if you're not within <?php and ?> you should use <?=$variable?> to echo a php variable, but if you are within <?php and ?> then you should use echo "$variable"; Hope this helps
  9. This is what i use... change the ($x%3) to the number of results you want per row. [code] <?php // YOUR MYSQL QUERY GOES HERE $numberall = mysql_numrows($result); if ($numberall==0) {     echo "No Results Found !"; } else if ($numberall>0) { $x=0; ?> <table class="content" align="center"> <? while ($x<$numberall)       {            if (($x%3)==0) { $row="</tr><tr><td class=report>"; } else { $row="<td>"; }             $variable=mysql_result($resultall,$x,"my_table_row"); ?> <? echo $row ?> <td class="report"> <?=$variable?> </td> <?         $x++;     } // end while } // end if numberall > 0 ?> [/code]
  10. if you could find out the @whatever.com part for all of the networks your needed to send a message to, it'd be great.
  11. you're on the right lines, however... unlink($dh.'/'.$result2); // this will not work. $result2 is the variable for the result of your query. So $result2 will equal either 1 or nothing. you need to have something like: $num = mysql_num_rows($result2); for($i=0;$i<$num;$i++) { $filename = mysql_result($result,$i,"filename"); unlink($dh.'/'.$filename); } Basically... get the filename of the image from your database, and use that as the variable for deletion rather than $result2. You might need further tinkering, but that is certainly part of your problem.
  12. that wouldnt send to a telephone number though, unless your network operator happened to allow it, which i know mine doesnt. The method used on that thread uses vtext.com, which is a site you can sign up to for sending and receiving free text messages via their website.
  13. I would use something like this: it makes it more definitive when the action is to take place. if($_GET[action]=="go") { // Run the insert query } else { // Show the form // <form method=post action=$PHP_SELF?action=go> }
  14. [code] <?php // something like this... // when form is submitted // query the db for matching data $check = "SELECT * FROM your_table WHERE title = $_POST[title]"; $result = mysql_query($check); // if it exists, do one thing if($result==1){ echo "An entry with this name already exists, please try something else";} // if it doesnt exist, do something else. else { echo "No entry exists, so we can continue"; } ?> [/code]
  15. When you say you want to "format plain text emails" what exactly do you want to do? Plain Text is exactly as the name would suggest... Plain.
  16. text indentation can be achieved by using the &nbsp; to put multiple spaces side by side. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; will create an 8 character indentation.
  17. There are several companies who offer this as a service, but there is no straight forward function you can use. If there was, everyone would have it built into their sites.
  18. In my clients table, i have two clients whose company name contains 'afon'. So, if i were to run: "SELECT * FROM clients WHERE company LIKE '%afon%'" it would return two results. However, if i run: "SELECT * FROM clients WHERE company LIKE '%afon%' AND client_id = '2'" this will return only the one result. This does work... as i am using it right now.
  19. I just found this... which might help you. If you can find the data/ directory you might get lucky. [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--] Copying database files When it comes to backing up MySQL databases, don't ignore the most obvious solution: making copies of the database files themselves. Because MySQL uses the same table format on different platforms, it's actually possible to copy MySQL table and index files from one platform and use them on another without any difficulties (assuming, of course, that you're using the same version of MySQL on both platforms). So which files should you copy? MySQL stores all its databases in a special data/ directory, which is further divided into subdirectories, one for each database. Tables and table indexes are represented as files, with the file name equal to the table name plus an extension. The easiest approach is to just copy the entire data/ directory to backup media, and archive it so that you can get it back at any time. You might want to write a script to automate the copy. You can then pop the script into your crontab so it can run on a daily or weekly basis, depending on how frequently your databases get updated. If you're moving files between Windows and UNIX platforms, there is one thing that can trip you up. UNIX file names are case-sensitive, while Windows names are not. Therefore, mixed-case MySQL table names are likely to get corrupted when moved between Windows and UNIX (though the data in the tables will be fine). If your SQL code uses these mixed-case table names, it might not work correctly until you check and fix the names and/or the code. For best results, always use lowercase table names, so that you don't encounter this problem. [/quote]
  20. Send me a PM with the details of what you're trying to do and i'll see if i can figure out a way of doing it. Give me an idea what you want the user to be presented with after they say "Yes" on the form, and i'll see what i can come up with.
  21. I just got this code from a tutorial website (http://www.tizag.com/phpT/fileupload.php). I've just tested it and the upload does work. All you need to do is add a simple database query to insert the filename into the database. [code] <?php if($_GET[action]=="go") { $target_path = "uploads/"; $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {     echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else{     echo "There was an error uploading the file, please try again!"; } } else { ?> <form enctype="multipart/form-data" action="<?=$PHP_SELF?>?action=go" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="100000" /> Choose a file to upload: <input name="uploadedfile" type="file" /><br /> <input type="submit" value="Upload File" /> </form> <?php } ?> [/code]
  22. [code] <script Language=Javascript> <!-- function predator12341() { var location= confirm("This job is a chargable visit because the customer does not have maintenance cover. If you wish to continue click ok."); if (location== true) {    window.location="yourpage.php?clicked=YES"; } else {   window.location="yourpage.php?clicked=NO";   } } //--> </script> <a href="#" onClick="predator12341();">Whatever, I agree without reading stuff anyway.</a> [/code] Yeah pretty good weekend... painted the living room ceiling and FINALLY got round to upgrading the pc to XP. PS. ^^^ That should do it.
  23. are you sure the field names have been spelled correctly etc
  24. i dont think there is anything that you can just tack onto the bottom of your script that will tell you all the $variables you have in your script. If I'm right, then what you need to do is work through your code logically, and carefully. Start with main.php. When you find an include('file.php') go to that file, copy the code and paste it into main.php in place of the include... then do the same for the next include, and the next and the next, and so on. Eventually you'll have one very large main.php file which is easy to follow through and see what is doing what, and you can then split it down and include parts of it as you want to, rather than how it was put together in the first place.
  25. Use a function like the one below, which can be activated onClick. Have it redirect you to a php url with ?buttonClicked=true on the URL or something like that. ?? Do you really need to use a javascript alert box? would a splash/holding page with the agree/disagree option not do the trick? [code]<script type="text/javascript"> <!-- function relocate() { window.location = "http://www.yourdomain.com/yourpage.php?action=whatever" } //--> </script> <a href="#" onClick="relocate();">Whatever, I agree without reading stuff anyway.</a>[/code]
×
×
  • 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.