jazzman1
Staff Alumni-
Posts
2,713 -
Joined
-
Last visited
-
Days Won
12
Everything posted by jazzman1
-
How to download a pdf and mp3 file stored in mysql
jazzman1 replied to Jaswinder's topic in MySQL Help
According to this log you got an empty value from database. Can you explain why? Warning: filesize() [function.filesize]: stat failed for songs/.mp3 in C:\xampp\htdocs\upload\download.php on line 21 1. Be conscious that download.php and the directory called songs lay on(share) one and the same main directory with name /upload 2. For Warning: Cannot modify header information - headers already sent by - click 3. When you fixed everything, the path must be: // the path to the file $file = 'songs'.'/'.$s['songs']; -
Do you have error reporting turned on and showing all errors? Paste this on the top of your file: error_reporting(-1);
- 19 replies
-
- smtp
- send email
-
(and 1 more)
Tagged with:
-
Try to put a backslash before the first comma in the string, $body=<<<EOT A password recover was requested, if you didn\'t make this action please ignore this email. <br /> <br />Your Username: <strong>$username</strong><br />Your Reset Key: <strong>$salt</strong><br /> <br />You can reset your password by accessing the following link: <a href="$url/index.php?a=recover&r=1" target="_blank">$url/index.php?a=recover&r=1</a> EOT; sendRecover('jazzman@gmail.com', 'Wonderful Subject', 'smtp.example.com', 'jazzman@localdomain.com', 'jazzman', $salt, $body);
- 19 replies
-
- smtp
- send email
-
(and 1 more)
Tagged with:
-
There is no problem with that script for me. Listen, don't copy/paste my heredoc (<<<EOT EOT;)just create own one with the same content or don't use heredoc, it's up to you
- 19 replies
-
- smtp
- send email
-
(and 1 more)
Tagged with:
-
Which editor you are using? Attach the file with error.
- 19 replies
-
- smtp
- send email
-
(and 1 more)
Tagged with:
-
No problem. swiftMailer.php
- 19 replies
-
- smtp
- send email
-
(and 1 more)
Tagged with:
-
What was a "powershell"? Is it that perversion shell product which Microsoft was proud for many years
- 3 replies
-
- powershell
- macos & powershell
- (and 2 more)
-
Ok, I wrote a simple script using the same logic as your. Instead phpMailer I'm using another good php mail library - swiftMailer - http://swiftmailer.org/docs/sending.html This test I have made it from my local linux server but using my remote google mail account. Here is it: <?php require_once 'swiftmailer./lib/swift_required.php'; date_default_timezone_set('America/Toronto'); function sendRecover($to, $title, $url, $from, $username, $salt, $body) { $transport = Swift_SmtpTransport::newInstance('smtp.googlemail.com', 465, 'ssl') ->setUsername("yourName@gmail.com") ->setPassword("yourPassword"); ; // Create the Mailer using your created Transport $mailer = Swift_Mailer::newInstance($transport); // Create a message $message = Swift_Message::newInstance($title) ->setContentType("text/html") ->setFrom(array($from)) ->setTo(array($to)) ->setBody($body) ; // Send the message $result = $mailer->send($message); return $result; } $url = 'reset.com'; $username = 'jazzman'; $salt = md5('password'); $body= <<<EOT A password recover was requested, if you didn't make this action please ignore this email. <br /> <br />Your Username: <strong>$username</strong><br />Your Reset Key: <strong>$salt</strong><br /> <br />You can reset your password by accessing the following link: <a href="$url/index.php?a=recover&r=1" target="_blank">$url/index.php?a=recover&r=1</a> EOT; sendRecover('jazzman@gmail.com', 'Wonderful Subject', 'smtp.example.com', 'jazzman@localdomain.com', 'jazzman', $salt, $body); Results:
- 19 replies
-
- smtp
- send email
-
(and 1 more)
Tagged with:
-
I don't have any experience with phpMailer, but I'am sure that you're trying to set up that function in wrong way. If you want to set up the php mail function to use different mail servers using SMTP protocol you need to know few things. 1. What OS is running on the server 2. Under linux servers by default the php mail function uses a l sendmail inux client, so you need to create own sendmail configuration file(if you don't have any access to the server) setting its correct path into php.ini file. 3. On windows servers I don't know how to do this but I found this one on the web - http://stackoverflow.com/questions/112190/php-ini-smtp-how-do-you-pass-username-password
- 19 replies
-
- smtp
- send email
-
(and 1 more)
Tagged with:
-
The script is fine. Which e-mail client you're using to send mails?
- 19 replies
-
- smtp
- send email
-
(and 1 more)
Tagged with:
-
Only getting one subcat_id and apply to all subcategories
jazzman1 replied to glen-rogers's topic in PHP Coding Help
If you run this query inside phpMyAdmin for example what result do you get: Assuming that a category with id: 1 has many subcategories. SELECT c.category, c.cat_id, s.subcat_id, GROUP_CONCAT(s.subcategory) AS sublist FROM categories AS c LEFT JOIN subcategories AS s ON c.cat_id = s.cat_id WHERE s.cat_id = 1 GROUP BY c.cat_id ORDER BY c.cat_id -
Only getting one subcat_id and apply to all subcategories
jazzman1 replied to glen-rogers's topic in PHP Coding Help
Hm.... you need to normalize your database tables. I recommend you to watch those Also, you would check here to find ready database schemata, otherwise you will have a lot of problems in the future. -
How to download a pdf and mp3 file stored in mysql
jazzman1 replied to Jaswinder's topic in MySQL Help
No, the path is fine. You get nothing from $s=mysql_fetch_assoc($sql); Put this code below to the script immediately after $s=mysql_fetch_assoc($sql); and give me the result back. if($n>0) { $s=mysql_fetch_assoc($sql); // put this echo '<pre>'.print_r($s, true).'</pre>'; exit; // path to the file $file = 'songs'.'/'.$s['songs'].'.mp3'; .............. -
Only getting one subcat_id and apply to all subcategories
jazzman1 replied to glen-rogers's topic in PHP Coding Help
Well, let us know how you designed the tables in the database. And......tell us what value you've got from $data['subcat_id'] too! -
Only getting one subcat_id and apply to all subcategories
jazzman1 replied to glen-rogers's topic in PHP Coding Help
My mistake, the $_GET valiable must be $_GET['subcat_id'] coming from $data['subcat_id'], right? Try this, $q = "SELECT c.category, c.cat_id, s.subcat_id, GROUP_CONCAT(s.subcategory) AS sublist FROM categories AS c LEFT JOIN subcategories AS s ON c.cat_id = s.cat_id"; if(isset($_GET['subcat_id'])) $q .= " WHERE s.cat_id=".$_GET['subcat_id']; $q .=" GROUP BY c.cat_id ORDER BY c.cat_id"; -
Only getting one subcat_id and apply to all subcategories
jazzman1 replied to glen-rogers's topic in PHP Coding Help
Change the statement: SELECT c.category, c.cat_id, s.subcat_id, GROUP_CONCAT(s.subcategory) AS sublist FROM categories AS c LEFT JOIN subcategories AS s ON c.cat_id = s.cat_id WHERE c.cat_id = $_GET['cat_id'] GROUP BY c.cat_id ORDER BY c.cat_id -
It took me few seconds to find the error. Have you ever used some IDE? <?php require_once ("config.php"); require_once ("admincp/install_cls.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 transitional//EN" "http://www.w3.org/tr/xhtml1/DTD/xhtml1-transitional.dtd"> <html lang="en" dir="ltr"> <head> <title>My Car Site <?php echo $name_of_site ?></title> <link href="<?php echo SITE_URL ?>/templates/admin/install.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="<?php echo SITE_URL ?>/templates/admin/install.js"></script> </head> <body> <h2 style="margin-left:auto; margin-right:auto; width:75%; text-align:center"><?php echo $name_of_site ?> Install</h2> <?php define('VERSION', '1.0.8'); // version of script if (file_exists(FULL_PATH . "/admincp/" . TABLE_PREFIX . "db.php")) { $db = "<div class=\"error\">" . TABLE_PREFIX . "db.php exits! You will be overwriting this file once you click continue.</div>"; $Connection = TRUE; } else { $db = "<div class=\"error\">" . TABLE_PREFIX . "db.php does not exits!</div>"; $Connection = FALSE; } $level = (isset($_POST['level'])) ? $_POST['level'] : ""; if ($level == "") { ?> <div class="raised" style="text-align:center; margin-right:auto; margin-left:auto"><b class="b1"></b><b class="b2"></b><b class="b3"></b><b class="b4"></b> <div class="boxcontent" style="padding:3px"> Welcome to the <?php echo $name_of_site ?> install. In order for you to install this product, you will need to follow the steps in the next few screens. <hr /> <div class="raised" style="margin-top:5px; width:130px; height:50px; text-align:center; margin-left:75%"> <b class="b1"></b><b class="b2"></b><b class="b3"></b><b class="b4"></b> <div class="boxcontent"><form action="install.php" method="post"><input type="hidden" name="level" value="1" /><input class="button" type="submit" name="next" value="Continue to Step 1" /></form></div> <b class="b4b"></b><b class="b3b"></b><b class="b2b"></b><b class="b1b"></b> </div> </div><b class="b4b"></b><b class="b3b"></b><b class="b2b"></b><b class="b1b"></b></div> <?php } if ($level == "1") { ?> <h3 style="margin-left:auto; margin-right:auto; width:75%; text-align:center">Step #1, MySql Connection Info</h3> <div class="raised" style="width:75%; text-align:center; margin-right:auto; margin-left:auto"><b class="b1"></b><b class="b2"></b><b class="b3"></b><b class="b4"></b> <div class="boxcontent" style="padding:3px"> <?php if ($Connection) { echo $db; } ?> <form method="post" action="install.php" onsubmit="return valid_dbf(this)"> <p align="center">This information is generally given to you by your host. It is important to have this for the script to work.</p> <div style="margin:auto; text-align:center; width:70%"> <p align="left">Hostname : <input errortext="You have must enter a 'host'" type="text" name="hostname" size="20" value="localhost" />(often localhost)</p> <p align="left">DB Username : <input errortext="You must enter a 'Username'" type="text" name="db_username" size="20" /></p> <p align="left">DB Password : <input errortext="You have must enter a 'Password'" type="text" name="db_password" size="20" /></p> <p align="left">Database Name: <input errortext="You have must enter a 'Database Name'" type="text" name="db_name" size="20" /></p> </div> <div class="raised" style="width:130px; height:50px; text-align:center; margin-left:75%"> <b class="b1"></b><b class="b2"></b><b class="b3"></b><b class="b4"></b> <div class="boxcontent"> <input type="hidden" name="level" value="2" /><input class="button" type="submit" name="next" value="Continue to Step 2" /></form></div> <b class="b4b"></b><b class="b3b"></b><b class="b2b"></b><b class="b1b"></b> </div> </div><b class="b4b"></b><b class="b3b"></b><b class="b2b"></b><b class="b1b"></b></div> <?php } if ($level == "2") { if (file_exists(FULL_PATH . "/admincp/" . TABLE_PREFIX . "db.php")) { unlink(FULL_PATH . "/admincp/" . TABLE_PREFIX . "db.php"); } $fd = fopen(FULL_PATH . "/admincp/" . TABLE_PREFIX . "db.php", "w+") or die("<div class=\"error\">Unable to create " . TABLE_PREFIX . "db.php in admincp. Please chmod this folder to 777 and press refresh on this page.</div>"); $str_gen = "<?php\n\n // " . date("M d, Y G:i:s") . " \n\ndefine(\"HOSTNAME\", \"{$_POST['localhost']}\"); define(\"USER\", \"{$_POST['root']}\"); define(\"PASS\", \"{$_POST['']}\"); define(\"DBNAME\", \"{$_POST['car2']}\");\r\n?>"; $len_gen = strlen($str_gen); fwrite($fd, $str_gen, $len_gen); fclose($fd); ?> <h3 style="margin-left:auto; margin-right:auto; width:75%; text-align:center">Step #2, Connection Info Saved</h3> <div class="raised" style="width:75%; text-align:center; margin-right:auto; margin-left:auto"><b class="b1"></b><b class="b2"></b><b class="b3"></b><b class="b4"></b> <div class="boxcontent" style="padding:3px"> <div class="error"><?php echo TABLE_PREFIX ?>db.php has been written to admincp succesfully.</div> <p align="center">The next step will create the mysql tables for you so the script can function properly.</p> <div class="raised" style="width:130px; height:50px; text-align:center; margin-left:75%"> <b class="b1"></b><b class="b2"></b><b class="b3"></b><b class="b4"></b> <div class="boxcontent"> <form method="post" action="install.php"> <input type="hidden" name="level" value="3" /><input class="button" type="submit" name="next" value="Continue to Step 3" /></form></div> <b class="b4b"></b><b class="b3b"></b><b class="b2b"></b><b class="b1b"></b> </div> </div><b class="b4b"></b><b class="b3b"></b><b class="b2b"></b><b class="b1b"></b></div> <?php } if ($level == "3") { if ($Connection) { include (FULL_PATH . "/admincp/sql.php"); $DBc = new DBM; $DBc->connect(); foreach ($CarDealer_Query['Create'] AS $query) { $DBc->query($query); } foreach ($CarDealer_Query['Insert'] AS $query) { $DBc->query($query); } if (!$DBc->errdesc) { $GetResult = "<div class=\"error\">Tables have been created successfully.</div>"; $GetResult .= "<p align=\"center\">Next step will install the scripts templates. Please continue to the next step. <br /><br />"; $submitbtn = "<input class=\"button\" type=\"submit\" name=\"next\" value=\"Continue to Step 4\" />\n"; $go = "4"; } else { $GetResult = "<div class=\"error\">Table creation failed. Error below: <br /><br />" . $DBc->errdesc . "</div>"; $submitbtn = "<input class=\"button\" type=\"submit\" name=\"next\" value=\"Redo Step 3\" />\n"; $go = "3"; } } else { $GetResult = "<div class=\"error\">" . TABLE_PREFIX . "db.php is not found. No Connection to mysql can be established. Please go back to setp 1 to create this file.</div>"; $submitbtn = "<input class=\"button\" type=\"submit\" name=\"next\" value=\"Back to Step 1\" />\n"; $go = "1"; } ?> <h3 style="margin-left:auto; margin-right:auto; width:75%; text-align:center">Step #3, Mysql Table Creation</h3> <div class="raised" style="width:75%; text-align:center; margin-right:auto; margin-left:auto"><b class="b1"></b><b class="b2"></b><b class="b3"></b><b class="b4"></b> <div class="boxcontent" style="padding:3px"> <form method="post" action="install.php"> <?php echo $GetResult ?> <div class="raised" style="width:130px; height:50px; text-align:center; margin-left:75%"> <b class="b1"></b><b class="b2"></b><b class="b3"></b><b class="b4"></b> <div class="boxcontent"> <input type="hidden" name="level" value="<?php echo $go ?>" /><?php echo $submitbtn ?></form></div> <b class="b4b"></b><b class="b3b"></b><b class="b2b"></b><b class="b1b"></b> </div> </div><b class="b4b"></b><b class="b3b"></b><b class="b2b"></b><b class="b1b"></b></div> <?php // End of level 3... } if ($level == "4") { $Install = new INSTALL(); $Install->INSTALLS(); if ($Install->InstallError) { $GetResult = "<div class=\"error\">Style Import Failed. Error below: <br /><br />$Install->InstallError</div>"; $submitbtn = "<input type=\"hidden\" name=\"level\" value=\"4\" /><input class=\"button\" type=\"submit\" name=\"next\" value=\"Redo to Step 4\" /></form></div>\n"; } else { $GetResult = "<div class=\"error\">$Install->msg</div>"; $GetResult .= "<a href='admincp/index.php'>Login to Your Admin</a></p> <p align=\"center\">Thank you for the Installing The $name_of_site Script. It is required to Delete this install script once done.</p>\n"; $submitbtn = "<div class=\"boxcontent\">Finished</div></form>\n"; } ?> <h3 style="margin-left:auto; margin-right:auto; width:75%; text-align:center">Step #4, Master Style Insertion</h3> <div class="raised" style="width:75%; text-align:center; margin-right:auto; margin-left:auto"><b class="b1"></b><b class="b2"></b><b class="b3"></b><b class="b4"></b> <div class="boxcontent" style="padding:3px"> <?php echo $GetResult ?> <form method="post" action="install.php"> <div class="raised" style="width:130px; height:50px; text-align:center; margin-left:75%"> <b class="b1"></b><b class="b2"></b><b class="b3"></b><b class="b4"></b> <?php echo $submitbtn ?> <b class="b4b"></b><b class="b3b"></b><b class="b2b"></b><b class="b1b"></b> </div> </div><b class="b4b"></b><b class="b3b"></b><b class="b2b"></b><b class="b1b"></b></div> <?php } ?> <div class="copyright"><div style="display: inline;"><?php echo $name_of_site ?> <?php echo VERSION ?></div><div style="text-align:right; display: inline; width:200px"> © My Car Site</div></div> </body> </html>
-
Also this is wrong way: /* This is the WRONG way to loop over the directory. */ while ($f = readdir($dir)) { #read one file name /* This is the correct way to loop over the directory. */ while (false !== ($f = readdir($dir))) { #read one file name I'm pretty sure that you must redesign this scrit
-
Every time when you're looping through the files of that particular directory you are calling the explode function, this is a waste of memory of the server. What would be happened if you have 2000 files there? To be more specific turn on error_reporting on the top of that file and give us back the error: error_reporting(-1);
-
Rid off the explode function from the while loop, it's a very bad design. I thing that you're exceeding the limit of memory.
-
How to download a pdf and mp3 file stored in mysql
jazzman1 replied to Jaswinder's topic in MySQL Help
Sorry, my misreading. 1. You don't have to loop the files in download.php, in case that you want to display only one file. 2. Check the correct path to the it should be something like - songs/name_of_the_file This is my suggestion: download.php <?php $download=$_GET['sno']; $cn=mysql_connect("localhost","root",""); $db=mysql_select_db("music",$cn); $a="select songs from mp3 where sno='$download'"; $sql=mysql_query($a) or die(mysql_error); $n=mysql_num_rows($sql); if($n>0) { $s=mysql_fetch_assoc($sql); // path to the file $file = 'songs'.'/'.$s['songs'].'.mp3'; header('Content-Description: File Transfer'); header("Content-type: audio/mpeg"); header('Content-Disposition: attachment; filename='. basename($file)); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Length: ' . filesize($file)); readfile($file); } -
How to download a pdf and mp3 file stored in mysql
jazzman1 replied to Jaswinder's topic in MySQL Help
Your inserting is wrong. You are trying to insert the file name as a blob data. Take a look at this post - http://www.sitepoint.com/forums/showthread.php?693871-Problem-using-PHP-to-pull-binary-files-from-a-BLOB-field-in-MYSQL -
Replace all "&" symbols with its a html entity name "&" $gatewayUrl .= 'key='.$app_key.'&'; http://www.utexas.edu/learn/html/spchar.html Are you planning to use this url in javascript?
-
Me too but I'm pretty sure that we will understand each other Have you ever used the database like mysql, firebird for example?
-
Don't be thinking too match. That are the rules of the company. They give you the money, they will say who is going to drive the train.