Jump to content

dsjoes

Members
  • Posts

    149
  • Joined

  • Last visited

    Never

Posts posted by dsjoes

  1. this is the script it is supposed to get the image url and file name from the address bar and then save the image in the pics folder. it doesn't work and there are no errors, i have never used curl before so i don't know what i am doing.

    the $img is commented out because i don't know how to add it into the code.

    <?php
    $url = $_GET["url"];
    //$img = $_GET["fileName"];
    $fullpath = "/hermes/bosweb/web230/b2302/ipg.account/test_server/pics";
    
    function save_image($url,$fullpath){
        $ch = curl_init ($url);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
        $rawdata=curl_exec($ch);
        curl_close ($ch);
        if(file_exists($fullpath)){
            unlink($fullpath);
        }
        $fp = fopen($fullpath,'x');
        fwrite($fp, $rawdata);
        fclose($fp);
    }
    ?>

     

    this is was the end of the url looks like

    save.php?url=http%3A%2F%2Fapi10.webresizer.com%2Fresizer%2Fdisplay.cgi%3Fsession%3DLO7WC4zoiw1z4pLFMIjK1dps3Q9HKP%26from%3Dresult.jpg%26type%3Djpg&filetype=jpg&filename=Group.jpg&filesize=39.07&width=385&height=289

  2. i have got the code below it is for a scroll box and  i have added the php part of it so that i can change the text from the admin page. the problem is that the scroller code is duplicating the text so it shows twice. how do i stop it from happening.

     

    scroller.php

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    
    <link rel="stylesheet" type="text/css" href="sagscroller.css" />
    
    <script src="sagscroller.js">
    
    /***********************************************
    * SAG Content Scroller- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
    * Visit http://www.dynamicDrive.com for hundreds of DHTML scripts
    * This notice must stay intact for legal use
    ***********************************************/
    
    </script>
    
    <style type="text/css">
    
    div#mysagscroller{
    width: 200px;  /*width of scroller*/
    height:250px;
    background:#FFF;
    }
    
    div#mysagscroller ul li{
    background:#FFFF48;
    color:Black;
    padding:5px;
    margin-bottom:5px; /*bottom spacing between each LI*/
    }
    
    div#mysagscroller ul li:first-letter{
    font-size:28px;
    background:#009fc6;
    color:white;
    padding:0 2px;
    margin-right:2px;
    }
    
    </style>
    
    <script>
    
    var sagscroller1=new sagscroller({
    id:'mysagscroller',
    mode: 'manual' //<--no comma following last option
    })
    </script>
    </head>
    <body>
    <div id="mysagscroller" class="sagscroller">
    <ul>
    <?php
    $con = mysql_connect("host","user","pass");
    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }
    mysql_select_db("group_news", $con);
    $result = mysql_query("SELECT * FROM News");
    while($row = mysql_fetch_array($result))
    {
    echo nl2br($row['News']);
    }
    mysql_close($con);
    ?>
    </ul>
    </div>
    </body>
    </html>

     

    sagscroller.js

    /*Sag Content Scroller (Aug 7th, 2010)
    * This notice must stay intact for usage 
    * Author: Dynamic Drive at http://www.dynamicdrive.com/
    * Visit http://www.dynamicdrive.com/ for full source code
    */
    
    //Updated Aug 28th, 10 to v1.3
    
    var sagscroller_constants={
    navpanel: {height:'16px', downarrow:'/pics/main/down1.gif', opacity:0.6, title:'Go to Next Content', background:'black'},
    loadingimg: {src:'/pics/main/ajaxloading.gif', dimensions:[100,15]}
    }
    
    function sagscroller(options){
    
    this.setting={mode:'manual', inittype:'stunted', pause:3000, animatespeed:500, ajaxsource:null, rssdata:null, refreshsecs:0, navpanel:{show:true, cancelauto:false}} //default settings
    jQuery.extend(this.setting, options) //merge default settings with options
    options=null
    this.curmsg=0
    this.addloadingpanel(jQuery, 'preload')
    if (this.setting.rssdata) //if rss contents
    	google.load("feeds", "1") //init google ajax api
    var slider=this
    jQuery(function($){ //on document.ready
    	slider.$slider=$('#'+slider.setting.id)
    	if (slider.setting.ajaxsource||slider.setting.rssdata)
    		slider.$slider.empty()
    	slider.addloadingpanel(jQuery, 'show')
    	if (slider.setting.ajaxsource) //if ajax data
    		slider.getajaxul(slider.setting.ajaxsource)
    	else if (slider.setting.rssdata){ //if rss data
    		slider.fetchfeeds()
    	}
    	else{ //if inline content
    		if (slider.setting.inittype=="onload") //load scroller when page has completely loaded?
    			$(window).load(function(){slider.init($)})
    		else //load scroller immediately and get dimensions progressively instead
    			slider.init($)
    	}
    })
    }
    
    sagscroller.prototype={
    
    getajaxul:function(path){
    	var $=jQuery, slider=this
    	this.stopscroll() //stop animation/ scrolling of slider, in the event this is a subsequent call to getajaxul()
    	this.$loadingpanel.show()
    	$.ajax({
    		url: path, //path to external content
    		async: true,
    		error:function(ajaxrequest){
    			slider.$slider.html('Error fetching content.<br />Server Response: '+ajaxrequest.responseText)
    		},
    		success:function(content){
    			slider.reloadul(content)
    			if (slider.setting.refreshsecs>0) //refetch contents every x sec?
    				setTimeout(function(){slider.getajaxul(path)}, slider.setting.refreshsecs*1000)
    		}
    	})
    },
    
    addloadingpanel:function($, mode){
    	var loadingimgref=sagscroller_constants.loadingimg
    	if (mode=="preload"){
    		var loadingimg=new Image(loadingimgref.dimensions[0], loadingimgref.dimensions[1])
    		loadingimg.src=loadingimgref.src
    		this.$loadingimg=$(loadingimg).css({position:'absolute', zIndex:1003})
    	}
    	else{
    		var sliderdimensions=[this.$slider.width(), this.$slider.height()]
    		var $loadingpanel=$('<div />').css({position:'absolute', left:0, top:0, background:'black', opacity:0.5, width:sliderdimensions[0], height:sliderdimensions[1], zIndex:1002}).appendTo(this.$slider)
    		this.$loadingimg.css({left:sliderdimensions[0]/2-loadingimgref.dimensions[0]/2, top:sliderdimensions[1]/2-loadingimgref.dimensions[1]/2}).appendTo(this.$slider)
    		this.$loadingpanel=$loadingpanel.add(this.$loadingimg)
    	}
    },
    
    addnavpanel:function(){
    	var slider=this, setting=this.setting
    	var $navpanel=$('<div class="sliderdesc"><div class="sliderdescbg"></div><div class="sliderdescfg"><div class="sliderdesctext"></div></div></div>')
    		.css({position:'absolute', width:'100%', left:0, top:-1000, zIndex:'1001'})
    		.find('div').css({position:'absolute', left:0, top:0, width:'100%'})
    		.eq(0).css({background:sagscroller_constants.navpanel.background, opacity:sagscroller_constants.navpanel.opacity}).end() //"sliderdescbg" div
    		.eq(1).css({color:'white'}).end() //"sliderdescfg" div
    		.eq(2).css({textAlign:'center', cursor:'pointer', paddingTop:'2px'}).html('<img src="'+sagscroller_constants.navpanel.downarrow+'"/>').end().end()
    		.appendTo(this.$slider)
    	var $descpanel=$navpanel.find('div.sliderdesctext').attr('title', sagscroller_constants.navpanel.title).click(function(){ //action when nav bar is clicked on
    		slider.stopscroll()
    		slider.scrollmsg(setting.mode=="auto" && !setting.navpanel.cancelauto? true : false)
    	})
    	$navpanel.css({top:this.$slider.height()-parseInt(sagscroller_constants.navpanel.height), height:sagscroller_constants.navpanel.height}).find('div').css({height:'100%'})
    },
    
    resetuls:function(){ //function to swap between primary and secondary ul
    	var $tempul=this.$mainul
    	this.$mainul=this.$secul.css({zIndex:1000})
    	this.$secul=$tempul.css({zIndex:999})
    	this.$secul.css('top', this.ulheight)
    },
    
    reloadul:function(newhtml){ //function to empty out SAG scroller UL contents then reload with new contents
    	this.$slider.find('ul').remove()
    	this.ulheight=null
    	this.curmsg=0;
    	this.$slider.append(newhtml)
    	this.init($)		
    },
    
    setgetoffset:function($li){
    	var recaldimensions=(this.setting.ajaxsource || this.setting.rssdata) && this.setting.inittype=="onload" //bool to see if script should always refetch dimensions
    	if (this.curmsg==this.$lis.length)
    		return (!this.ulheight || recaldimensions)? this.ulheight=this.$mainul.height() : this.ulheight
    	else{
    		if (!$li.data('toppos') || recaldimensions)
    			$li.data('toppos', $li.position().top)
    		return $li.data('toppos')
    	}
    },
    
    scrollmsg:function(repeat){
    	var slider=this, setting=this.setting
    	var ulheight=this.ulheight || this.$mainul.height()
    	var endpoint=-this.setgetoffset(this.$lis.eq(this.curmsg))
    	this.$mainul.animate({top: endpoint}, setting.animatespeed, function(){
    		slider.curmsg=(slider.curmsg<slider.$lis.length+1)? slider.curmsg+1 : 0
    		if (slider.curmsg==slider.$lis.length+1){ //if at end of UL
    			slider.resetuls() //swap between main and sec UL
    			slider.curmsg=1
    		}
    		if (repeat)
    			slider.scrolltimer=setTimeout(function(){slider.scrollmsg(repeat)}, setting.pause)
    	})
    	var secendpoint=endpoint+ulheight
    	this.$secul.animate({top: secendpoint}, setting.animatespeed)
    },
    
    stopscroll:function(){
    	if (this.$mainul){
    		this.$mainul.add(this.$secul).stop(true, false)
    		clearTimeout(this.scrolltimer)
    	}
    },
    
    init:function($){
    	var setting=this.setting
    	this.$loadingpanel.hide()
    	this.$mainul=this.$slider.find('ul:eq(0)').css({zIndex:1000})
    	this.$lis=this.$mainul.find('li')
    	if (setting.navpanel.show)
    		this.addnavpanel()
    	this.$secul=this.$mainul.clone().css({top:this.$mainul.height(), zIndex:999}).appendTo(this.$slider) //create sec UL and add it to the end of main UL
    	this.scrollmsg(setting.mode=="auto")
    },
    
    ///////////////////////RSS related methods below///////////////////
    
    
    fetchfeeds:function(){
    	var slider=this, rssdata=this.setting.rssdata
    	this.stopscroll() //stop animation/ scrolling of slider, in the event this is a subsequent call to fetchfeeds()
    	this.$loadingpanel.show()
    	this.entries=[] //array holding combined RSS feeds' entries from Feed API (result.feed.entries)
    	this.feedsfetched=0
    	for (var i=0; i<rssdata.feeds.length; i++){ //loop through the specified RSS feeds' URLs
    		var feedpointer=new google.feeds.Feed(rssdata.feeds[i][1]) //create new instance of Google Ajax Feed API
    		feedpointer.setNumEntries(rssdata.entries) //set number of items to display
    		feedpointer.load(function(label){
    			return function(r){
    				slider.storefeeds(r, label)
    			}
    		}(rssdata.feeds[i][0])) //call Feed.load() to retrieve and output RSS feed.
    	}	
    },
    
    storefeeds:function(result, label){
    	var thisfeed=(!result.error)? result.feed.entries : "" //get all feed entries as a JSON array or "" if failed
    	if (thisfeed==""){ //if error has occured fetching feed
    		alert("Google Feed API Error: "+result.error.message)
    	}
    	for (var i=0; i<thisfeed.length; i++){ //For each entry within feed
    		result.feed.entries[i].label=label //extend it with a "label" property
    	}
    	this.entries=this.entries.concat(thisfeed) //add entry to array holding all feed entries
    	this.feedsfetched+=1
    	if (this.feedsfetched==this.setting.rssdata.feeds.length){ //if all feeds fetched
    		if (this.setting.rssdata.groupbylabel){ //sort by label name?
    			this.entries.sort(function(a,b){
    				var fielda=a.label.toLowerCase(), fieldb=b.label.toLowerCase()
    				return (fielda<fieldb)? -1 : (fielda>fieldb)? 1 : 0
    			})
    		}
    		else{ //just sort by date
    			this.entries.sort(function(a,b){return new Date(b.publishedDate)-new Date(a.publishedDate)})
    		}
    		this.formatfeeds()
    	}
    },
    
    formatfeeds:function(){
    	function formatdate(datestr, showoptions){
    		var itemdate=new Date(datestr)
    		var parseddate=(showoptions.indexOf("datetime")!=-1)? itemdate.toLocaleString() : (showoptions.indexOf("date")!=-1)? itemdate.toLocaleDateString() : ""
    		return "<span class='datefield'>"+parseddate+"</span>"
    	}
    	var sagcontent='<ul>'
    	var slider=this, rssdata=this.setting.rssdata, entries=this.entries
    	for (var i=0; i<entries.length; i++){
    		sagcontent+='<li><a href="'+entries[i].link+'" target="'+rssdata.linktarget+'">'+entries[i].title+'</a>'
    			+'<div class="rsscontent">'
    			+(/description/.test(rssdata.displayoptions)? entries[i].content : entries[i].contentSnippet)
    			+'</div>'
    			+'<div class="rsslabel">'
    			+(/label/.test(rssdata.displayoptions)? "<b>Source("+(i+1)+"):</b> "+entries[i].label+" " : "")
    			+(/date/.test(rssdata.displayoptions)? formatdate(entries[i].publishedDate, rssdata.displayoptions): "")
    			+'</div>'
    			+'</li>\n\n'
    	}
    sagcontent+='</ul>'
    this.reloadul(sagcontent)
    if (slider.setting.refreshsecs>0) //refetch contents every x sec?
    	setTimeout(function(){slider.fetchfeeds()}, slider.setting.refreshsecs*1000)
    }
    }

  3. i have got the code below it is for a scroll box and  i have added the php part of it so that i can change the text from the admin page. the problem is that the scroller code is duplicating the text so it shows twice. how do i stop it from happening.

     

    scroller.php

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    
    <link rel="stylesheet" type="text/css" href="sagscroller.css" />
    
    <script src="sagscroller.js">
    
    /***********************************************
    * SAG Content Scroller- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
    * Visit http://www.dynamicDrive.com for hundreds of DHTML scripts
    * This notice must stay intact for legal use
    ***********************************************/
    
    </script>
    
    <style type="text/css">
    
    div#mysagscroller{
    width: 200px;  /*width of scroller*/
    height:250px;
    background:#FFF;
    }
    
    div#mysagscroller ul li{
    background:#FFFF48;
    color:Black;
    padding:5px;
    margin-bottom:5px; /*bottom spacing between each LI*/
    }
    
    div#mysagscroller ul li:first-letter{
    font-size:28px;
    background:#009fc6;
    color:white;
    padding:0 2px;
    margin-right:2px;
    }
    
    </style>
    
    <script>
    
    var sagscroller1=new sagscroller({
    id:'mysagscroller',
    mode: 'manual' //<--no comma following last option
    })
    </script>
    </head>
    <body>
    <div id="mysagscroller" class="sagscroller">
    <ul>
    <?php
    $con = mysql_connect("host","user","pass");
    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }
    mysql_select_db("group_news", $con);
    $result = mysql_query("SELECT * FROM News");
    while($row = mysql_fetch_array($result))
    {
    echo nl2br($row['News']);
    }
    mysql_close($con);
    ?>
    </ul>
    </div>
    </body>
    </html>

     

    sagscroller.js

    /*Sag Content Scroller (Aug 7th, 2010)
    * This notice must stay intact for usage 
    * Author: Dynamic Drive at http://www.dynamicdrive.com/
    * Visit http://www.dynamicdrive.com/ for full source code
    */
    
    //Updated Aug 28th, 10 to v1.3
    
    var sagscroller_constants={
    navpanel: {height:'16px', downarrow:'/pics/main/down1.gif', opacity:0.6, title:'Go to Next Content', background:'black'},
    loadingimg: {src:'/pics/main/ajaxloading.gif', dimensions:[100,15]}
    }
    
    function sagscroller(options){
    
    this.setting={mode:'manual', inittype:'stunted', pause:3000, animatespeed:500, ajaxsource:null, rssdata:null, refreshsecs:0, navpanel:{show:true, cancelauto:false}} //default settings
    jQuery.extend(this.setting, options) //merge default settings with options
    options=null
    this.curmsg=0
    this.addloadingpanel(jQuery, 'preload')
    if (this.setting.rssdata) //if rss contents
    	google.load("feeds", "1") //init google ajax api
    var slider=this
    jQuery(function($){ //on document.ready
    	slider.$slider=$('#'+slider.setting.id)
    	if (slider.setting.ajaxsource||slider.setting.rssdata)
    		slider.$slider.empty()
    	slider.addloadingpanel(jQuery, 'show')
    	if (slider.setting.ajaxsource) //if ajax data
    		slider.getajaxul(slider.setting.ajaxsource)
    	else if (slider.setting.rssdata){ //if rss data
    		slider.fetchfeeds()
    	}
    	else{ //if inline content
    		if (slider.setting.inittype=="onload") //load scroller when page has completely loaded?
    			$(window).load(function(){slider.init($)})
    		else //load scroller immediately and get dimensions progressively instead
    			slider.init($)
    	}
    })
    }
    
    sagscroller.prototype={
    
    getajaxul:function(path){
    	var $=jQuery, slider=this
    	this.stopscroll() //stop animation/ scrolling of slider, in the event this is a subsequent call to getajaxul()
    	this.$loadingpanel.show()
    	$.ajax({
    		url: path, //path to external content
    		async: true,
    		error:function(ajaxrequest){
    			slider.$slider.html('Error fetching content.<br />Server Response: '+ajaxrequest.responseText)
    		},
    		success:function(content){
    			slider.reloadul(content)
    			if (slider.setting.refreshsecs>0) //refetch contents every x sec?
    				setTimeout(function(){slider.getajaxul(path)}, slider.setting.refreshsecs*1000)
    		}
    	})
    },
    
    addloadingpanel:function($, mode){
    	var loadingimgref=sagscroller_constants.loadingimg
    	if (mode=="preload"){
    		var loadingimg=new Image(loadingimgref.dimensions[0], loadingimgref.dimensions[1])
    		loadingimg.src=loadingimgref.src
    		this.$loadingimg=$(loadingimg).css({position:'absolute', zIndex:1003})
    	}
    	else{
    		var sliderdimensions=[this.$slider.width(), this.$slider.height()]
    		var $loadingpanel=$('<div />').css({position:'absolute', left:0, top:0, background:'black', opacity:0.5, width:sliderdimensions[0], height:sliderdimensions[1], zIndex:1002}).appendTo(this.$slider)
    		this.$loadingimg.css({left:sliderdimensions[0]/2-loadingimgref.dimensions[0]/2, top:sliderdimensions[1]/2-loadingimgref.dimensions[1]/2}).appendTo(this.$slider)
    		this.$loadingpanel=$loadingpanel.add(this.$loadingimg)
    	}
    },
    
    addnavpanel:function(){
    	var slider=this, setting=this.setting
    	var $navpanel=$('<div class="sliderdesc"><div class="sliderdescbg"></div><div class="sliderdescfg"><div class="sliderdesctext"></div></div></div>')
    		.css({position:'absolute', width:'100%', left:0, top:-1000, zIndex:'1001'})
    		.find('div').css({position:'absolute', left:0, top:0, width:'100%'})
    		.eq(0).css({background:sagscroller_constants.navpanel.background, opacity:sagscroller_constants.navpanel.opacity}).end() //"sliderdescbg" div
    		.eq(1).css({color:'white'}).end() //"sliderdescfg" div
    		.eq(2).css({textAlign:'center', cursor:'pointer', paddingTop:'2px'}).html('<img src="'+sagscroller_constants.navpanel.downarrow+'"/>').end().end()
    		.appendTo(this.$slider)
    	var $descpanel=$navpanel.find('div.sliderdesctext').attr('title', sagscroller_constants.navpanel.title).click(function(){ //action when nav bar is clicked on
    		slider.stopscroll()
    		slider.scrollmsg(setting.mode=="auto" && !setting.navpanel.cancelauto? true : false)
    	})
    	$navpanel.css({top:this.$slider.height()-parseInt(sagscroller_constants.navpanel.height), height:sagscroller_constants.navpanel.height}).find('div').css({height:'100%'})
    },
    
    resetuls:function(){ //function to swap between primary and secondary ul
    	var $tempul=this.$mainul
    	this.$mainul=this.$secul.css({zIndex:1000})
    	this.$secul=$tempul.css({zIndex:999})
    	this.$secul.css('top', this.ulheight)
    },
    
    reloadul:function(newhtml){ //function to empty out SAG scroller UL contents then reload with new contents
    	this.$slider.find('ul').remove()
    	this.ulheight=null
    	this.curmsg=0;
    	this.$slider.append(newhtml)
    	this.init($)		
    },
    
    setgetoffset:function($li){
    	var recaldimensions=(this.setting.ajaxsource || this.setting.rssdata) && this.setting.inittype=="onload" //bool to see if script should always refetch dimensions
    	if (this.curmsg==this.$lis.length)
    		return (!this.ulheight || recaldimensions)? this.ulheight=this.$mainul.height() : this.ulheight
    	else{
    		if (!$li.data('toppos') || recaldimensions)
    			$li.data('toppos', $li.position().top)
    		return $li.data('toppos')
    	}
    },
    
    scrollmsg:function(repeat){
    	var slider=this, setting=this.setting
    	var ulheight=this.ulheight || this.$mainul.height()
    	var endpoint=-this.setgetoffset(this.$lis.eq(this.curmsg))
    	this.$mainul.animate({top: endpoint}, setting.animatespeed, function(){
    		slider.curmsg=(slider.curmsg<slider.$lis.length+1)? slider.curmsg+1 : 0
    		if (slider.curmsg==slider.$lis.length+1){ //if at end of UL
    			slider.resetuls() //swap between main and sec UL
    			slider.curmsg=1
    		}
    		if (repeat)
    			slider.scrolltimer=setTimeout(function(){slider.scrollmsg(repeat)}, setting.pause)
    	})
    	var secendpoint=endpoint+ulheight
    	this.$secul.animate({top: secendpoint}, setting.animatespeed)
    },
    
    stopscroll:function(){
    	if (this.$mainul){
    		this.$mainul.add(this.$secul).stop(true, false)
    		clearTimeout(this.scrolltimer)
    	}
    },
    
    init:function($){
    	var setting=this.setting
    	this.$loadingpanel.hide()
    	this.$mainul=this.$slider.find('ul:eq(0)').css({zIndex:1000})
    	this.$lis=this.$mainul.find('li')
    	if (setting.navpanel.show)
    		this.addnavpanel()
    	this.$secul=this.$mainul.clone().css({top:this.$mainul.height(), zIndex:999}).appendTo(this.$slider) //create sec UL and add it to the end of main UL
    	this.scrollmsg(setting.mode=="auto")
    },
    
    ///////////////////////RSS related methods below///////////////////
    
    
    fetchfeeds:function(){
    	var slider=this, rssdata=this.setting.rssdata
    	this.stopscroll() //stop animation/ scrolling of slider, in the event this is a subsequent call to fetchfeeds()
    	this.$loadingpanel.show()
    	this.entries=[] //array holding combined RSS feeds' entries from Feed API (result.feed.entries)
    	this.feedsfetched=0
    	for (var i=0; i<rssdata.feeds.length; i++){ //loop through the specified RSS feeds' URLs
    		var feedpointer=new google.feeds.Feed(rssdata.feeds[i][1]) //create new instance of Google Ajax Feed API
    		feedpointer.setNumEntries(rssdata.entries) //set number of items to display
    		feedpointer.load(function(label){
    			return function(r){
    				slider.storefeeds(r, label)
    			}
    		}(rssdata.feeds[i][0])) //call Feed.load() to retrieve and output RSS feed.
    	}	
    },
    
    storefeeds:function(result, label){
    	var thisfeed=(!result.error)? result.feed.entries : "" //get all feed entries as a JSON array or "" if failed
    	if (thisfeed==""){ //if error has occured fetching feed
    		alert("Google Feed API Error: "+result.error.message)
    	}
    	for (var i=0; i<thisfeed.length; i++){ //For each entry within feed
    		result.feed.entries[i].label=label //extend it with a "label" property
    	}
    	this.entries=this.entries.concat(thisfeed) //add entry to array holding all feed entries
    	this.feedsfetched+=1
    	if (this.feedsfetched==this.setting.rssdata.feeds.length){ //if all feeds fetched
    		if (this.setting.rssdata.groupbylabel){ //sort by label name?
    			this.entries.sort(function(a,b){
    				var fielda=a.label.toLowerCase(), fieldb=b.label.toLowerCase()
    				return (fielda<fieldb)? -1 : (fielda>fieldb)? 1 : 0
    			})
    		}
    		else{ //just sort by date
    			this.entries.sort(function(a,b){return new Date(b.publishedDate)-new Date(a.publishedDate)})
    		}
    		this.formatfeeds()
    	}
    },
    
    formatfeeds:function(){
    	function formatdate(datestr, showoptions){
    		var itemdate=new Date(datestr)
    		var parseddate=(showoptions.indexOf("datetime")!=-1)? itemdate.toLocaleString() : (showoptions.indexOf("date")!=-1)? itemdate.toLocaleDateString() : ""
    		return "<span class='datefield'>"+parseddate+"</span>"
    	}
    	var sagcontent='<ul>'
    	var slider=this, rssdata=this.setting.rssdata, entries=this.entries
    	for (var i=0; i<entries.length; i++){
    		sagcontent+='<li><a href="'+entries[i].link+'" target="'+rssdata.linktarget+'">'+entries[i].title+'</a>'
    			+'<div class="rsscontent">'
    			+(/description/.test(rssdata.displayoptions)? entries[i].content : entries[i].contentSnippet)
    			+'</div>'
    			+'<div class="rsslabel">'
    			+(/label/.test(rssdata.displayoptions)? "<b>Source("+(i+1)+"):</b> "+entries[i].label+" " : "")
    			+(/date/.test(rssdata.displayoptions)? formatdate(entries[i].publishedDate, rssdata.displayoptions): "")
    			+'</div>'
    			+'</li>\n\n'
    	}
    sagcontent+='</ul>'
    this.reloadul(sagcontent)
    if (slider.setting.refreshsecs>0) //refetch contents every x sec?
    	setTimeout(function(){slider.fetchfeeds()}, slider.setting.refreshsecs*1000)
    }
    }

  4. i have done it the example.com/update.php?Update=7 way because i have used this method before but when the update page opens it shows the correct id but the other fields are wrong they are showing the first ids results.

     

    update.php

    <?php
    include("dbinfo1.inc.php");
    $link=mysql_connect($localhost,$username,$password);
    mysql_select_db($database) or die("unable to connect");
    $result=mysql_query("SELECT * FROM Testimonials where id") or die("ERROR:".mysql_error());
    $row=mysql_fetch_array($result,MYSQL_ASSOC); 
    $file = $_GET["Update"];
    print '<form method="POST" action="updated.php">';
    print 'id:<input name="id" value="'.$file.'">';
    print '<br />';
    print 'Name:<input type="text" name="Name" value="'.$row['Name'].'" />';
    print '<br />';
    print 'Message:<input type="text" name="Message" value="'.$row['Message'].'" />';
    print '<br />';
    print 'Download:<input type="text" name="Download" value="'.$row['Download'].'" />';
    print '<br />';
    print '<input type="submit" name="submit" value="Update">';
    mysql_close($link);
    ?>

     

    updated.php

    <META HTTP-EQUIV="refresh" content="0;URL=index.php"><?php 
    include("dbinfo1.inc.php");
    $link=mysql_connect($localhost,$username,$password);
    mysql_select_db($database) or die("unable to connect");
    $id=$_POST['id'];
    $Name=$_POST['Name'];
    $Message=$_POST['Message'];
    $Download=$_POST['Download'];
    mysql_query("UPDATE Testimonials SET Name='$Name', Message='$Message', Download='$Download' where id='$id'") or die("ERROR:".mysql_error());
    echo "thanks";
    mysql_close($link);
    ?>

  5. i have got the update script below it works but what i want to know is could i change the id text box into a drop down that lists all of the ids in the database and when one is selected it shows the other information in the other fields next to it so it is easier to edit the required field.

    update.php

    <?php
    include("dbinfo1.inc.php");
    $link=mysql_connect($localhost,$username,$password);
    mysql_select_db($database) or die("unable to connect");
    $result=mysql_query("SELECT * FROM Testimonials where id") or die("ERROR:".mysql_error());
    $row=mysql_fetch_array($result,MYSQL_ASSOC); 
    print '<form method="POST" action="updated.php">';
    print 'id:<input name="id" value="'.$row['id'].'">';
    print '<br />';
    print 'Name:<input type="text" name="Name" value="'.$row['Name'].'" />';
    print '<br />';
    print 'Message:<input type="text" name="Message" value="'.$row['Message'].'" />';
    print '<br />';
    print 'Download:<input type="text" name="Download" value="'.$row['Download'].'" />';
    print '<br />';
    print '<input type="submit" name="submit" value="Update">';
    mysql_close($link);
    ?>

     

    updated.php

    <META HTTP-EQUIV="refresh" content="0;URL=index.php"><?php 
    include("dbinfo1.inc.php");
    $link=mysql_connect($localhost,$username,$password);
    mysql_select_db($database) or die("unable to connect");
    $id=$_POST['id'];
    $Name=$_POST['Name'];
    $Message=$_POST['Message'];
    $Download=$_POST['Download'];
    mysql_query("UPDATE Testimonials SET Name='$Name', Message='$Message', Download='$Download' where id='$id'") or die("ERROR:".mysql_error());
    echo "thanks";
    mysql_close($link);
    ?>

  6. OK, when you insert the values into the database, are you using any logic strip out the slashes added by magic_quotes_gpc before using mysql_real_escape_string? If you don't, the data ends up doubly escaped resulting in a set of the slashes making its way into the database.

     

    Should look something like this for sanitizing and inserting the data:

    if( get_magic_quotes_gpc() ) {
         $value = mysql_real_escape_string(stripslashes($_POST['value']));
    } else {
         $value = mysql_real_escape_string($_POST['value']);
    }
    

    thanks that has worked

  7. when i upload a link using the form below it adds \ into it like this <a href=\"http://www.google.co.uk\" target=\"_blank\">test</a> and the link is unusable with them any way to stop this

     

    <?php
    include("dbinfo.inc.php");
    mysql_connect($localhost,$username,$password);
    @mysql_select_db($database) or die( "Unable to select database");
    $query="SELECT * FROM News WHERE id='$id'";
    $result=mysql_query($query);
    $num=mysql_numrows($result); 
    mysql_close();
    
    $i=0;
    while ($i < $num) {
    $News=mysql_result($result,$i,"News");
    
    
    ?>
    <form action="updated.php">
    <input type="hidden" name="ud_id" value="<? echo "$id"; ?>">
    News:<br> <TEXTAREA NAME="ud_News" COLS=40 ROWS=6><? echo "$News"?></TEXTAREA><br>
    <input type="Submit" value="Update">
    </form>
    
    <?php
    ++$i;
    } 
    ?>

  8. HTML uses <br> tags to indicate a newline. Hence, you'll need to insert a <br> tag everywhere there is a newline char.

     

    There is a builtin function for this: nl2br.

     

    This only needs to be used when youi want to display your data, not on the way into the database.

     

    thanks that is what i was looking for i didn't want to use <br> all the time

  9. if i enter

    hello

     

    hello

     

    it shows as

    hello hello

    on the code below but in mysql database it shows the gap in the first bit

     

     

    this displays it

    <?php
    $con = mysql_connect("","","");
    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }
    mysql_select_db("", $con);
    $result = mysql_query("SELECT * FROM News");
    while($row = mysql_fetch_array($result))
    {
    echo $row['News'];
    }
    mysql_close($con);
    ?>

     

    and this submits to the database

    <?php
    include("dbinfo.inc.php");
    mysql_connect($localhost,$username,$password);
    @mysql_select_db($database) or die( "Unable to select database");
    $query="SELECT * FROM News WHERE id='$id'";
    $result=mysql_query($query);
    $num=mysql_numrows($result); 
    mysql_close();
    
    $i=0;
    while ($i < $num) {
    $News=mysql_result($result,$i,"News");
    
    
    ?>
    <form action="updated.php">
    <input type="hidden" name="ud_id" value="<? echo "$id"; ?>">
    News:<br> <TEXTAREA NAME="ud_News" COLS=40 ROWS=6><? echo "$News"?></TEXTAREA><br>
    <input type="Submit" value="Update">
    </form>
    
    <?php
    ++$i;
    } 
    ?>

  10. yes it is showing that it is getting the file name and everything fine. yes it has header and body tags and no html syntax errors.

     

    the folder locations are wrong in the script the first one has the wrong source folders it should be the same as the one near the bottom and it still won't play in internet explorer

  11. the below works in firefox but doesn't work in internet explorer is there something wrong with it

    <?php  
    $file = $_GET["Watch"];
    echo "<OBJECT ID='MediaPlayer' WIDTH='450' HEIGHT='310' CLASSID='clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6'
    STANDBY='Loading Windows Media Player components...' TYPE='application/x-oleobject'>
    <PARAM NAME=".$file." VALUE='../audio/audio_files/".$file.".wmv'>
    <PARAM NAME='autostart' VALUE='false'>
    <PARAM NAME='ShowControls' VALUE='true'>
    <PARAM NAME='ShowStatusBar' VALUE='true'>
    <PARAM NAME='ShowDisplay' VALUE='false'>
    <EMBED TYPE='application/x-mplayer2' SRC='../dvds/dvd_files/".$file.".wmv' NAME=".$file."
    WIDTH='450' HEIGHT='310' ShowControls='1' ShowStatusBar='1'  ShowDisplay='0' autostart='0'></EMBED>
    </OBJECT>";
    ?>

  12. the script below works but i have started getting this error

    Warning: Cannot modify header information - headers already sent by (output started at /hermes/bosweb/web230/b2302/ipg.myaccount/test_server/admin/index.php:10) in /hermes/bosweb/web230/b2302/ipg.myaccount/test_server/admin/index.php on line 95

    line 95 is this bit

    header('Location: index.php');
    

    <?php
    // Set Global Vars
    $HOST = "xxxxxxxxxx";
    $USERNAME = "xxxxxxxxx";
    $PASSWORD = "xxxxxxxxx";
    $DATABASE = "group";
    $TABLE = "Testimonials";
    // Establish a connection
    mysql_connect($HOST, $USERNAME, $PASSWORD) or die(mysql_error());
    mysql_select_db($DATABASE) or die(mysql_error());
    //==================================================================
    // Check if anything is posted
    //==================================================================
    if (isset($_POST['delete'])) {
        $sql = ("delete from $TABLE where ");
        for ($i = 0; $i < count($_POST['checkbox']); $i++) {
            if ($i != 0) {
                $sql.= "OR ";
            }
            $sql .= " id='" . $_POST['checkbox'][$i] . "'";
            //==================================================================
            // Select file to unlink based on id posted
            //==================================================================
            $sql_file_unlink = "select Download from $TABLE where id = {$_POST['checkbox'][$i]}";
            $result_file_unlink =  mysql_query($sql_file_unlink);
            $row_file_link = mysql_fetch_assoc($result_file_unlink);
            if($row_file_link) {
                 unlink('../testimonial_files/' . $row_file_link['Download']);
            }
            //==================================================================
        }
        $result = mysql_query($sql);
        header('Location: index.php');
        exit;
    } else {
        // select sql here
        $sql = "select * from `$TABLE` order by `id`;";
        $result = mysql_query($sql);
    }
    ?>
    <table  align="center" width="400" border="0" cellspacing="1" cellpadding="0">
         <tr>
          <td colspan="6" align="center"><strong>Testimonials</strong> </td>
        </tr>
        <tr>
            <td><form name="delete" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">
                    <table width="400" border="1" cellpadding="3" cellspacing="1">
                        <tr>
                            <td align="center"><strong>Select</strong></td>
                            <td align="center"><strong>ID</strong></td>
                            <td align="center"><strong>Name</strong></td>
                            <td align="center"><strong>Description</strong></td>
                            <td align="center"><strong>Download</strong></td>
                            <td align="center"><strong>Last Modified</strong></td>
                        </tr>
                        <?php $row = mysql_fetch_assoc($result); ?><?php do { ?>
                            <tr>
                                <td align="center">
                                    <input name="checkbox[]" type="checkbox" id="checkbox[]" value="<?php echo $row['id']; ?>">
                                </td>
                                <td align="center"><?php echo $row['id']; ?></td>
                                <td align="center"><?php echo $row['Name']; ?></td>
                                <td align="center"><?php echo $row['Message']; ?></td>
                                <td align="center"><a href="../testimonial_files/<?php echo $row['Download']; ?>">Download</a></td>
                                <td align="center"><?php echo date("j/n/y", strtotime($row["Modified"])) ?></td>
                            </tr>
                          <?php
                          } while ($row = mysql_fetch_assoc($result)); ?>
                            <tr>
                                <td colspan="6" align="center"><input name="delete" type="submit" id="delete" value="Delete"></td>
                            </tr>
                        </table>
                    </form>
                </td>
            </tr>
        </table>

  13. i have contacted my host and they said

    I have checked and noticed that your website is showing the server time. It is not possible to overwrite the server time. Hence you need to upload a script in your website so that it shows the desired time zone. I have uploaded a test script at http://example.com/time.php which shows the time according to timezone = Europe/London.

     

    so i'm using the below code which i include into pages that i need it for it works when i echo the the date

    date_default_timezone_set('Europe/London');

     

    but mysql time still shows the server time how do i stop this. i am using the timestamp in mysql to capture the date and time info was inserted

×
×
  • 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.