Jump to content

melting_dog

Members
  • Posts

    118
  • Joined

  • Last visited

    Never

Posts posted by melting_dog

  1. Use PHP to query the DB and create some vars,

    Write the vars to a txt file adding in the necessary JSON brackets,

    Use PHP's JSON Encode to encode the txt file to JSON

    Repeat when ever the database is updated

    But...why?  Why not make a PHP page that spits out a json-formatted document from the database every time you call it?  Why all these extra steps?

     

    Thanks for the response! And to answer your question of why: because I am trying to learn the best way of approaching this. Are you suggesting using the having my JavaScript read directly from the .php file using JSONencode?

  2. Hi all,

     

    I am trying to figure out a way to make a JSON script more dynamic and responsive to a database.

     

    I am forming and idea in my head and just wanted to run it past people here - not expecting any coding answers just want to know if it is possible.

     

    Use PHP to query the DB and create some vars,

    Write the vars to a txt file adding in the necessary JSON brackets,

    Use PHP's JSON Encode to encode the txt file to JSON

    Repeat when ever the database is updated

     

    What do you guys think? Is this a plausible scenario?

  3. Hi all. I have a simple mail script that doesnt appear to be working. I get a:

     

    Parse error: syntax error, unexpected T_STRING

     

    error:

     

    My code is:

     

    mail("$webmaster_email", 
    "RSVP from WC Entry Form",
       "From: $email \n 
       Name: $firstname $lastname \n
       Phone Number: $phone \n
       Address: $postal \n 
    Other Artist: $otherband \n
       Recieve more news: $newsagree" );

     

    But i cant seem to see whats wrong with it. Can anyone point me in the right direction?

     

    Thanks

  4. Hi all,

     

    I am using a ModX CMS and want to have my own php file (my.php) in the root directory that connects to the database independently of the CMS.

     

    However, I am unsure of how to connect to the database securely ie: so that no-one sees my username and password etc.

     

    The CMS has its own config file with all the DB connection info already in variables that is locked away in a folder with permissions set so that browsers cannot access it but I am unsure how to pass those varaibles to my.php (this occurs in the index.php file in the root but I have been unable to replicate it).

     

    Can anyone suggest a way for me to do this?

     

    Thanks!

  5. You cannot write to a file using client side JavaScript. What exactly are you trying to achieve?

     

    Thanks for the reply.

     

    Basically, I am trying to transfer some data from one site to another, like how the Twitter API does.

     

    My goal is to have other sites updated from one, central site.

     

    Would I have to use PHP to achieve this?

  6. Hi all,

     

    A simple one but it seems I am running into trouble.

     

    All I want is to add a JavaScript variable to the html body as part of an <a> tag, eg: <a href="JAVASCRIPT VARIABLE">Click Me</a>

     

    Here what I have:

     

    <div class="headerrefresh"><script>document.write('<a href="'+pathname+'">Refresh</a>')</script></div>

     

    Any help woud be very appreciated!

     

    Thanks!

  7. OK got it working using:

    $(document).ready(function() {

     

                $('#tab-bar a').on('click', function(e){

                e.preventDefault();

                $('#pages .current').removeClass('current');

                $(this.hash).addClass('current');

                });

            });

     

    Main issue was there was no space between #pages and .current

     

    Cheers

  8. You might want to describe your problem while your here.

     

    Sorry -

     

    So the code is meant to show the div related to the a tag thats been clicked in  <footer>. If I click <a href="#camera">Camera</a> I want <div id="camera">Camera</div> to show - ie: become <div id="camera" class="current">Camera</div> as .current has the display:block; css, whist all other divs within #pages have display:none; css.

     

    Right now when I run the script simply nothing happens. I am hoping that someone with a fresh set of eyes and a little more experience can help me out.

     

    Thanks!

  9. Hi all,

     

    I know this is a bit amiguous but I am hoping someone can suggest something.

     

    I have what should be a simple piece of code - just hides and shows divs when a link is clicked.

     

    JQuery is:

     
    <script type="text/javascript" src="js/jquery.js"></script>
    <script type="text/javascript">
    
    $(document).ready(function() {
    
                $('#tab-bar a').on('click', function(e){
                e.preventDefault();
                var nextPage = $(e.target.hash);
                $('#pages.current').removeClass('current');
                });
            });
            
        </script>

     

    CSS:

    #pages > div {
        display: none;
    }
    
    #pages > div.current {
        display: block;
    }

     

    HTML:

    <div id="wrapper">
              
              <div id="main-content">
                    <!--<div id="accelerometer">Waiting for accelerometer...</div>-->
                  <div id="pages">
                      <div id="map" class="current">
                          Map
                      </div>
                      
                      <div id="camera">
                          Camera
                      </div>
                      
                      <div id="twitter">
                          Twitter
                      </div>
                      
                  </div>
              </div><!--MAIN-CONTENT-->
          </div><!--WRAPPER-->
          
          <footer>
              <ul id="tab-bar">
                  <li>
                      <a href="#map">Map</a>
                  </li>
                  
                  <li>
                      <a href="#camera">Camera</a>
                  </li>
                  
                  <li>
                      <a href="#twitter">Twitter</a>
                  </li>
              </ul>
          </footer>

     

    I have tested to see if jquery is loaded and its ok. I have tested to see if the click is working using console.log and thats ok - I just dont know what could be wrong!

     

    Any help would be greatly appreciated! Thanks!

  10. Hi all,

     

    I have been experimenting with a JQuery Twitter Plugin. In it, is has this line:

     

    //place the tweet within a paragraph tag within the main div.

    holder.append("<p>"+item.text.makeLinks()+"</p>");

     

    Now, that makes sense: It simply puts the Tweet in paragraph tags and appends it to the holder. But I am unsure of what makeLinks() does. In fact it causes an error:

     

    Uncaught TypeError: Object Tweet text blah blah blah http://t.co/W6GNA4ps has no method 'makeLinks'

     

    If I remove the makeLinks() it runs fine but any links in the tweet to it do not work.

     

    Heres the full code:

     

    (function($){
    //Creating Function called Twitterize
        $.fn.twitterize = function(username,options){
     //check to see if the username has been set.
            if (username){
                //create an object full of default settings.
                var defaultSettings = {
                    count:'1'
                }
               // Finds which default settings have been overwritten by the options object
                // and creates a new object with all the new and untouched settings.
                var settings = $.extend(defaultSettings, options);
    			 // The URL for the Twitter JSON API.
                		var url = "http://twitter.com/status/user_timeline/"+username+".json?count="+settings.count+"&callback=?";
                		//Variable to get around scope problem in callback function.
        	        var holder = this;
                		//Contact Twitter
    	            $.getJSON(url,
            		    //This function is called when twitter responds with the appropriate information.
    	            function(data){
            		        //Step through each tweet.
                    		$.each(data, function(i, item) {
    	                    //place the tweet within a paragraph tag within the main div.
            		            holder.append("<p>"+item.text.makeLinks()+"</p>");
                    });
                });  
            }
    	else{
                //Username paramater has not been set.
                console.debug("jquery plugin twitterize requires a username! Check your parameters");
            }
            //Return itself
            return this;
        };//END TWITTERIZE    
    })(jQuery);
    

     

    Any help would be appreciate!

  11. Hi all,

     

    I have been following a few JavaScript and JQuery tutorials and they always seem to use something called init. But they never explain it properly.

     

    EG:

    init: function(config) {

    $.extend(this.config, config);

    $('<button></button>', {

    text: 'Contact Me'

    })

     

    OR:

     

    contactForm.init({

    effect: 'fadeToggle',

    speed: 500

    });

     

    Couldnt find any info on the net either. Was wondering if someone could explain it to me? I no it standards for initialise but thats about it

     

    Thanks!

  12. Hi all,

     

    I need to make a site that is entirely client side. I was wondering if any one new if there was a JavaScript equivilant of PHP's include()?

     

    IE I want to include my header.html file at the top of every html page I make, rather then writing the same stuff again and again.

     

    Any help would be great! Thanks!

  13. Tell me exactly what a view source shows.

    Are the forms there but they simply have no values at all?

     

    Sorry Im not sure what you mean exactly. The values in the hidden fields are just not being sent to the receiving page...

  14. 1. the form action can just be action=''

     

    2. Have you looked at a view source to make sure the values are what you expect them to be?

     

    3. what does the function _e() do?

     

    Hi AyKay,

     

    Thanks for the response. To answer your questions:

     

    1 and 3: I am actually making a Wordpress Plugin so these things are actually necessary (apparently)

     

    2: No values are being sent whatsoever

     

    Cheers

  15. Hi All,

     

    I am having a bit of difficulty with a form I've built that has some PHP elements in it. The issue is it is just not sending the values (which are in hidden fields).

     

    Code is:

     

    while($row = mysql_fetch_array($result)){
    
    		echo '<tr style="padding: 15px;">';
    		echo '<td>' . $row['product_id'] . '</td>';
    		echo '<td>' . $row['name'] . '</td>';
    		echo '<td>' . $row['catalogue_id'] . '</td>';
                             ?>            
    		<td>
                <form method="post"  enctype="multipart/form-data" action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); ?>">
                <!--Hidden Field Checks to see if form has already been sent-->
    		<input type="hidden" name="editform" value="Y">
                <!--Hidden Fields for Edit Job-->
    		<input type="hidden" name="prodid" value="<?php echo $row['product_id'] ?>">           
                <input type="hidden" name="prodname" value="<?php echo $row['name'] ?>">
                <input type="hidden" name="catalogue_id" value="<?php echo $row['catalogue_id'] ?>">
                <input type="hidden" name="full_description" value="<?php echo $row['full_description'] ?>">    
                <input type="submit" name="Edit" value="<?php _e('Edit', 'pmimp_trdom' ) ?>" />
                </form>
                </td>
    

     

    Would it have something to do with splitting up the php tags?

    Any help would be apprecited!

     

    Thanks!

  16. Hi all,

     

    Thanks for the responses. I had tried all that but now have found the issue. I should have mentioned first off - I am making a Wordpress Plugin and thus I have since found out WP needs to use certain 'tags'.

     

    So for WP plugins this is the correct path:

     

    $path = WP_PLUGIN_DIR."/prodadd/uploads/".$new_image_name;

     

    OR to get to the Wordpress Sites root:

     

    $path = ABSPATH."/uploads/".$new_image_name;

     

    Thanks all!

  17. Thanks for that.

     

    I have updated both those:

     

        //Form data sent
    
    	$product_name = $_POST['product_name'];  
    	$product_active = $_POST['product_active'];  
    	$product_cat = $_POST['product_cat'];  
    	$product_desc = $_POST['product_desc'];  
    	$prod_inoutdoor = $_POST['prod_inoutdoor']; 
    	$prod_stackable = $_POST['prod_stackable']; 
    	$prod_discounted = $_POST['prod_discounted']; 
    	//IMAGE FILE	
    	$file_name = $_FILES['product_img']['name'];
    
    	echo '<p>File Name:' . $file_name . '</p>';
    	//IMAGE UPLOAD
    	// random 4 digit to add to file name
    	$random_digit=rand(0000,9999);
    
    	//combine random digit to you file name to create new file name
    	//use dot (.) to combile these two variables
    	$new_image_name = $random_digit.$file_name;
    
    	echo $new_image_name;
    
    
    	//SET DESINATION FOLDER
    	$path= "http://localhost/website/uploads/".$new_image_name;
    	echo '<p>Path:' . $path . '</p>';
    	if($product_img !=none)
    	{
    		if(move_uploaded_file($_FILES['product_img']['tmp_name'], $path))
    		{
    			echo "Successful<BR/>";
    			echo "File Name :".$new_file_name."<BR/>";
    			echo "File Size :".$HTTP_POST_FILES['product_img']['size']."<BR/>";
    			echo "File Type :".$HTTP_POST_FILES['product_img']['type']."<BR/>";
    		}
    	else
    		{
    			echo "Image upload Error<BR/>";
    		}

     

     

    However, I now get this error:

     

    move_uploaded_file(http://localhost/website/uploads/5965thailand.jpg) [function.move-uploaded-file]: failed to open stream: HTTP wrapper does not support writeable connections in

     

    I know this may have something to do with permissions. All permissions on that folder are set to read/write. This is obviously also running off my localhost.

     

    Can anyone give me an idea of why this is happening?

     

    Thanks heaps again!

  18. Hi guys,

     

    I am wirting a script to upload an image file, but I get the error:

     

    copy() [function.copy]: Filename cannot be empty in

     

    Obviouly it has something to do with the copy() function - (copy($HTTP_POST_FILES['product_img']['tmp_name'], $path))

     

    I think it is not copying from my temp folder or something.

     

    Can anyone help me out?

     

    Code is:

     

    //IMAGE FILE	
    	$file_name = $_FILES['product_img']['name'];
    
    	echo '<p>File Name:' . $file_name . '</p>';
    	//IMAGE UPLOAD
    	// random 4 digit to add to file name
    	$random_digit=rand(0000,9999);
    
    	//combine random digit to file name to create new file name
    	//use dot (.) to combile these two variables
    	$new_image_name = $random_digit.$file_name;
    
    	echo $new_image_name;
    
    
    	//SET DESINATION FOLDER
    	$path= "uploads/".$new_image_name;
    	echo '<p>Path:' . $path . '</p>';
    	if($product_img !=none)
    	{
    		if(copy($HTTP_POST_FILES['product_img']['tmp_name'], $path))
    		{
    			echo "Successful<BR/>";
    			echo "File Name :".$new_file_name."<BR/>";
    			echo "File Size :".$HTTP_POST_FILES['product_img']['size']."<BR/>";
    			echo "File Type :".$HTTP_POST_FILES['product_img']['type']."<BR/>";
    		}
    	else
    		{
    			echo "Image upload Error<BR/>";
    		}
    	}

     

    Any help would be greatly appreciated!

     

    Thanks

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