Jump to content

cyber_alchemist

Members
  • Posts

    55
  • Joined

  • Last visited

Everything posted by cyber_alchemist

  1. code after if condition is okay i guess. should check the code before. or send a simple mail without the query form with variables in code and check if mail() is working or not. $to="kiruthigabaskaran@gmail.com"; $subject="Feedback/Enquiry"; $mail="test@email.com"; $message="test message" ; $header="From:$mail"; $send=mail($to,$subject,$message,$header); if($send) { echo "alert('Your feedback or enquiry is sent successfully!');"; } else { echo "alert('Enter all the fields properly!');"; } most probably it may be server problem. :x
  2. okay i dont know where to put this topic, if it needs to be moved then please do so, I have been creating a mass mailer with this class, <?php class SimpleMail { private $toAddress; private $CCAddress; private $BCCAddress; private $fromAddress; private $subject; private $sendText; private $textBody; private $sendHTML; private $HTMLBody; public function __construct() { $this->toAddress = ''; $this->CCAddress = ''; $this->BCCAddress = ''; $this->fromAddress = ''; $this->subject = ''; $this->sendText = false; $this->textBody = ''; $this->sendHTML = true; $this->HTMLBody = ''; } public function setToAddress($value) { $this->toAddress = $value; } public function setCCAddress($value) { $this->CCAddress = $value; } public function setBCCAddress($value) { $this->BCCAddress = $value; } public function setFromAddress($value) { $this->fromAddress = $value; } public function setSubject($value) { $this->subject = $value; } public function setSendText($value) { $this->sendText = $value; } public function setTextBody($value) { $this->sendText = false; $this->textBody = $value; } public function setSendHTML($value) { $this->sendHTML = $value; } public function setHTMLBody($value) { $this->sendHTML = true; $this->HTMLBody = $value; } public function send($to = null, $subject = null, $message = null, $headers = null) { $success = false; if (!is_null($to) && !is_null($subject) && !is_null($message)) { $success = mail($to, $subject, $message, $headers); return $success; } else { $headers = array(); if (!empty($this->fromAddress)) { $headers[] = 'From: ' . $this->fromAddress; } if (!empty($this->CCAddress)) { $headers[] = 'CC: ' . $this->CCAddress; } if (!empty($this->BCCAddress)) { $headers[] = 'BCC: ' . $this->BCCAddress; } if ($this->sendText && !$this->sendHTML) { $message = $this->textBody; } elseif (!$this->sendText && $this->sendHTML) { $headers[] = 'MIME-Version: 1.0'; $headers[] = 'Content-type: text/html; charset="iso-8859-1"'; $headers[] = 'Content-Transfer-Encoding: 7bit'; // $headers[] .= 'Content-Transfer-Encoding: quoted-printable'; $message = $this->HTMLBody; } elseif ($this->sendText && $this->sendHTML) { $boundary = '==MP_Bound_xyccr948x=='; $headers[] = 'MIME-Version: 1.0'; $headers[] = 'Content-type: multipart/alternative; boundary="' . $boundary . '"'; $message = 'This is a Multipart Message in MIME format.' . "\n"; $message .= '--' . $boundary . "\n"; $message .= 'Content-type: text/plain; charset="iso-8859-1"' . "\n"; $message .= 'Content-Transfer-Encoding: 7bit' . "\n\n"; // $message .= 'Content-Transfer-Encoding: quoted-printable' . "\n\n"; $message .= $this->textBody . "\n"; $message .= '--' . $boundary . "\n"; $message .= 'Content-type: text/html; charset="iso-8859-1"' . "\n"; $message .= 'Content-Transfer-Encoding: 7bit' . "\n\n"; $message .= $this->HTMLBody . "\n"; $message .= '--' . $boundary . '--'; } $success = mail($this->toAddress, $this->subject, $message, join("\r\n", $headers)); return $success; } } } ?> now the problem is when ever gmail recives the image code , <img src="http://yourdomain.com/image.jpg" > it escapes them like this : <img src=\"http://yourdomain.com/image.jpg\" > and the image is not read how could i resolve this ???
  3. looked into the .csv files with comma , commas are escaped by " such as ," any conditional statement will solve it with explode isnt it ??? anyways here is the short script with the help of the example of php.net: excelupload.php <?php if (isset($_POST['submit'])) { $excel_name = $_FILES['excel']['name']; echo $excel_name . "<br />"; $excel_tmp_name = $_FILES['excel'][ 'tmp_name']; echo $excel_tmp_name . "<br />"; $excel_file_size = $_FILES['excel']['size']; echo $excel_file_size . "<br />"; $excel_file_type = $_FILES['excel']['type']; echo $excel_file_type . "<br />"; $excel_date = @date('y-m-d'); echo 'Date of file upload' . $excel_date; $row = 1; echo '<table border="1" >'; if (($handle = fopen($excel_tmp_name, "r")) !== FALSE) { while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $num = count($data); echo "<tr> <td>$num</td><td>$row:</td>"; $row++; for ($c=0; $c < $num; $c++) { echo "<td>" . $data[$c] . "</td>\n"; } echo "</tr>"; } fclose($handle); } echo "</table>"; } ?> excel.html <html> <head><title>excel upload</title></head> <body> <form action="excelupload.php" method="post" enctype="multipart/form-data" > <input type="file" name="excel" id="excel" /> <input type="submit" name="submit" id="submit" value="submit" /> </form> </body> </html>
  4. have you tried opening your saved .csv files on excel ??? if it open correctly then , their is a way around it using .csv format. --edited-- thanks it helped better
  5. Coincidences , i have to do the same thing and was figuring out how ... csv file format is i guess like this ... Year,Make,Model,Length 1997,Ford,E350,2.34 2000,Mercury,Cougar,2.38 where every value is separated by a comma , so i guess on could use explode(); to takeout values from it http://php.net/manual/en/function.explode.php it would help if one could get a format of the file and a example data inserted into it
  6. yes i can but it didn't solved the problem ???? i mean both things mean the same ? whether i write 'UPDATE ml_subscriptions SET pending = 0 WHERE user_id = '. $user_id .' AND ml_id = '. $ml_list; or 'UPDATE ml_subscriptions SET pending = 0 WHERE user_id = '.$user_id.' AND ml_id = '.$ml_list. ''; but anyways i got why it wasn't working from the irc channel
  7. but , ; comes after '' isn't it ??? like $query = '<your query >'; it could be like : 'UPDATE ml_subscriptions SET pending = 0 WHERE user_id = '.$user_id.' AND ml_id = '.$ml_list. ''; isn't it ? phpcodechecker.com returns this error PHP Syntax Check: Parse error: syntax error, unexpected T_VARIABLE in your code on line 102 $result = mysql_query($query, $db); after i do what you asked..
  8. this is my code ... if (!empty($user_id) && !empty($ml_id)) { echo 'empty security pass ..' ; $query = 'UPDATE ml_subscriptions SET pending = 0 WHERE user_id = ' . $user_id . ' AND ml_id = ' . $ml_list; mysql_query($query, $db); $query = 'SELECT listname FROM ml_lists WHERE ml_id = ' . $ml_id; $result = mysql_query($query, $db); $row = mysql_fetch_assoc($result); $listname = $row['listname']; mysql_free_result($result); $query = 'SELECT first_name, email FROM ml_users WHERE user_id = ' . $user_id; $result = mysql_query($query, $db); $row = mysql_fetch_assoc($result); $first_name = $row['first_name']; $email = $row['email']; mysql_free_result($result); $message = 'Hello ' . $first_name . ',' . "\n"; $message .= 'Thank you for subscribing to the ' . $listname . ' mailing list. Welcome!' . "\n\n"; $message .= 'If you did not subscribe, please accept our ' . 'apologies. You can remove' . "\n"; $message .= 'this subscription immediately by visiting the ' . 'following URL:' . "\n"; $message .= 'http://www.massmailer.pixub.com.com/ml_remove.php?user_id=' . $user_id . '&ml_id=' . $ml_id; $mail = new SimpleMail(); $mail->setToAddress($email); $mail->setFromAddress('massmailer@pixub.com'); $mail->setSubject('Mailing list subscription confirmed'); $mail->setTextBody($message); $mail->send(); header('Location: ml_thanks.php?user_id=' . $user_id . '&ml_id=' . $ml_id . '&type=s'); } else { header('Location: ml_user.php'); } every this is working fine just that the query ... $query = 'UPDATE ml_subscriptions SET pending = 0 WHERE user_id = ' . $user_id . ' AND ml_id = ' . $ml_list; mysql_query($query, $db); doesn't seem to update my table , is my query is wrong ??? is my syntax is correct for the updating the table ??
  9. okay got few things , first to add mailing lists and second to delete mailing list... <?php require 'db.inc.php'; require 'class.SimpleMail.php'; $db = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD) or die ('Unable to connect. Check your connection parameters.'); mysql_select_db(MYSQL_DB, $db) or die(mysql_error($db)); $action = (isset($_REQUEST['action'])) ? $_REQUEST['action'] : ''; switch ($action) { case 'Add New Mailing List': $listname = isset($_POST['listname']) ? $_POST['listname'] : ''; if (!empty($listname)) { $query = 'INSERT INTO ml_lists (listname) VALUES ("' . mysql_real_escape_string($listname, $db) . '")'; } mysql_query($query,$db) or die(mysql_error($db)); break; case 'Delete Mailing List': $ml_id = isset($_POST['ml_id']) ? $_POST['ml_id'] : ''; if (ctype_digit($ml_id)) { $query = 'DELETE FROM ml_lists WHERE ml_id=' . $ml_id; mysql_query($query, $db) or die(mysql_error($db)); } break; } ?> however... i am still figuring out how to send mass mails to all the subscribers...
  10. nope , as the password is not given / or use of Facebook passwords is unethical in making any Facebook app or api connecting Facebook, i am not currently updated with the technical details but that is how it goes, once the cookies expires the user have to log in again, although , if they are already signed in , you could make them online in messenger etc.
  11. SELECT * FROM tourDB WHERE categories LIKE '$international_categories' DESC LIMIT $start, $limit if not how could i show it with a limit and where to start ???
  12. This was a third party script which i was going through , now, somehow this script seemed incomplete, i want to make sure what are missing and what do i have to do to make it working. this is the admin form to add the mailing list, although after going through the ml_admin_transact it just gives a blank page..?? Also I didn't find any switch related to the post made by the admin form. <?php require 'db.inc.php'; $db = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD) or die ('Unable to connect. Check your connection parameters.'); mysql_select_db(MYSQL_DB, $db) or die(mysql_error($db)); ?> <html> <head> <title>Mailing List Administration</title> <style type="text/css"> td { vertical-align: top; } </style> </head> <body> <h1>Mailing List Administration</h1> <form method="post" action="ml_admin_transact.php"> <p><label for="listname">Add Mailing List:</label><br /> <input type="text" id="listname" name="listname" maxlength="100" /> <input type="submit" name="action" value="Add New Mailing List" /> </p> <?php $query = 'SELECT ml_id, listname FROM ml_lists ORDER BY listname ASC'; $result = mysql_query($query, $db) or die(mysql_error($db)); if (mysql_num_rows($result) > 0) { echo '<p><label for="ml_id">Delete Mailing List:</label><br />'; echo '<select name="ml_id" id="ml_id">'; while ($row = mysql_fetch_array($result)) { echo '<option value="' . $row['ml_id'] . '">' . $row['listname'] . '</option>'; } echo '</select>'; echo '<input type="submit" name="action" value="Delete ' . 'Mailing List" />'; echo '</p>'; } mysql_free_result($result); ?> </form> <p><a href="ml_quick_msg.php">Send a quick message to users.</a></p> </body> </html> and ml_admin_transact.php :- <?php require 'db.inc.php'; require 'class.SimpleMail.php'; $db = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD) or die ('Unable to connect. Check your connection parameters.'); mysql_select_db(MYSQL_DB, $db) or die(mysql_error($db)); $action = (isset($_REQUEST['action'])) ? $_REQUEST['action'] : ''; switch ($action) { case 'Subscribe': $email = (isset($_POST['email'])) ? $_POST['email'] : ''; $query = 'SELECT user_id FROM ml_users WHERE email="' . mysql_real_escape_string($email, $db) . '"'; $result = mysql_query($query, $db) or die(mysql_error($db)); if (mysql_num_rows($result) > 0) { $row = mysql_fetch_assoc($result); $user_id = $row['user_id']; } else { $first_name = (isset($_POST['first_name'])) ? $_POST['first_name'] : ''; $last_name = (isset($_POST['last_name'])) ? $_POST['last_name'] : ''; $query = 'INSERT INTO ml_users (first_name, last_name, email) VALUES ("' . mysql_real_escape_string($first_name, $db) . '", ' . '"' . mysql_real_escape_string($last_name, $db) . '", ' . '"' . mysql_real_escape_string($email, $db) . '")'; mysql_query($query, $db); $user_id = mysql_insert_id($db); } mysql_free_result($result); foreach ($_POST['ml_id'] as $ml_id) { if (ctype_digit($ml_id)) { $query = 'INSERT INTO ml_subscriptions (user_id, ml_id, pending) VALUES (' . $user_id . ', ' . $ml_id . ', TRUE)'; mysql_query($query, $db); $query = 'SELECT listname FROM ml_lists WHERE ml_id = ' . $ml_id; $result = mysql_query($query, $db); $row = mysql_fetch_assoc($result); $listname = $row['listname']; $message = 'Hello ' . $first_name . "\n" . $message .= 'Our records indicate that you have subscribed ' . 'to the ' . $listname . ' mailing list.' . "\n\n"; $message .= 'If you did not subscribe, please accept our ' . 'apologies. You will not be subscribed if you do ' . 'not visit the confirmation URL.' . "\n\n"; $message .= 'If you subscribed, please confirm this by ' . 'visiting the following URL: ' . 'http://www.example.com/ml_user_transact.php?user_id=' . $user_id . '&ml_id=' . $ml_id . '&action=confirm'; $mail = new SimpleMail(); $mail->setToAddress($email); $mail->setFromAddress('list@example.com'); $mail->setSubject('Mailing list confirmation'); $mail->setTextBody($message); $mail->send(); unset($mail); } } header('Location: ml_thanks.php?user_id=' . $user_id . '&ml_id=' . $ml_id . '&type=c'); break; case 'confirm': $user_id = (isset($_GET['user_id'])) ? $_GET['user_id'] : ''; $ml_id = (isset($_GET['ml_id'])) ? $_GET['ml_id'] : ''; if (!empty($user_id) && !empty($ml_id)) { $query = 'UPDATE ml_subscriptions SET pending = FALSE WHERE user_id = ' . $user_id . ' AND ml_id = ' . $ml_id; mysql_query($query, $db); $query = 'SELECT listname FROM ml_lists WHERE ml_id = ' . $ml_id; $result = mysql_query($query, $db); $row = mysql_fetch_assoc($result); $listname = $row['listname']; mysql_free_result($result); $query = 'SELECT first_name, email FROM ml_users WHERE user_id = ' . $user_id; $result = mysql_query($query, $db); $row = mysql_fetch_assoc($result); $first_name = $row['first_name']; $email = $row['email']; mysql_free_result($result); $message = 'Hello ' . $first_name . ',' . "\n"; $message .= 'Thank you for subscribing to the ' . $listname . ' mailing list. Welcome!' . "\n\n"; $message .= 'If you did not subscribe, please accept our ' . 'apologies. You can remove' . "\n"; $message .= 'this subscription immediately by visiting the ' . 'following URL:' . "\n"; $message .= 'http://www.example.com/ml_remove.php?user_id=' . $user_id . '&ml_id=' . $ml_id; $mail = new SimpleMail(); $mail->setToAddress($email); $mail->setFromAddress('list@example.com'); $mail->setSubject('Mailing list subscription confirmed'); $mail->setTextBody($message); $mail->send(); header('Location: ml_thanks.php?user_id=' . $user_id . '&ml_id=' . $ml_id); } else { header('Location: ml_user.php'); } break; case 'Remove': $email = (isset($_POST['email'])) ? $_POST['email'] : ''; if (!empty($email)) { $query = 'SELECT user_id FROM ml_users WHERE email="' . $email . '"'; $result = mysql_query($query, $db) or die(mysql_error($db)); if (mysql_num_rows($result)) { $row = mysql_fetch_assoc($result); $user_id = $row['user_id']; header('Location: ml_remove.php?user_id=' . $user_id . '&ml_id=' . $ml_id); break; } header('Location: ml_user.php'); } break; } ?> if any more files are needed i will post it those as well.
  13. hmmm.... i guess i forgot, the page doesn't exist to see what i was talking about...
  14. nevermind , i overlooked $pf = fopen ($file, "w"); if (!$pf) { echo "cannot create $file\n"; return; } fwrite ($pf,"<?xml version=\"1.0\" encoding=\"UTF-8\"?> <urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd\"> <!-- created with SiteMap Generator --> <url> <loc>$url/</loc> <changefreq>daily</changefreq> </url> "); $scanned = array(); Scan ($url); fwrite ($pf, "</urlset>\n"); fclose ($pf); i was writing this in free style previously
  15. use isset() or !empty <?php $host="localhost"; $dbuser="root"; $dbpass=""; $db_name="login"; $db_table="login"; mysql_connect("$host","$dbuser","$dbpass") or die("Could Not Establish Connection"); mysql_select_db("$db_name")or die(mysql_error()); $fname=$_POST["fname"]; $lname=$_POST["lname"]; $username=$_POST["username"]; $email=$_POST["email"]; $password=$_POST["password"]; $phone=$_POST["phone"]; $gender=$_POST["gender"]; //validation of input in the form fieldS include("register.php"); if (isset($fname) && isset($lname) && isset($username) && isset($email) && isset($password)&& isset($phone) && $isset($gender) ){ $submit=mysql_query("INSERT INTO users(fname,lname,username,email,password,phone,gender)VALUES('$fname','$lname','$username','$email','$password','$phone','$gender')") or die("REGISTRATION NOT COMPLETED Thanks"); } if($submit==TRUE){ Echo"<div style='background:yellow;'><script>alert('YOU HAVE SUCESSFULLY REGISTERED PLEASE LOGIN WITH YOUR USERNAME AND PASSWORD');</script></div>"; } ?> this should work...
  16. why don't you use $_POST ? $url = $_POST['website_name']; where the second file name is getload.php.
  17. if you could give the internal link where the http://www.thewattletree.com/product/test-product-3/ points to whether in php or asp.net from .htaccess file then it could be traceable i guess...
  18. I was trying to write a class which would generate a sitemap for every post which is made or edited, but i don't seem to understand what is my mistake here. class sitemap { var $file_net; var $url_net; var $extention_net; var $freq_net; var $priority_net; function set() { $file = $this->file_net; $url = $this->url_net; $extention = $this->extention_net; $freq = $this->freq_net; $priority = $this->priority_net; } function Path ($p) { $a = explode ("/", $p); $len = strlen ($a[count ($a) - 1]); return (substr ($p, 0, strlen ($p) - $len)); } function GetUrl($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $data = curl_exec($ch); curl_close($ch); return $data; } function Scan($url) { global $scanned, $pf, $extension, $skip, $freq, $priority; echo "scan url $url\n"; array_push ($scanned, $url); $html = GetUrl ($url); $a1 = explode ("<a", $html); foreach ($a1 as $key => $val) { $parts = explode (">", $val); $a = $parts[0]; $aparts = explode ("href=", $a); $hrefparts = explode (" ", $aparts[1]); $hrefparts2 = explode ("#", $hrefparts[0]); $href = str_replace ("\"", "", $hrefparts2[0]); if ((substr ($href, 0, 7) != "http://") && (substr ($href, 0, != "https://") && (substr ($href, 0, 6) != "ftp://")) { if ($href[0] == '/') $href = "$scanned[0]$href"; else $href = Path ($url) . $href; } if (substr ($href, 0, strlen ($scanned[0])) == $scanned[0]) { $ignore = false; if (isset ($skip)) foreach ($skip as $k => $v) if (substr ($href, 0, strlen ($v)) == $v) $ignore = true; if ((!$ignore) && (!in_array ($href, $scanned)) && (strpos ($href, $extension) > 0) ) { fwrite ($pf, "<url>\n <loc>$href</loc>\n" . " <changefreq>$freq</changefreq>\n" . " <priority>$priority</priority>\n</url>\n"); echo $href. "\n"; Scan ($href); } } } } $pf = fopen ($file, "w"); if (!$pf) { echo "cannot create $file\n"; return; } fwrite ($pf,"<?xml version=\"1.0\" encoding=\"UTF-8\"?> <urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd\"> <!-- created with SiteMap Generator --> <url> <loc>$url/</loc> <changefreq>daily</changefreq> </url> "); $scanned = array(); Scan ($url); fwrite ($pf, "</urlset>\n"); fclose ($pf); }
  19. I have been stuck with this for quite a while now.. i have this rewrite rule for now.. #RewriteCond %{THE_REQUEST} \ /trip\.php\?url=([^&]+\) RewriteRule ^([^/]*)\.html$ /trip.php?url=$1 [L] but now i want this one as well so as any page in .php extention would be converted to .html extention such as .. RewriteRule ^(.*)\.html$ $1.php [nc] also i was working with few other pages and i need these queries to be converted as well.. to http://mydomain.com/holiday-deals http://mydomain.com/international-holidays is there a way around it ??
  20. "Warning: mysql_affected_rows() expects parameter 1 to be resource, boolean given in........" so does it mean that the variable, $result = mysql_query( $sql ) or die( mysql_error() ); is a boolean , and that i am putting it in mysql_affected_rows() which expects it to be resource ??? as $result = mysql_query( $sql ); ????
  21. I did that, id defined it, here is the function.. public function transact_pic_1( $u ) { if ( $_POST[ 'tour_id' ] ) $tour_id = mysql_real_escape_string( $_POST[ 'tour_id' ] ); if ( isset( $_POST[ 'edit' ] ) && $_FILES[ 'pic1' ][ 'size' ] > 0 ) { $pic_1_name = $_FILES[ 'pic1' ][ 'name' ]; $pic_1_tmp_name = $_FILES[ 'pic1' ][ 'tmp_name' ]; $pic_1_file_size = $_FILES[ 'pic1' ][ 'size' ]; $pic_1_file_type = $_FILES[ 'pic1' ][ 'type' ]; $image_date_1 = @date( 'Y-m-d' ); $pic_1_fp = fopen( $pic_1_tmp_name, 'r' ); $pic_1_content = fread( $pic_1_fp, filesize( $pic_1_tmp_name ) ); $pic_1_content = addslashes( $pic_1_content ); fclose( $pic_1_fp ); if ( !get_magic_quotes_gpc() ) { $pic_1_name = addslashes( $pic_1_name ); } //!get_magic_quotes_gpc() if ( $_FILES[ 'pic1' ][ 'error' ] != UPLOAD_ERR_OK ) { switch ( $_FILES[ 'pic1' ][ 'error' ] ) { case UPLOAD_ERR_INI_SIZE: die( 'The uploaded 1st image exceeds the upload_max_filesize directive ' . 'in php.ini.' ); break; case UPLOAD_ERR_FORM_SIZE: die( 'The uploaded 1st exceeds the MAX_FILE_SIZE directive that ' . 'was specified in the HTML form.' ); break; case UPLOAD_ERR_PARTIAL: die( 'The uploaded 1st image was only partially uploaded.' ); break; case UPLOAD_ERR_NO_FILE: die( 'No 1st image was uploaded.' ); break; case UPLOAD_ERR_NO_TMP_DIR: die( 'The server is missing a temporary folder.' ); break; case UPLOAD_ERR_CANT_WRITE: die( 'The server failed to write the uploaded the uploaded 1st image to disk.' ); break; case UPLOAD_ERR_EXTENSION: die( '1st image upload stopped by extension.' ); break; } //$_FILES[ 'pic1' ][ 'error' ] } //$_FILES[ 'pic1' ][ 'error' ] != UPLOAD_ERR_OK $sql = "UPDATE tourDB SET pic_1_name = '$pic_1_name', pic_1_file_size = '$pic_1_file_size', pic_1_file_type = '$pic_1_file_type', pic_1_content = '$pic_1_content', image_date_1 = '$image_date_1' WHERE tour_id = '$tour_id'"; $result = mysql_query( $sql ) or die( mysql_error() ); if ( $result && mysql_affected_rows( $result ) != 0 ) { return true; } //$result && mysql_affected_rows( $result ) != 0 else { return false; } } //isset( $_POST[ 'submit' ] ) && $_FILES[ 'pic1' ][ 'size' ] > 0 } here is the form i use for getting the tour id.. public function edit_package( ) { $id = $_GET[ 'id' ]; $q = "SELECT * FROM tourDB WHERE tour_id = '$id' "; $r = mysql_query( $q ); if ( $r !== false && mysql_num_rows( $r ) > 0 ) { while ( $mfa = mysql_fetch_assoc( $r ) ) { $tour_id = stripslashes( $mfa[ 'tour_id' ] ); $tour_type = stripslashes( $mfa[ 'tour_type' ] ); $tour_name = stripslashes( $mfa[ 'tour_name' ] ); $day = stripslashes( $mfa[ 'day' ] ); $nights = stripslashes( $mfa[ 'nights' ] ); $tour_price = stripslashes( $mfa[ 'tour_price' ] ); $overview = stripslashes( $mfa[ 'overview' ] ); $itinerary = stripslashes( $mfa[ 'itinerary' ] ); $terms_conditons = stripslashes( $mfa[ 'terms_conditons' ] ); $inclusions = stripslashes( $mfa[ 'inclusions' ] ); $exclusions = stripslashes( $mfa[ 'exclusions' ] ); $twin_triple_sharing = stripslashes( $mfa[ 'twin_triple_sharing' ] ); $single_occcupancy = stripslashes( $mfa[ 'single_occcupancy' ] ); $child_with_no_bed = stripslashes( $mfa[ 'child_with_no_bed' ] ); $inf_below = stripslashes( $mfa[ 'inf_below' ] ); $pricing_details = stripslashes( $mfa[ 'pricing_details' ] ); $url = stripslashes( $mfa[ 'url' ] ); $keywords = stripslashes( $mfa[ 'keywords' ] ); $title = stripslashes( $mfa[ 'title' ] ); $description = stripslashes( $mfa[ 'description' ] ); $categories = stripslashes( $mfa[ 'categories' ] ); $image_alt_1 = stripslashes( $mfa[ 'image_alt_1' ] ); $image_alt_2 = stripslashes( $mfa[ 'image_alt_2' ] ); $image_alt_3 = stripslashes( $mfa[ 'image_alt_3' ] ); $image_alt_4 = stripslashes( $mfa[ 'image_alt_4' ] ); $image_alt_5 = stripslashes( $mfa[ 'image_alt_5' ] ); if ( $tour_type == 'international' ) { $option1 = 'selected'; } //$tour_type == 'international' elseif ( $tour_type == 'domestic' ) { $option2 = 'selected'; } //$tour_type == 'domestic' elseif ( $tour_type == 'insta_deals' ) { $option3 = 'selected'; } //$tour_type == 'insta_deals' else { $option = 'selected'; } $edit_package = <<<EDIT_PACKAGE <form action="{$_SERVER['PHP_SELF']}" method="post" enctype="multipart/form-data"> <script type="text/javascript" > $(function new_editor() { $('#transportation_$tour_id').wysiwyg({ autoGrow: true, initialContent: "<p>Transportation Content</p>", maxHeight: 600 }); $('#payment-norms_$tour_id').wysiwyg({ autoGrow: true, initialContent: "<p>Payment Content</p>", maxHeight: 600 }); $('#overview_$tour_id').wysiwyg({ autoGrow: true, initialContent: "$overview", maxHeight: 600 }); $('#inclusions_$tour_id').wysiwyg({ autoGrow: true, initialContent: "$inclusions", maxHeight: 600 }); $('#exclusions_$tour_id').wysiwyg({ autoGrow: true, initialContent: "$exclusions", maxHeight: 600 }); $('#itinerary_$tour_id').wysiwyg({ autoGrow: true, initialContent: "$itinerary", maxHeight: 600 }); $('#pricing_details_$tour_id').wysiwyg({ autoGrow: true, initialContent: "$pricing_details", maxHeight: 600 }); }); </script> <div id="tour-package" > <ul> <li><a href="#genral">General Information</a></li> <li><a href="#picture">Picture And Meta Info</a></li> <li><a href="#tour-inclusions">Tour Inclusions</a></li> <li><a href="#tour-feature">Itinerary</a></li> <!--<li><a href="#availibility">Availability and Others</a></li>--> <li><a href="#billing">Billing And Prices</a></li> </ul> <div id="genral"> <input type="hidden" name="tour_id" value="$id" /> <div class="package-element"> <p><span class="left" >Tour Name: <input type="text" name="tour_name" value= "$tour_name" id="tour_name" /></span></p> </div> <div class="package-element"> <p>Tour Type: <select id="tour_type" name="tour_type" > <option value="null-category" $option >Select Tour Type</option> <option value="international" $option1 >International Tours</option> <option value="domestic" $option2 > Domestic Tours </option> <option value="insta_deals" $option3 >Insta Deals</option> </select> </p> </div> <div class="package-element"> <p>No. of Days: <input type="text" size="2" id="day" value="$day" name="day" /> </p> </div> <div class="package-element"> <p> No. of Nights: <input type="text" name="nights" value="$nights" id="nights" size="2" /> </p> </div> <div class="package-element" > <p> Sub categories <input type="text" name="categories" value="$categories" id="categories" size="5" /> </p> </div> <div class="package-element"> <div class="package-element-head"> <p>Overview of the package :</p> </div> <br /> <div class="package-element"> <textarea rows="10" cols="70" value="" id="overview_$tour_id" name="overview" ></textarea> </div> </div> <div class="cleaner"></div><br /> </div> <div id="picture" > <div class="chavi" > <div class="package-element-head" > <p>Pictures To upload (.jpg, .png) :</p> </div> <div class="cleaner"></div> <div class="chavi-element" > <span class="left"> 1st Image </span> <span class="left"><input type="file" accept ="image/gif, image/jpeg" name="pic1" id="pic1" /></span> <span class="right" ><input value="$image_alt_1" id="alt1" name="alt1" type="text" size="20" /> </span><span class="right">Alt of 1st image </span> </div> <div class="chavi-element" > <span class="left">2nd Image </span> <span class="left"><input type="file" accept ="image/gif, image/jpeg" name="pic2" id="pic2" /></span> <span class="right"><input value="$image_alt_2" name="alt2" id="alt2" type="text size="20" /></span> <span class="right">Alt of 2nd image </span> </div> <div class="chavi-element"> <span class="left" > 3rd Image</span> <span class="left"><input type="file" accept ="image/gif, image/jpeg" name="pic3" id="pic3" /></span> <span class="right" ><input value="$image_alt_3" name="alt3" id="alt3" type="text" size="20" /></span> <span class="right" >Alt of 3rd image </span> </div> <div class="chavi-element" > <span class="left" >4th Image</span> <span class="left"><input type="file" accept ="image/gif, image/jpeg" name="pic4" id="pic4" /></span> <span class="right"><input name="alt4" value="$image_alt_4" id="alt4" type="text" size="20" /></span> <span class="right">Alt of 4th image </span> </div> <div class="chavi-element" > <span class="left" >5th Image</span> <span class="left"><input type="file" accept ="image/gif, image/jpeg" name="pic5" id="pic5" /></span> <span class="right"><input type="text" value="$image_alt_5" name="alt5" id="alt5" size="20" /></span> <span class="right">Alt of 5th image </span> </div> </div> <div class="meta-info"> <div class="package-element-head" > <p>Title:</p> </div> <div class="package-element" > <input type="text" value="$title" size="30" id="title" name="title" /> </div> <div class="package-element-head-2" > Keywords: </div> <div class="package-element" > <textarea rows="5" value="$keywords" cols="28" id="keywords" name="keywords" >$keywords</textarea> </div> </div> <div class="meta-info" > <div class="package-element-head" > Description: </div> <div class="package-element" > <textarea rows="5" cols="30" value="$description" name="description" id="description">$description</textarea> </div> <div class="package-element-head-2" > URL of the page: </div> <div class="package-element" > <input type="text" size="30" value="$url" name="url" id="url" onblur="this.value=removeSpaces(this.value);" /> </div> </div> <div class="cleaner"></div> </div> <div id="tour-inclusions"> <div class="inclusions-exclusions"> <div class="package-element-head" > Inclusions: </div> <div class="package-element" > <textarea rows="10" cols="70" name="inclusions" id="inclusions_$tour_id"></textarea> </div> </div> <div class="inclusions-exclusions"> <div class="package-element-head" > Exlcusions: </div> <div class="package-element"> <textarea rows="10" cols=70" name="exclusions" id="exclusions_$tour_id"></textarea> </div> </div> <div class="cleaner"></div> </div> <div id="tour-feature"> <div class="package-element-head"> Itinerary: </div> <div class="package-element" > <textarea rows="30" cols="75" name="itinerary" id="itinerary_$tour_id"></textarea> </div> <div class="cleaner"></div> </div> <div id="billing"> <div class="price-tab" > <div class="price-tab-row" > <div class="price-tab-element"> <b>Pax Type</b> </div> <div class="price-tab-element"> <b>Tour Price Total in INR</b> </div> </div> <div class="price-tab-row" > <div class="price-tab-element" > Twin/Triple Sharing </div> <div class="price-tab-element" > <span class="rupee">`</span> <input typ="text" value="$twin_triple_sharing" size="7" name="twin_triple_sharing" id="twin_triple_sharing" /> </div> </div> <div class="price-tab-row" > <div class="price-tab-element" > Single Occupancy </div> <div class="price-tab-element" > <span class="rupee">`</span> <input type="text" size="7" name="single_occcupancy" id="single_occcupancy" value=" $single_occcupancy "/> </div> </div> <div class="price-tab-row"> <div class="price-tab-element" > Child With No Bed </div> <div class="price-tab-element"> <span class="rupee" >`</span> <input type="text" size="7" value="$child_with_no_bed" name="child_with_no_bed" id="child_with_no_bed" /> </div> </div> <div class="price-tab-row"> <div class="price-tab-element"> Infant below 2 years </div> <div class="price-tab-element" > <span class="rupee" >`</span> <input type="text" value="$inf_below" size="7" name="inf_below" id="inf_below" /> </div> </div> <div class="package-element-head-2">Terms And Conditions:</div> <div class="cleaner"></div> <div class="package-element" > <textarea rows="10" cols="70" id="pricing_details_$tour_id" name="terms_conditons" ></textarea> </div> <input type="submit" name="edit" id="submit" value="Create This Entry!" /> <div class="cleaner" ></div> </div> </div> </div> </form> </form> <br /> </div> EDIT_PACKAGE; } //$mfa = mysql_fetch_assoc( $r ) } //$r !== false && mysql_num_rows( $r ) > 0 else { echo 'invalid package !!'; } hopefully i could get the $_POST['tour_id'] via a hidden input <input type="hidden" name="tour_id" value="$id" /> isn't it ?? it's still not updating my MEDIUMBLOBS .... ---EDITED-- okay its working although its giving me errors "Warning: mysql_affected_rows() expects parameter 1 to be resource, boolean given in/localhost/ssl/_class/tourCMS.php on line 2582 " what does it means ???
  22. !!! This was in previous function where I have defined it I must have forgotten in while splitting it into different function . ...lets see ...
  23. is my function of updating medium blobs is correct ??? public function transact_pic_1( $u ) { if ( isset( $_POST[ 'edit' ] ) && $_FILES[ 'pic1' ][ 'size' ] > 0 ) { $pic_1_name = $_FILES[ 'pic1' ][ 'name' ]; $pic_1_tmp_name = $_FILES[ 'pic1' ][ 'tmp_name' ]; $pic_1_file_size = $_FILES[ 'pic1' ][ 'size' ]; $pic_1_file_type = $_FILES[ 'pic1' ][ 'type' ]; $image_date_1 = @date( 'Y-m-d' ); $pic_1_fp = fopen( $pic_1_tmp_name, 'r' ); $pic_1_content = fread( $pic_1_fp, filesize( $pic_1_tmp_name ) ); $pic_1_content = addslashes( $pic_1_content ); fclose( $pic_1_fp ); if ( !get_magic_quotes_gpc() ) { $pic_1_name = addslashes( $pic_1_name ); } //!get_magic_quotes_gpc() if ( $_FILES[ 'pic1' ][ 'error' ] != UPLOAD_ERR_OK ) { switch ( $_FILES[ 'pic1' ][ 'error' ] ) { case UPLOAD_ERR_INI_SIZE: die( 'The uploaded 1st image exceeds the upload_max_filesize directive ' . 'in php.ini.' ); break; case UPLOAD_ERR_FORM_SIZE: die( 'The uploaded 1st exceeds the MAX_FILE_SIZE directive that ' . 'was specified in the HTML form.' ); break; case UPLOAD_ERR_PARTIAL: die( 'The uploaded 1st image was only partially uploaded.' ); break; case UPLOAD_ERR_NO_FILE: die( 'No 1st image was uploaded.' ); break; case UPLOAD_ERR_NO_TMP_DIR: die( 'The server is missing a temporary folder.' ); break; case UPLOAD_ERR_CANT_WRITE: die( 'The server failed to write the uploaded the uploaded 1st image to disk.' ); break; case UPLOAD_ERR_EXTENSION: die( '1st image upload stopped by extension.' ); break; } //$_FILES[ 'pic1' ][ 'error' ] } //$_FILES[ 'pic1' ][ 'error' ] != UPLOAD_ERR_OK $sql = "UPDATE tourDB SET pic_1_name = '$pic_1_name', pic_1_file_size = '$pic_1_file_size', pic_1_file_type = '$pic_1_file_type', pic_1_content = '$pic_1_content', image_date_1 = '$image_date_1' WHERE tour_id = '$tour_id'"; $result = mysql_query( $sql ) or die( mysql_error() ); if ( $result && mysql_affected_rows( $result ) != 0 ) { return true; } //$result && mysql_affected_rows( $result ) != 0 else { return false; } because i cant seem to upload images to this .. i call out the function by this : if ( $_POST[ 'edit' ] ) { $obj->transact_pic_1( $_POST[ 'edit' ] ); } the image is being uploaded but it is not being updated in the coloumn of mediumblob. :/
×
×
  • 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.