-
Posts
151 -
Joined
-
Last visited
Everything posted by subhomoy
-
Thank you everybody...
-
Thanks you @Jacques1, for the help.... Yeah definitely school projects doesn't need lots of space though.... Can you plz throw light on some indexing method which will help me in long run for my project... Thank you once again...
-
Hello everyone, I'm going to create my school project and I really need your advice. My Project Summary I need to create a new website where the user can add new schools in my site. After creating, they can add students, add teachers, add principal and hell lot of things from their admin panel. And in the frontend they will get their own urls and can display their schools. Ex1: example.com/st_sebastians/ <------- School name. Ex2: example.com/st_augustin/ <------- School name. When the user will visit those url they will see all the contents of their respective schools. My Questions How can I create those database. For that I've thought of two methods. 1) I will create multiple database for every user/school dynamically using php and saves the record in it. (I searched on google that it is very prone to mysql injection.) 2) I will create a single database with everything related to their (school id) and stores in the single database. Example Student table id | school_id | name | roll | ---------------------------------------------- 1 | 1 | Subho | 123456 ---------------------------------------------- 2 | 5 | xyz | 236566 ---------------------------------------------- 3 | 45 | asfgf | 778219 . . . . . . . . Please note that the database are going to store whole lot of records and I don't want to it slow down. Any Help will be highly appreciated. Thank You In advance...
-
Hello everybody I;m trying to post data to my facbook page (not on my profile wall) but whenever i try it keeps getting posted in my fan page but in different place . I want to post it using My Page name i the wall but it is getting posted in this section (in the left panel of my page..) I want to show in the page wall like all the posts is showing... Here is the script that i've used $touid = "xxxxxxxxxxxxxxxxx"; // This is the page id i'm using $token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // my access token of that page $msg = "Hello again"; $title = "TItle"; $uri = "http://www.google.com"; $desc = "description"; $pic = "http://i.imgur.com/JCdGh.png"; $action_name = "Google"; $action_link = "http://www.google.com"; echo FB_wallpost_wosdk($touid, $token, $msg, $title, $uri, $desc, $pic, $action_name, $action_link); function FB_wallpost_wosdk($touid, $token, $msg, $title, $uri, $desc, $pic, $action_name, $action_link){ if ( ($touid !="") && ($token !="") && ($msg != "") && ($title != "") && ($uri != "") && ($desc != "") && ($pic != "") && ($action_name != "") && ($action_link != "") ) { $url = "https://graph.facebook.com/".$touid."/feed"; $attachment = array( 'access_token' => $token, 'message' => $msg, 'name' => $title, 'link' => $uri, 'description' => $desc, 'picture'=>$pic, 'actions' => json_encode(array('name' => $action_name,'link' => $action_link)) ); // set the target url $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $attachment); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //to suppress the curl output $result = curl_exec($ch); curl_close ($ch); return $result; } else { return 0; } } My Access tokens have this scopes.. Whenever i post anything it getting posted as a visitors post in my fan page.... Pleas help guys... THank in advance....
-
hello every body, Currently i'm scraping web data for a demo project but i cant preg_match the value from this html. The html code is <div class="carouselContainer leftDisabled"> <ul class="carousel leftDisabled"> <li> <div class="thumbContainer"> <div class="thumb" style="background-image:url(http://img6a.flixcart.com/image/mobile/v/h/g/samsung-galaxy-core-2-sm-g355h-100x100-imadzb4ywyj25mw4.jpeg)" data-imageId="IMADZB4YWYJ25MW4"> </div> </div> </li> <li> <div class="thumbContainer"> <div class="thumb" style="background-image:url(http://img6a.flixcart.com/image/mobile/v/h/g/samsung-galaxy-core-2-sm-g355h-100x100-imadzb4zhk4855ny.jpeg)" data-imageId="IMADZB4ZHK4855NY"> </div> </div> </li> <li> <div class="thumbContainer"> <div class="thumb" style="background-image:url(http://img6a.flixcart.com/image/mobile/v/h/g/samsung-galaxy-core-2-sm-g355h-100x100-imadzwrpmdwhnxg7.jpeg)" data-imageId="IMADZWRPMDWHNXG7"> </div> </div> </li> <li> <div class="thumbContainer"> <div class="thumb" style="background-image:url(http://img6a.flixcart.com/image/mobile/v/h/g/samsung-galaxy-core-2-sm-g355h-100x100-imadzwvvz3deeh4c.jpeg)" data-imageId="IMADZWVVZ3DEEH4C"> </div> </div> </li> </ul> </div> The regex i've used is preg_match_all('|<div class="carouselContainer leftDisabled"+>(.*)</div+>|U',$txt,$matches3); I want only the images images url from that specific block. Can anybody help me in this plz...
-
Thanks for the reply @ QuickOldCar But i'm asking is there anything to protect direct access to the image directory... I dont want any1 to go directly and view all all the images www.yourdomain.com/images.. Rather it should show "ACCESS FORBIDDEN"
-
Hello every1, I'm trying to create a magazine wesite and I dont want anybody to access my images folder which is located in the root directory. I want some thing like this... I want to call the images in my website using <img> tag but I dont want any1 to access the directory directly. It should also protect from software bots also like (HTTrack or website Copier) It should show "Access forbidden". Any help will be greatly appreciated. Thank you...
-
Hello every body. Currently I am creating a quiz section but I'm facing some problem. The thing i want is that the questions which the user has played before should not come again. So here is my quiz table. +-------------+-------------------------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+-------------------------------------+------+-----+---------+----------------+ | qid | int(11) | NO | PRI | NULL | auto_increment | | questions | varchar(255) | NO | UNI | NULL | | | correct_ans | varchar(50) | NO | | NULL | | | option1 | varchar(50) | NO | | NULL | | | option2 | varchar(50) | NO | | NULL | | | option3 | varchar(50) | NO | | NULL | | | category | enum('Maths','Bollywood','Special') | NO | | NULL | | +-------------+-------------------------------------+------+-----+---------+----------------+ Then I have created another tablle where I stored their user id and the questions Iid they have played. Here is the table. +----------------+---------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------------+---------+------+-----+---------+-------+ | mid | int(11) | NO | PRI | NULL | | | quiz_questions | text | NO | | NULL | | +----------------+---------+------+-----+---------+-------+ In the above table, the ids are stored in this pattern 1,5,10,6,7,11,15,29,2 ------------------> Tis are the quiz id. I'm using this query but to bring the uinque questions but still the same questions are comming.. $q = $this->database()->prepare("SELECT quiz_questions FROM quiz_played WHERE mid = ?"); $q->bindParam(1, $mid,PDO::PARAM_INT); $q->execute(); $row = $q->fetch(PDO::FETCH_ASSOC); $q->closeCursor(); $q1 = $this->database()->prepare("SELECT * FROM quiz WHERE qid NOT IN (?) ORDER BY RAND()"); $q1->bindParam(1, $genre,PDO::PARAM_STR); $q1->bindParam(1, $row['quiz_questions'], PDO::PARAM_STR); $q1->execute(); return $q1->fetch(PDO::FETCH_ASSOC); Any help will be really appreciated.
-
If I add [L,R] in each RewriteRule then it redirects me to the another url Example I want to visits www.example.com/new_folder it took me to this url http://www.example.com/home3/superior/public_html/new_folder.php Is there anything that could solve the problem ???? plz help...
-
@requinix still not working, showing the same error.... 404 not found 've change the file as u have said RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^/]+)/$ $1.php RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$ RewriteRule (.*)$ /$1/ [R=301,L] RewriteCond %{HTTP_HOST} !^www.example.com$ [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301] DirectoryIndex index.php Plz help me/......
-
Thanks for the help.....
-
Hello every body Currently I'm facing a new prbel with .htaccess. I've used this code to remove the .php extention and add a trailing '/' at the end. RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^/]+)/$ $1.php RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$ RewriteRule (.*)$ /$1/ [R=301,L] RewriteCond %{HTTP_HOST} !^www.superioradsmedia.com$ [NC] RewriteRule ^(.*)$ http://www.superioradsmedia.com/$1 [L,R=301] Everything is working fine except two things 1) If I use an image location like "www.abc.com/images/abc.jpg" it does'nt show up.. But if I use 'http://' in front of it it shows the image... 2) Suppose I have a directory in my root directory like 'new_folder' which contains an index.php page If i access like this www.abc.com/new_folder -------------------> It gives me 404 error... But if I use www.abc.com/new_folder/index.php ---------------------> it works... ANy help will be greatly appreciated.... Thank you...
-
duplicate records are getting inserted in the database
subhomoy replied to subhomoy's topic in PHP Coding Help
I'm runniig it from the IPN simulator using a sandbox account.... -
duplicate records are getting inserted in the database
subhomoy replied to subhomoy's topic in PHP Coding Help
No i'm using the script from paypal only.... Always it showing INVALID... ANY HELP.... -
duplicate records are getting inserted in the database
subhomoy replied to subhomoy's topic in PHP Coding Help
Thanks for the info... BTW the bindParam one I know.. It was done by mistake... Actually i found dis on net.. WHen ever i'm testing using IPN SIMULATOR, it always gives me invalid... ANY IDEAS??? <?php // STEP 1: read POST data // Reading POSTed data directly from $_POST causes serialization issues with array data in the POST. // Instead, read raw POST data from the input stream. $raw_post_data = file_get_contents('php://input'); $raw_post_array = explode('&', $raw_post_data); $myPost = array(); foreach ($raw_post_array as $keyval) { $keyval = explode ('=', $keyval); if (count($keyval) == 2) $myPost[$keyval[0]] = urldecode($keyval[1]); } // read the IPN message sent from PayPal and prepend 'cmd=_notify-validate' $req = 'cmd=_notify-validate'; if(function_exists('get_magic_quotes_gpc')) { $get_magic_quotes_exists = true; } foreach ($myPost as $key => $value) { if($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1) { $value = urlencode(stripslashes($value)); } else { $value = urlencode($value); } $req .= "&$key=$value"; } // STEP 2: POST IPN data back to PayPal to validate $msg = json_encode($_POST); $ch = curl_init('https://www.sandbox.paypal.com/cgi-bin/webscr'); curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_POSTFIELDS, $req); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_FORBID_REUSE, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close')); // In wamp-like environments that do not come bundled with root authority certificates, // please download 'cacert.pem' from "http://curl.haxx.se/docs/caextract.html" and set // the directory path of the certificate as shown below: // curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/cacert.pem'); if( !($res = curl_exec($ch)) ) { // error_log("Got " . curl_error($ch) . " when processing IPN data"); curl_close($ch); exit; } curl_close($ch); // STEP 3: Inspect IPN validation result and act accordingly if (strcmp ($res, "VERIFIED") == 0) { // The IPN is verified, process it: // check whether the payment_status is Completed // check that txn_id has not been previously processed // check that receiver_email is your Primary PayPal email // check that payment_amount/payment_currency are correct // process the notification // assign posted variables to local variables $item_name = $_POST['item_name']; $item_number = $_POST['item_number']; $payment_status = $_POST['payment_status']; $payment_amount = $_POST['mc_gross']; $payment_currency = $_POST['mc_currency']; $txn_id = $_POST['txn_id']; $receiver_email = $_POST['receiver_email']; $payer_email = $_POST['payer_email']; $to = "[email protected]"; $subject = "Verified"; $message = "$otherstuff"; $from = "From: superior"; mail($to,$subject,$message,$from); // IPN message values depend upon the type of notification sent. // To loop through the &_POST array and print the NV pairs to the screen: foreach($_POST as $key => $value) { echo $key." = ". $value."<br>"; } } else if (strcmp ($res, "INVALID") == 0) { // IPN invalid, log for manual investigation echo "The response from IPN was: <b>" .$res ."</b>"; $to = "[email protected]"; $subject = "INVALID"; $message = "$msg"; $from = "From: superior"; mail($to,$subject,$message,$from); } ?> -
duplicate records are getting inserted in the database
subhomoy replied to subhomoy's topic in PHP Coding Help
Thanks guyss for all the help..... I've done upto this... Can any1 tell me whether i'm going in a correct way or not... <?php require '../db.php'; $req = 'cmd=' . urlencode('_notify-validate'); foreach ($_POST as $key => $value) { $value = urlencode(stripslashes($value)); $req .= "&$key=$value"; } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://www.sandbox.paypal.com/cgi-bin/webscr'); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_POSTFIELDS, $req); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Host: www.sandbox.paypal.com')); $res = curl_exec($ch); curl_close($ch); if (strcmp ($res, "VERIFIED") == 0) { $transaction_id = $_POST['txn_id']; $payerid = $_POST['payer_id']; $firstname = $_POST['first_name']; $lastname = $_POST['last_name']; $payeremail = $_POST['payer_email']; $paymentdate = $_POST['payment_date']; $paymentstatus = $_POST['payment_status']; $mdate= date('Y-m-d h:i:s',strtotime($paymentdate)); $otherstuff = json_encode($_POST); if($paymentstatus === "Completed") { if(check_txn_id($transaction_id)) { $to = "[email protected]"; $subject = "Verified"; $message = "$otherstuff"; $from = "From: Superior Ads Media"; mail($to,$subject,$message,$from); // database insertion } else { $to = "[email protected]"; $subject = "Duplicate"; $message = "$otherstuff"; $from = "From: Superior Ads Media"; mail($to,$subject,$message,$from); } } } else { "<h1 style='font-family:verdana,san-seriff,seriff;color:red'>You are not allowed to view this page.</h1>"; } function check_txn_id($txn_id) { $q = $this->connect()->prepare("SELECT count(*) FROM payment WHERE txn_id = ?"); $q->bindParam(1, $transaction_id, PDO::PARAM_STR); $q->execute(); if($q->fetchColumn()>0) { return FALSE; } else { return TRUE; } } ?> Then i've used the return url while creating the buynow button... Where the user willl be redirected. There i'll check any new entry is done from the user id.. If yes then I will upgrade... -
duplicate records are getting inserted in the database
subhomoy replied to subhomoy's topic in PHP Coding Help
then what should I do... Plz help.. I've already started the project... @ mac_gyver u said that I should use unique composite key..Lets try it out... BTW thanks for da reply.... -
hello every body... two I'm creating an IPN in paypal for my membership site but the problem I'm facing is that on successfull verification of the purchase, four rows are getting inserted in the database... The code is <?php require '../db.php'; $paypalmode = '.sandbox'; $req = 'cmd=' . urlencode('_notify-validate'); foreach ($_POST as $key => $value) { $value = urlencode(stripslashes($value)); $req .= "&$key=$value"; } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://www'.$paypalmode.'.paypal.com/cgi-bin/webscr'); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_POSTFIELDS, $req); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Host: www'.$paypalmode.'.paypal.com')); $res = curl_exec($ch); curl_close($ch); if (strcmp ($res, "VERIFIED") == 0) { $transaction_id = $_POST['txn_id']; $payerid = $_POST['payer_id']; $firstname = $_POST['first_name']; $lastname = $_POST['last_name']; $payeremail = $_POST['payer_email']; $paymentdate = $_POST['payment_date']; $paymentstatus = $_POST['payment_status']; $mdate= date('Y-m-d h:i:s',strtotime($paymentdate)); $otherstuff = json_encode($_POST); $date = date("y-m-d"); $q = $pdo->connect()->query("INSERT INTO payment (mid,username,amount,paypal_id,txn_id,received_date) VALUES('{$_SESSION['user_id']}','{$_SESSION['uname']}','{$_POST['mc_gross']}','{$_POST['payer_email']}','{$_POST['txn_id']}','$date')"); $q->execute(); $q1 = $pdo->connect()->query("UPDATE members SET amount_loaded = amount_loaded + {$_SESSION['amount']} WHERE mid = '{$_SESSION['user_id']}'"); $q1->execute(); //header("Location: funds.php"); echo "verified"; } ?> two for the payment and in the members table, the amount is getting doubled. (i.e if anybody purchases For $2, it shows $4 in the database....) Any help will be really appreciated...
-
Hello everybody I am facing some problem with array.. I have a na array like this $arr = array( [0]=>1, [1]=>10, [2]=>166, [7]=>12, [15]=>1365, [20]=>1253, . . . . . [31]=>40 ); What i want is that to show the whole array. The keys consist of all the dates of a month.. If no specific dates exits then it will show 0 for that corresponding dates.. Like the above array does not contain keys [3]. [4], [5], .... I awant to show them as zero... Like this $arr = array( [0]=>1, [1]=>10, [2]=>166, [3]=>0, [4]=>0, [5]=>0, [6]=>0, [7]=>12, [15]=>1365, [20]=>1253, . . . . . [31]=>40 ); Any help will be greatly appreciated... Thank u in advance....
-
Hello every body.... I'm creating a simple php project where the user will be able to choose option from dropdown menu and the query will be executed accordingly.. The html form is shown below.... <select name='movie_name'> <option value='ALL'>All</option> <option value='blah'>Blah blah </option> <option value='blah'>Blah blah </option> ... </select> <select name='movie_genre'> <option value='ALL'>All</option> <option value='Horror'>Horror</option> <option value='Anime'>Anime</option> ... </select> <select name='movie_cast'> <option value='ALL'>All</option> <option value='john'>john</option> <option value='Katrina'>Blah blah Katrina</option> ... </select> If the user select "ALL" then, all the resuls will be displayed according to the selected options AND again If the user select "different" options then, all the resuls matcing from the database will be shown... Tha database schema is shown below | id | movie_name| movie_genre | movie_cast | 1 | Hello Brother | Comedy | Salman Khan | 2 | Blah blah | ALL | Blah blah | 3 | ALL | ALL | ALL | 4 | Blah Blah | Blah Blah | ALL * here "ALL" is a specific text which may or may not be present in the rows.... Thank u in advance....
-
please any1 help me....
-
Thanks gizmola ur awesome...But I've still some problem... After creating the index when i query something, it definately reduces the rows number but still it searches from a large no of rows... Before indexing mysql> EXPLAIN SELECT country_name FROM ip2country WHERE 1388445696 BETWEEN begin_long_ip AND end_long_ip +----+-------------+------------+------+---------------+------+---------+------+--------+-------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+------------+------+---------------+------+---------+------+--------+-------------+ | 1 | SIMPLE | ip2country | ALL | NULL | NULL | NULL | NULL | 135497 | Using where | +----+-------------+------------+------+---------------+------+---------+------+--------+-------------+ 1 row in set (0.03 sec) ^ |----------------------------- (Large rows number) After indexing... mysql> EXPLAIN SELECT country_name FROM ip2country WHERE 1388445696 BETWEEN begin_long_ip AND end_long_ip; +----+-------------+------------+-------+-----------------+-----------------+---------+------+-------+-----------------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+------------+-------+-----------------+-----------------+---------+------+-------+-----------------------+ | 1 | SIMPLE | ip2country | range | both_long_index | both_long_index | 4 | NULL | 15637 | Using index condition | +----+-------------+------------+-------+-----------------+-----------------+---------+------+-------+-----------------------+ 1 row in set (0.00 sec) ^ |----------------------------- (smaller but still large) Is there any chance i can reduce the number of rows... I have indexed the the two column.. mysql> CREATE INDEX both_long_index ON ip2country(begin_long_ip,end_long_ip); Query OK, 135497 rows affected (0.64 sec) Records: 135497 Duplicates: 0 Warnings: 0 Thanks for the reply... Really u r very helpfull.... Thank u...
-
Hello plz help anybody.....
-
Thanks for the reply... Here it is what u have asked. mysql> SHOW CREATE TABLE ip2country; +------------+------------------------------------------------ | Table | Create Table +------------+------------------------------------------------ | ip2country | CREATE TABLE `ip2country` ( `id` int(11) NOT NULL AUTO_INCREMENT, `begin_long_ip` varchar(20) NOT NULL, `end_long_ip` varchar(20) NOT NULL, `country_code` varchar(3) NOT NULL, PRIMARY KEY (`id`), KEY `ip_adress` (`begin_long_ip`,`end_long_ip`) ) ENGINE=MyISAM AUTO_INCREMENT=135716 DEFAULT CHARSET=latin1 | +------------+------------------------------------------------