-
Posts
3,372 -
Joined
-
Last visited
-
Days Won
18
Everything posted by Muddy_Funster
-
How do I subtotal/group a list??
Muddy_Funster replied to dazzathedrummer's topic in PHP Coding Help
add "GROUP BY MONTH(gl_date)" to your SQL -
your not terminating your lines with semi-colons
-
I think you want to be looking at multi dimensional arrays (siplified they are arrays within arrays). something like : $master = array(); foreach ($_POST['asname'] as $key => $value){ $master['asname'][$key] = $value; } then use more foreach along with explode to build up a single insert string that you can run on the database. you could user the $_POST array, but I preffer to leave that alone whenever I can.
-
OK, I got the attachment working on the fly. Now however my message boddy has completly vanished from the mail. It's in the variable when I print_r($mail), which is the return from the following function, everything is in there, looking how I expect it should. Can anyone see what I've done wrong here? function buildMessage($fieldArray, $attachment, $bound){ $fname = $fieldArray[0][0].'.xml'; $at_con = chunk_split(base64_encode($attachment)); $mailBody = ""; $mailBody .= "--".$bound."\r\n"; $mailBody .= "Content-Type: application/xml name =\"$fname\"\r\n"; $mailBody .= "Content-Transfer-Encoding: base64 \r\n"; $mailBody .= "Content-Disposition: attachment; filename=\"$fname\""."\r\n"."\r\n"; $mailBody .= $at_con."\r\n"."\r\n"; $mailBody .= "--".$bound."\r\n"; $mailBody .="Content-Type: multipart/alternative \r\n"; $mailBody .= "Content-type: text/html; charset=iso-8859-1"; $mailBody .= "Content-Transfer-Encoding: 8bit"."\r\n"; $mailBody .= "<html><body><br><center><h3>Names Changed to protect the guilty</h3></center><br>"; $mailBody .="<table border='1'><tr><th>Service Provider Name :</th><td>Not Here</td><th>Customer Ref Number:</th><td>{$fieldArray[0][0]}</td></tr>"; $mailBody .="<tr><th>Contact Name :</th><td>{$fieldArray[0][1]}</td><th>Customer :</th><td>{$fieldArray[0][2]}</td></tr>"; $mailBody .="<tr><th>Contact No :</th><td>{$fieldArray[0][3]}</td><th>Target ID :</th><td>{$fieldArray[0][4]}</td></tr>"; $mailBody .= "<tr><th>Query Date :</th><td>{$fieldArray[0][5]}</td><th>Job Date :</th><td>{$fieldArray[0][6]}</td></tr>"; $mailBody .= "<tr><td colspan='4'>QUERY TYPE :</td></tr>"; $mailBody .= "<tr><th>QUERY INFO :</th><td colspan='3'>{$fieldArray[0][7]}</td></tr>"; $mailBody .= "<tr><td colspan='4'>DETAILS OF THE ISSUE :</td></tr>"; $mailBody .= "<tr><td colspan='4'>{$fieldArray[0][8]}</td></tr>"; $mailBody .= "</table><p>Please do not reply to this email unless there is a technical issue.</p></body></html>"."\r\n"."\r\n" ; $mailBody .= "--".$bound."--"."\r\n"."\r\n"; return $mailBody; The attachment, from, reply-to and subject are all coming through spot on, but the body of the message is empty.
-
Help with removing ' ' from displaying!!
Muddy_Funster replied to concrete's topic in PHP Coding Help
change your doquery function to use an or die(mysql_error()) on the query aswell. I don't think that your current code is going to capture the error properly, and as you are already using or die() for the connection and database, and as you are returning the mysql_error to the screen regardless, it's not much odds. change that over and let us know what comes back, also, could you clear up exactly what the issue is? -
Dropdown list with db tables and files
Muddy_Funster replied to logintech's topic in PHP Coding Help
Could you post the code that geve that error. -
you would need some serious coding to get that done. Your table isn't really set up properly for that kind of output. a single level + single sublevel isn't a problem, but to recusevly build a full depth tree from just a single parent folder listing isn't going to be fun. You may be lucky and one of the other guys here has some code to hand that could work, but if not that's a big ask.
-
Dropdown list with db tables and files
Muddy_Funster replied to logintech's topic in PHP Coding Help
when refferencing drop down lists from a form into a variable you would do it by pointing to the name of the select element, not the option. An attempt to make this clearer: $_POST['textbox1'] => 'hello' would come from a form field like so: <input type="text" name="textbox1" value ="hello" > $_POST['dropdown1'] => 'second Option' would come from a drpdown field like so: <select name="dropdown1"> <option value="First Option">1st Option</option> <option value="Second Option" selected="selected">2nd Option</option> </select> Hope that helps. -
help with submitting form to same url
Muddy_Funster replied to deathadder's topic in PHP Coding Help
If you only want to run the php after the form submition, do a check on the post variable and include your code inside the if statment: ?<php if(isset($_POST['userfile'])) { //all your code that will run after the uplaod button is clicked } //any code that should run even on fist page view ?> -
Re-using code from different authors?
Muddy_Funster replied to xtremey_ytinasni's topic in PHP Coding Help
also check for copyright and usage agreements - lots of people who write code look for financial compensation from other people who want to use it. -
Help with removing ' ' from displaying!!
Muddy_Funster replied to concrete's topic in PHP Coding Help
Just don't apply the quotes like that. Aplly the quotes directly in the query string, that way you can echo out the variables and not have to worry about stripping the quotes off to do it. <?php print "<H2>Thank you, <i>"; print $_POST['firstname']; print " "; print $_POST[ 'surname']; print "</i> has been sucessfully added to the system.</H2>"; print "<a href=\"add_student.php\"><h4>Add Another Student</h4></a>"; function doquery($query) { $db = "prs"; $link = mysql_connect("localhost","..........","........") or die("Could not connect to server! Error: ".mysql_error()); mysql_select_db($db,$link) or die("Could not select $db! Error: ".mysql_error()); $result = mysql_query($query,$link) or $result = "Query Error!<p>Query: $query<p>Error: ".mysql_error(); mysql_close($link); return($result); } $firstname= $_POST['firstname']; $surname= $_POST['surname']; $address1= $_POST['address1']; $address2= $_POST['address2']; $town= $_POST['town']; $county= $_POST['county']; $postcode= $_POST['postcode']; $phone= $_POST['phone']; $email= $_POST['email']; $class_set= $_POST['class_set']; $query = "SELECT MAX(upn) + 1 as upn FROM students"; $result = doquery($query); $row = mysql_fetch_array($result); $upn = $row['upn']; $query = "INSERT INTO students (upn, firstname, surname, address1, address2, town, county, postcode, phone, email, class_set) VALUES ($upn, '$firstname', '$surname', '$address1', '$address2', '$town', '$county', '$postcode', '$phone', '$email', '$class_set')"; doquery($query); echo "<table width=\"350px\" border=\"1\" cellspacing=\"0\" cellpadding=\"5\" bordercolor=\"#de5f57\" align=\"center\"> <tr> <td colspan=\"2\"><h3>Recorded Added</h3></td> </tr> <tr> <td width=\"150px\" class=\"form_labels\">Student Number</td> <td width=\"300px\" class=\"table_data\">".$upn."</td> </tr> <tr> <td class=\"form_labels\">First Name</td> <td class=\"table_data\">".$firstname."</td> </tr> <tr> <td class=\"form_labels\">Surname</td> <td class=\"table_data\">".$surname."</td> </tr> <tr> <td class=\"form_labels\">Address 1</td> <td class=\"table_data\">".$address1."</td> </tr> <tr> <td class=\"form_labels\">Address 2</td> <td class=\"table_data\">".$address2."</td> </tr> <tr> <td class=\"form_labels\">Town</td> <td class=\"table_data\">".$town."</td> </tr> <tr> <td class=\"form_labels\">County</td> <td class=\"table_data\">".$county."</td> </tr> <tr> <td class=\"form_labels\">Postcode</td> <td class=\"table_data\">".$postcode."</td> </tr> <tr> <td class=\"form_labels\">Phone Number</td> <td class=\"table_data\">".$phone."</td> </tr> <tr> <td class=\"form_labels\">Email</td> <td class=\"table_data\">".$email."</td> </tr> <tr> <td class=\"form_labels\">Class</td> <td class=\"table_data\">".$class_set."</td> </tr> </table>"; ?> You should also make sure that you run some sanatisation on your field values to protect the inforation in your database from attack -
Hi, is there a way to generate attachemtns for php's mail() function on the fly, without first saving a file. I have an html page stored in a variable and would like to send it as both the body of the mail and as an attachment in it (well actualy I would like to just send it in the body....). Can I push the variable as an attachement or do I need to generate a temp file from it first? Cheers
-
Totally new to PHP. Need URGENT help with form.
Muddy_Funster replied to Dimplistic's topic in PHP Coding Help
that's what I'm thinkning. hard code your prices into an array with keys that = radio button values and then use them to work out the prices, something a little like: $pricelist_coffe = array('Latte'=> '2.15', 'Mocha'=> '2.25'....); ... $cost = 0; foreach($pricelist_coffe as $key => $value){ if ($key == $_POST['coffe']]){ $cost = $cost+$value; } } -
Totally new to PHP. Need URGENT help with form.
Muddy_Funster replied to Dimplistic's topic in PHP Coding Help
what did you try in the way of arrays? oh, and is your form page an html page or a php one? -
Totally new to PHP. Need URGENT help with form.
Muddy_Funster replied to Dimplistic's topic in PHP Coding Help
erm...why didn't you name your hidden fields for the sizes the same way you did for your types? -
lol, it's seldom these days I get called "lad", and even more seldom "legend" . You are very welcome however.
-
This here is your key part of the code for what you want to do: <a href=\"del_student1.php?id=".$result[0]."\"> That code is passing the varible key "id" into the $_GET[] method with the value of "$result[0]" (which is the id returned from the SELECT query you ran earlier.) This is done by the use of the ? at the end of the url declaration. To pass fistname and lastname along with it, you will need to add them onto the end using an & for each key you want to populate in the $_GET[]. To make this all more readable, and less complicated, instead of breaking out of the string each time and using a "." to join the string together, we keep using the double quotes and wrap the array refferences inside {}'s So you should end up with: <a href=\"del_student1.php?id={$result[0]}&firstname={$result[1]}&surname={$result[2]}\"> you should change your $_REQUEST to $_GET on the other page, for consistancy.
-
At forst glance it looks like a white space problem. try: function display_user_branches($user_id, $branch = NULL) { $branches = get_all_branch($user_id); $all_branches = mysql_fetch_array($branches); $split_branches = preg_split("/,/", $all_branches['brand'], -1, PREG_SPLIT_NO_EMPTY); foreach($split_branches as $value) { echo "<option value='{$value}' "; if(trim($value) == trim($branch)) { echo " selected=\"selected\""; } echo ">$value</option>"; } } I just changed your selected statement too. selected on it's own isn't standards complient.
-
Giving each user a sub-directory is a pretty good idea. I understand about using file_exists, but I still want to accept every file that's uploaded using the original file name without overwriting any files. then you will have to ensure that every user only uploads a file once under any given name. If you can exert that level of control over your users do please tell us how you do it The only real option that I can see is to check for the file existing and then either append something to the end of the new one, or present options to the end user on what they want to do about it - overwrite/rename new/rename old/cancel... if there is already a file with that name.
-
$_GET[] uses the url to provide values to variables. $_REQUEST[] uses all of $_GET[] $_POST[] and $_COOKIE[] methods. $_POST[] method is normaly used by forms. $_COOKIE[] uses cookie session information. Where are you expecting to get the $_GET['firstname'] and $_GET['surname'] information from? Is it from a previous page? is it taken from the database or is it entered by the user? can you show the code where the information is first populated?
-
Check your file name and location, perticularly the case used in the file name.
-
I personaly would give each user a sub directory, and you must check if the file exists if you do not want to do a blind over write. what conflict are you concerned about?
-
You are changing your transport method in the middle of the code: $id=$_REQUEST['id']; $firstname=$_GET['firstname']; $surname=$_GET['surname']; Is there a reason for that? I suspect that the values in the $_GET[] array are not actualy being populated.
-
Need help with php mysql database - maintenance?
Muddy_Funster replied to andy_b_1502's topic in PHP Coding Help
$sql = mysql_query("SELECT * FROM users WHERE Email = $email"); You should NEVER do this! Do not SELECT * from your user table ESPECIALY if you don't encrypt any information. If you get hacked you are not only giving out all the login info for a user, you are also giving out user email addresses. If you are storing personal informaton about anyone then you have a duty of care to protect that information. Also, I see you are not actualy escaping your $email variable before sending it to the dtatabase. That's dangerous. -
Or at least the one that we can help with