-
Posts
3,372 -
Joined
-
Last visited
-
Days Won
18
Everything posted by Muddy_Funster
-
ok, let me start by saying please reword the question, prefferably pointing out what your "results statement" is and some rough idea of what the scrip is actualy doing.
-
ok, I've been through it and compared it to how my function looks, There was a lot of white space in the strings that shouldn't have been, some of the \n's were still \r\n, some lines didn't have enough \n's and you didn't wrap the charset value in double quotes, oh, and you missed out the To and Subject headers altogether (may only matter on some servers with a spam overwatch, but I put them in anyway). I think it should work now, if you want to see my function for comparison it's on my blog in my sig, but here's the revised code anyway: <?php function emailJI($to, $subject, $attachment, $content){ /* Email Detials */ $mail_to = "$to"; $from_mail = "Admin@********.co.uk"; $from_name = "*******Administrator"; $reply_to = "******.******@******.com"; $subject = "$subject"; $message = "$content"; /* Attachment File */ // Attachment location $file_name = "prebrief.pdf"; $path = ""; // Read the file content $file = $path.$file_name; $file_size = filesize($file); $handle = fopen($file, "r"); $att = fread($handle, $file_size); fclose($handle); $att = chunk_split(base64_encode($att)); /* Set the email header */ // Generate a boundary $boundary = md5(uniqid(time())); // Email header $header = "From: ".$from_name." <".$from_mail.">\n"; $header .= "To: ".$mail_to."\n"; $header .= "Subject: ".$subject."\n"; $header .= "Reply-To: ".$reply_to."\n"; $header .= "MIME-Version: 1.0\n"; // Multipart wraps the Email Content and Attachment $header .= "Content-Type: multipart/mixed;boundary=\"".$boundary."\"\n\n"; $header .= "This is a multi-part message in MIME format.\n"; $header .= "--".$boundary."\n"; // Email content // Content-type can be text/plain or text/html $header .= "Content-type:text/html;charset=\"iso-8859-1\";\n"; $header .= "Content-Transfer-Encoding:7bit\n\n\n"; $header .= "$message\n\n"; $header .= "--".$boundary."\n"; // Attachment // Edit content type for different file extensions $header .= "Content-Type:text/pdf;"; $header .="name=\"prebrief.pdf\"\n"; $header .= "Content-Disposition:attachment;filename=\"".$file_name."\"\n"; $header .= "Content-Transfer-Encoding:base64\n\n"; //$att= "<html><head><title></title></head><body>Test attachment for mail delivery</body></html>"; $header .= $att."\n\n"; $header .= "--".$boundary."--\n"; // Send email if (mail($mail_to, $subject, "", $header)) { echo "Sent"; } else { echo "Error"; } } ?> Sadly I can't test this just now as all mail traffic here is routed through the server and requires authentication. Good luck though, let me know how it goes. P.S. The reason you couldn't open the PDF when the transfer-encoding was commented out was because you still had it going through the base64 encode at the top of the function.
-
or possibly into a sensless single letter, whichever works for you. using AS does the same thing as leaving a space and then adding in a stupid single letter, it creates an alias, a usable reffrence to the database, table or colum that you are querying. how usable the refference is by other people - and yourself in 6 months time - all depends on how much sense the alias its self makes.
-
that's just what print_r does, I can't fathom why anyone would write code to check what print_r outputs rather than just checking against the original array, that's just crazy. You're either going to have to pass the print_r result to a sting and then do a regular expression replace on it, or can the code that was written by a crazy person and find something sane to do the job.
-
ok, post me up the full thing as it is just now and I'll run it over on this end, see what I can sus out.
-
PHP not displaying MYSQL result - so strange?? Please help
Muddy_Funster replied to lewisdow123's topic in PHP Coding Help
nope, I tried Workbench on 2 seporate ocasions, never again! it may look more intuative, but in my opinion the one that works is the better one. try to get into phpMyAdmin, once you know what your doing it won't seem all that bad. what you could try is Navicat for MySQL, there should be a trial download that you can get. They used to do a light version for free, but I think your will need to pay to keep using it these days. -
Well something somewhere point's to it or else it would be showing up. your script can't just invent a page to display without being told to display it somewhere in the code, if it's passing to another page then it will loose variable values that arn't passed along. Try a search/find for the page refference in all your code and see if anything comes back, it's got to be there somewhere, it's either that or something external is having an effect.
-
no problem, glad you got it all worked out. good luck.
-
PHP not displaying MYSQL result - so strange?? Please help
Muddy_Funster replied to lewisdow123's topic in PHP Coding Help
yeah, bin mysql workbench, use phpMyAdmin or somthing else thats not as quirky. That's also the first install I have seen without an information_schema table. How did you install your DB? -
ok, for debugging, lats do this: if ($v != $dataset[$k]){ //$url = "/register-cache.php?error=true"; //header("Location: $url"); //exit; echo "$v does not match {$dataset[$k]}"; } let's get eyes on what the comparison looks like.
-
PHP not displaying MYSQL result - so strange?? Please help
Muddy_Funster replied to lewisdow123's topic in PHP Coding Help
could you create a new php file and run the following in it, copy and paste the output. <?php $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = 'root'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die (mysql_error()); $qry = "SHOW DATABASES"; $result = mysql_query($qry) or die (mysql_error()); while ($row = mysql_fetch_assoc($result)) { $x[] = $row['Database']; } $dispX = print_r($x, true); echo "<pre>$dispX</pre>"; ?> -
how about trying some error capture in the script and seeing what comes back?
-
why have you stored the information in two different databases? also, what the SQL looks like depends entierly on what you want to return form the tables
-
right, this is a problem: if(isset($_POST['nextbtn'])){ foreach($_POST as $key => $value) { $$key = mysql_real_escape_string(trim($value)); } Unless you really know what you are doing, don't use $$ variables, your just going to end up in knots of confusion. let's go for this: if(isset($_POST['nextbtn'])){ foreach($_POST as $key => $value) { $fieldlist[$key] = (trim($value)); } unset($fieldlist['nextbtn']); //... //also, take the -1 off of this line: $keyVal = $row['cacheInfoID'] -1; // so it reads $keyVal = $row['cacheInfoID']; //... //then the check becomes: foreach($fieldlist as $k => $v){ if ($v != $dataset[$k]){ $url = "/register-cache.php?error=true"; header("Location: $url"); exit; } see how that goes
-
PHP not displaying MYSQL result - so strange?? Please help
Muddy_Funster replied to lewisdow123's topic in PHP Coding Help
if the connection was the problem then it would fail there, however, you can connect to the server without accessing any databases. that the error comes when you try to acceess a database is telling us that the connection is irelivent to the issue - unless said connection is being made with credentials that arn't allowed to access the database. Follow this link for more info on GRANT PRIVILEDGES http://dev.mysql.com/doc/refman/5.5/en/adding-users.html -
That's one of the options that I was expecting to get. the $slip[] array has not been defined on this page, so it had no content (is NULL) - I assume it's on a page one or two before the one we're working on just now?
-
where did $key come from? Also, looking at the way this is running, there is no need to use the mysql_real_escape_string, as you arn't actualy touching the database with the data and it could end up adding escape characters which will in turn cause a missmatch. post up your full page to let me see how it's all flowing together.
-
PHP not displaying MYSQL result - so strange?? Please help
Muddy_Funster replied to lewisdow123's topic in PHP Coding Help
the connection is to the server, not the database. The other thing that may cause an issue is permissions, normaly the root@localhost has full access, but depending on how the MySQL was installed, or if you are using another user, you may need to grant priviledges to that user. -
yip, forgot the ; at the end of the line sorry
-
whats does a die(var_dump($slide)) produce if you put it on the line above $desc=?
-
PHP not displaying MYSQL result - so strange?? Please help
Muddy_Funster replied to lewisdow123's topic in PHP Coding Help
try this change for me: $dbname = "test"; $db = mysql_select_db($dbname, $conn) or die("Unable to locate the $dbname databse on the current server, please ensure database exists on the server and try again"); $qry = "SELECT * FROM new_table"; $result = mysql_query($qry) or die("There was an error running the the following query:<br>$qry<br><br>The server responded with:<br>".mysql_error()); -
ueah, your going to need to put the single quotes around all your array keys (so everything that is inside a set of []) and also wrap all array key reffrences within double quote strings inside the curly braces, including $desc = "was sent a conformation letter for their booking on the {$slide['event_day']} {$slide['event_month']}, {$slide['event_year']}"; There is also nothing to put the title,first,last information at the start of the $desc = line, so you probably want it to look like: $desc = "{$slide['title']}. {$slide['fname']} {$slide['lname']} was sent a conformation letter for their booking on the {$slide['event_day']} {$slide['event_month']}, {$slide['event_year']}";
-
PHP not displaying MYSQL result - so strange?? Please help
Muddy_Funster replied to lewisdow123's topic in PHP Coding Help
change: $dbname = 'test'; mysql_select_db($dbname); mysql_select_db("test", $conn); $result = mysql_query("SELECT * FROM new_table"); To: $dbname = "test"; mysql_select_db($dbname, $conn); $qry = "SELECT * FROM new_table"; $result = mysql_query($qry) or die("There was an error running the the following query:<br>$qry<br><br>The server responded with:<br>".mysql_error()); and let us know what you get back -
You do have a primary key in your user_location table (as indeed you should) - I have highlighted it in red above -, please follow the link I provided previously to find out how to properly handle this issue.
-
can you provide the results of the following queries please? SHOW CREATE TABLE user_location; SHOW CREATE TABLE quotes; either run them in phpMyAdmin, in command line or from script.