Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL PHP
<?php 
ini_set("memory_limit","1024M");
set_time_limit(0);
$link=mysql_connect('localhost','root','youmint');
if (!$link) {
    die('Could not connect: ' . mysql_error());
   }
  
mysql_select_db('ajay_wp');
 require("xml.class.php");
 require_once("couponfunction.php");
 $ObjCoupon= new Addcoupons();
	$ObjXML = new XML();
    $ArrField = array();
$Field='merchantid,merchantname,merchanturl,merchantlogo,merchantsmalllogo,offerset';
	if(isset($Field) && $Field != '' ) {
	   $Field = $Field;
	   $ArrField  = explode(',' , $Field);
	}
	
	$AllCoupon = $ObjXML->GetCouponFromXML($ArrField, 'http://www.saverr.com/webservicexml/xml/addedofferxml.xml');
	echo '<pre>';
	print_r($AllCoupon);
	 die;
$tc=count($AllCoupon);	
foreach($AllCoupon as $coupondata)	
	{
	$cd		    =explode('~~',$coupondata);
	$Merchantid	    =$cd[0];
	$merchantname	    =$cd[1];
	$merchanturl	    =$cd[2];
	$merchantlogo	    =$cd[3];
	$merchantsmalllogo  =$cd[4];
	$OfferDetails	    =$cd[5];*/
 
preg_match_all("/<offerID>(.*?)<\/offerID>/s",$OfferDetails,$offerid);
preg_match_all("/<offerName>(.*?)<\/offerName>/s",$OfferDetails,$offerName);
preg_match_all("/<offerDescription>(.*?)<\/offerDescription>/s",$OfferDetails,$offerDescription);
preg_match_all("/<couponCode>(.*?)<\/couponCode>/s",$OfferDetails,$couponCode);
preg_match_all("/<offerType>(.*?)<\/offerType>/s",$OfferDetails,$offerType);
preg_match_all("/<offercategory>(.*?)<\/offercategory>/s",$OfferDetails,$offercategory);
preg_match_all("/<offerTags>(.*?)<\/offerTags>/s",$OfferDetails,$offerTags);
preg_match_all("/<offerAmount>(.*?)<\/offerAmount>/s",$OfferDetails,$offerAmount);
preg_match_all("/<offerPercentAmount>(.*?)<\/offerPercentAmount>/s",$OfferDetails,$offerPercentAmount);
preg_match_all("/<offerAddedDate>(.*?)<\/offerAddedDate>/s",$OfferDetails,$offerAddedDate);
preg_match_all("/<offerStartDate>(.*?)<\/offerStartDate>/s",$OfferDetails,$offerStartDate);
preg_match_all("/<offerEndDate>(.*?)<\/offerEndDate>/s",$OfferDetails,$offerEndDate);
preg_match_all("/<offerUrl>(.*?)<\/offerUrl>/s",$OfferDetails,$offerUrl);
 
for($i=0;$i<count($offerid[1]);$i++)
		{
 
$Merchantid=$Merchantid;
$Merchantname=addslashes($merchantname);
$Merchanturls=$merchanturl;
$Merchantlogo=$merchantlogo;
$merchantSmalllogo=$merchantsmalllogo;
$offerIds=$offerid[1][$i];
$offername=addslashes($offerName[1][$i]);
$offerDesc=addslashes($offerDescription[1][$i]);
$couponCodes=$couponCode[1][$i];
$offerTypes=$offerType[1][$i];
$offerCategories=addslashes($offercategory[1][$i]);
$offerTag=addslashes(htmlentities($offerTags[1][$i]));
$offerAmounts=$offerAmount[1][$i];
$offerPercentAmount=addslashes($offerPercentAmount[1][$i]);
$offerAddedDates=$offerAddedDate[1][$i];
$offerStartDates=$offerStartDate[1][$i];
$offerEndDates=$offerEndDate[1][$i];
$offerUrls=addslashes($offerUrl[1][$i]);
if(!empty($offerIds)){
mysql_query("INSERT INTO `addedallcoupons` (`pid`, `Merchantid`, `Merchantname`, `Merchanturls`, `Merchantlogo`, `merchantSmalllogo`, `offerIds`, `offername`, `offerDesc`, `couponCodes`, `offerTypes`, `offerCategories`, `offerTag`, `offerAmounts`, `offerPersentAmount`, `offerAddedDates`, `offerStartDates`, `offerEndDates`, `offerUrls`,`postid`) VALUES (NULL, '$Merchantid', '$merchantname', '$merchanturl', '$merchantlogo', '$merchantSmalllogo', '$offerid', '$offerName', '$offerDescription', '$couponCode', '$offerType', '$offercategory', '$offerTags', '$offerAmount', '$offerPercentAmount', '$offerAddedDate', '$offerStartDate', '$offerEndDate', '$offerUrl',0)");
	
		}
		}		
	}
//Insert into Post

$allcoupon=mysql_query("SELECT * FROM `addedallcoupons` where `postid`=0");
while($allcouponArray=mysql_fetch_array($allcoupon))
{
 
$offerid=$allcouponArray['offerIds'];
$title=$allcouponArray['offername'];
$store=$allcouponArray['Merchantname'];
$offertype=$allcouponArray['offerTypes'];
$description=$allcouponArray['offerDesc'];
$merchanturl=$allcouponArray['offerUrls'];
$imagesrc=$allcouponArray['Merchantlogo'];
$code=$allcouponArray['couponCodes'];
$startdate=$allcouponArray['offerStartDates'];
$enddate=$allcouponArray['offerEndDates'];
$catname=$allcouponArray['offerCategories'];
$taxonomyidArray=$ObjCoupon->TaxonomyIdArray($catname);
$taxonomystoreidArray = $ObjCoupon->TaxonomyIdStoreArray($store);
$postid=$ObjCoupon->InsertCoupons($taxonomyidArray,$taxonomystoreidArray ,$offerid,$title,$offertype,$description,$merchanturl,$imagesrc,$code,$startdate,$enddate);
 
if($postid!=0){
mysql_query("update `addedallcoupons` set `postid`=$postid where `offerId`=$offerid");
}
 
}
 

 

 
problem is that i have loaded the data into phpadmin and having problems in connecting code to sql and displaying this on browser!! help needed!!
Posted 2-Jul-13 22:38pm
Comments
thanh_bkhn at 3-Jul-13 4:27am
   
Can you tell what is the error message?
nkhldhar at 3-Jul-13 5:47am
   
actually this php code is to be run on a browser and problem is it is showing the following :
 
Not Found
 
The requested URL /xxx/xxx_live.com/Code/xxxlive/ajay/wp/coupon/insertallcoupons.php was not found on this server.
 
Apache/2.2.17 (Fedora) Server at 192.168.1.90 Port 80
nkhldhar at 3-Jul-13 6:01am
   
u there????
thanh_bkhn at 3-Jul-13 6:04am
   
So I think the problem is your file is at the wrong place, not in your code.
nkhldhar at 3-Jul-13 6:09am
   
no its the ryt address ive checked that

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web01 | 2.8.1411022.1 | Last Updated 3 Jul 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100