Forum Replies Created

Viewing 14 replies - 16 through 29 (of 29 total)
  • Forum: Hacks
    In reply to: Nested Select Menu
    Thread Starter A31

    (@a31)

    Hi,

    Ok, Im going to paste ALL the code for all the files (I appologize for so much code, but i dont know what else), maybe you can spot my mistake ??

    Plugin main FILE – AJAXTest.php

    <?php
    /*
    Plugin Name: Ajax Test
    Plugin URI: https://www.example.co.za/
    Description: Testing Ajax
    Author: Adrian Beyers
    Version: 1.0
    Author URI: https://www.example.co.za/
    */
    
    /***************************
    * GLOBAL VARIABLES
    ***************************/
    
    if (!isset($wpdb)) $wpdb = $GLOBALS['wpdb'];
    global $wpdb;
    
    /***************************
    * INCLUDES
    ***************************/
    include ("inc/setup_addPages.php");
    include ("inc/setup_shortcodes.php");
    
    /***************************
    * SETUP
    ***************************/
    
    register_activation_hook(__FILE__,'AT_Func_addTestPage');
    register_deactivation_hook(__FILE__,'AT_Func_removeTestPage');
    
    register_activation_hook(__FILE__,'AT_Func_addMyData');
    register_deactivation_hook(__FILE__,'AT_Func_removeMyData');
    
    /***************************
    * SCRIPTS
    ***************************/
    
    function AT_load_scripts() {
    	wp_enqueue_script('custom-script1', plugin_dir_url(__FILE__) . 'js/ajax.js', array('jquery'));
    	wp_enqueue_script('custom-script2', plugin_dir_url(__FILE__) . 'js/jquery.validate.js', array('jquery'));
    	wp_enqueue_script('custom-script3', plugin_dir_url(__FILE__) . 'js/jquery-1.9.1.js', array('jquery'));
    	wp_enqueue_script('custom-script4', plugin_dir_url(__FILE__) . 'js/jquery.min.js', array('jquery'));
    	wp_enqueue_script('custom-script5', plugin_dir_url(__FILE__) . 'js/jquery.validate.min.js', array('jquery'));
    	wp_enqueue_script('custom-script6', plugin_dir_url(__FILE__) . 'js/additional-methods.js', array('jquery'));
    
    	wp_enqueue_script('jquery');
    
    	wp_localize_script('custom-script1', 'custom-script_vars1', array('ajaxurl' =>  admin_url('admin-ajax.php')));
    	wp_localize_script('custom-script2', 'custom-script_vars2', array('ajaxurl' =>  admin_url('admin-ajax.php')));
    	wp_localize_script('custom-script3', 'custom-script_vars3', array('ajaxurl' =>  admin_url('admin-ajax.php')));
    	wp_localize_script('custom-script4', 'custom-script_vars4', array('ajaxurl' =>  admin_url('admin-ajax.php')));
    	wp_localize_script('custom-script5', 'custom-script_vars5', array('ajaxurl' =>  admin_url('admin-ajax.php')));
    	wp_localize_script('custom-script6', 'custom-script_vars6', array('ajaxurl' =>  admin_url('admin-ajax.php')));
    
    }
    add_action('wp_enqueue_scripts', 'AT_load_scripts');

    FILE setup_addPages.php:

    <?php
    global $wpdb;
    
    /***************************
    * SETUP PAGES
    ***************************/
    
    function AT_Func_addTestPage()
    {
    	$PageTitle = 'AJAX Test';
    	$PageContent = '[AT_TestPage]';
    	$PageStatus = 'publish';
    	$PostType = 'page';
    	$PostAuthor = 1;
    	$CommentStatus = 'closed';
    
    	$myPage = array(
    	'post_title' => $PageTitle,
    	'post_content' => $PageContent,
    	'post_status' => $PageStatus,
    	'post_type' => $PostType,
    	'post_author' => $PostAuthor,
    	'comment_status' => $CommentStatus
    	);
    
    	$post_id = wp_insert_post($myPage);
    }
    
    function AT_Func_removeTestPage()
    {
    	global $wpdb;
    	$post_tbl = $wpdb->prefix . "posts";
    	$postmeta_tbl = $wpdb->prefix . "postmeta";
    	$PageTitle = 'AJAX Test';
    	$page = get_page_by_title($PageTitle);
    	$myID = $page->ID;
    
    	$myMetaID = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM em_postmeta WHERE meta_value = ".$myID.""));
    
    	$deletePost = "DELETE FROM " . $post_tbl . " WHERE ID = ".$myID."";
    	$deletePostSubs = "DELETE FROM " . $post_tbl . " WHERE post_parent = ".$myID."";
    	$deletePostMetaLink = "DELETE FROM " . $post_tbl . " WHERE ID = ".$myMetaID."";
    	$deletePostMeta = "DELETE FROM " . $postmeta_tbl . " WHERE post_id = ".$myMetaID."";
    
    	$wpdb->query($deletePost);
    	$wpdb->query($deletePostSubs);
    	$wpdb->query($deletePostMetaLink);
    	$wpdb->query($deletePostMeta);
    
    }
    
    /************************************************************************************************************/
    /************************************************************************************************************/
    /************************************************************************************************************/
    /************************************************************************************************************/
    /************************************************************************************************************/
    function AT_Func_addMyData()
    {
    	$PageTitle = 'MyData';
    	$PageContent = '[AT_MyData]';
    	$PageStatus = 'publish';
    	$PostType = 'page';
    	$PostAuthor = 1;
    	$CommentStatus = 'closed';
    
    	$myPage = array(
    	'post_title' => $PageTitle,
    	'post_content' => $PageContent,
    	'post_status' => $PageStatus,
    	'post_type' => $PostType,
    	'post_author' => $PostAuthor,
    	'comment_status' => $CommentStatus
    	);
    
    	$post_id = wp_insert_post($myPage);
    }
    
    function AT_Func_removeMyData()
    {
    	global $wpdb;
    	$post_tbl = $wpdb->prefix . "posts";
    	$postmeta_tbl = $wpdb->prefix . "postmeta";
    	$PageTitle = 'MyData';
    	$page = get_page_by_title($PageTitle);
    	$myID = $page->ID;
    
    	$myMetaID = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM em_postmeta WHERE meta_value = ".$myID.""));
    
    	$deletePost = "DELETE FROM " . $post_tbl . " WHERE ID = ".$myID."";
    	$deletePostSubs = "DELETE FROM " . $post_tbl . " WHERE post_parent = ".$myID."";
    	$deletePostMetaLink = "DELETE FROM " . $post_tbl . " WHERE ID = ".$myMetaID."";
    	$deletePostMeta = "DELETE FROM " . $postmeta_tbl . " WHERE post_id = ".$myMetaID."";
    
    	$wpdb->query($deletePost);
    	$wpdb->query($deletePostSubs);
    	$wpdb->query($deletePostMetaLink);
    	$wpdb->query($deletePostMeta);
    
    }
    
    /************************************************************************************************************/
    /************************************************************************************************************/
    /************************************************************************************************************/
    /************************************************************************************************************/
    /************************************************************************************************************/

    FILE setup_shortcodes.php:

    <?php
    
    global $wpdb;
    
    /***************************
    * SETUP FRONT-END SHORTCODES
    ***************************/
    
    add_shortcode("AT_TestPage","AT_TestPage_Shortcode");
    
    function AT_TestPage_Shortcode($atts)
    {
    	  include ('TestPage.php');
    }
    
    add_shortcode("AT_MyData","AT_MyData_Shortcode");
    
    function AT_MyData_Shortcode($atts)
    {
    	  include ('MyData.php');
    }

    FILE TestPage.php:

    <div id="responsecontainer"></div>
    
    <form id="MyForm" method="post" action="" novalidate="novalidate" enctype="multipart/form-data">
    
        		<div class="FormLabel">Description</div>
                        <textarea name="Description" id="Description" width="300px"/></textarea>
    
                        <br /><br />
    
                    <div class="FormLabel">Item Cost</div>
                        <input name="ItemCost" id="ItemCost" type="text"/>
                    <div class="FormLabel">Available Budget: Rxxxx.xx (Not yet available)</div>
                    <br /><br /><br /><br />
    
                    <div class="FormLabel">Select Cost Center</div>
                        <select name="Sel_CostCentre" id="Sel_CostCentre">
                            <option value="">Please Select... </option>
                            <option value="29 Degrees">29 Degrees</option>
                            <option value="J-Zone">J-Zone</option>
                        </select>
                        <br /><br />                
    
                    <div class="FormLabel">Select Allocation Account</div>
                        <select name="txtHint" id="txtHint" required="required"></select>
                        <br /><br />                   
    
        <input type="submit" name="submit" value="Submit" />
    </form>
    
    <div id="returneddata"></div>

    FILE ajax.js:

    jQuery(document).ready(function ($) {
    
    	$("#Sel_CostCentre").change(function() {
    
    		var SendData = document.getElementById('Sel_CostCentre').value;
    		var Usernaam = "Adrian";
    
    		$.ajax({
                   type:"POST",
                    url: "https://localhost/WPTest/wp-content/plugins/AJAXTest/inc/MyData.php",
    				//data:"SentData="+SendData,
    				data: { SentData: SendData, userid: Usernaam },
                   datatype: "json",
                    success: function(data, textStatus, xhr) {
                       data = JSON.parse(xhr.responseText);
                       // do something with data
    				   $("#responsecontainer").html(data);
    				}
                });
    
    	//$("#responsecontainer").html($("#Sel_CostCentre").val());
    
    	});
    
    	$("#ItemCost").change(function()
    	{
    		$("#responsecontainer").html($("#ItemCost").val());
    	});
    
        $('#MyForm').validate({ // initialize the plugin
            rules:
    		{
                Description: {
                    required: true
                },
                ItemCost: {
                    required: true
                }
            },
    		messages:
    			{
    				Description: "Please enter a description",
    				ItemCost: "Please enter a description"
    			}
        });
    
    });
    
    	function checkValue(element)
    		{
        		if(element.value >= 2500)
    				{
            			alert ('More than 2500');
        			}
    			else if (element.value < 2500)
    				{
    					alert ('Less than 2500');
    				}
    		}

    FILE MyData.php:

    <?php
    
    	global $wpdb;
    
    	$SentData = $_POST['SentData'];
    	$userid = $_POST['userid'];
    
    	//echo json_encode($userid . " sent the following data: " . $SentData);
    
    	$Returned = $wpdb->get_var( "SELECT meta_value FROM wp_usermeta WHERE meta_key = 'ActiveEntity'" );
    	echo json_encode($Returned);

    Ok I think thats everything….

    As mentioned in my previous posts, I realise that there are some very simple queries in the MyData.php file, and that I have not added Nonces, etc. but for now I just need to get my main issue working, then I will add all the rest in my main plugin.

    The ultimate goal, is that when the user selected the value from the first select box, it should populate the second selectbox with options from a database.

    Although my code does not request that at this moment, it is supposed to return the basic query, the meta_value for a unique key from the table into a div container named “responsecontainer”.

    Hopefully you can help ?? I am getting a bit discouraged after a month of trying to get this working ??

    Thank you so much for all your help!! I really do appreciate it so much!

    Forum: Hacks
    In reply to: Nested Select Menu
    Thread Starter A31

    (@a31)

    Hi there,

    I have been trying to figure this out thos past few days but I am somewhere not understanding something,

    I am using the enqueue_scripts to access the admin-ajax.php

    wp_enqueue_script(‘custom-script1’, plugin_dir_url(__FILE__) . ‘js/ajax.js’, array(‘jquery’));
    wp_localize_script(‘custom-script1’, ‘custom-script_vars1’, array(‘ajaxurl’ => admin_url(‘admin-ajax.php’)));

    Am I missing something completely?

    Kind Regards

    Forum: Hacks
    In reply to: Nested Select Menu
    Thread Starter A31

    (@a31)

    Hi,

    That fixed it! Thank you very much!

    As to how my pages are created, all my files are currently created when the plugin is activated, so I have full wpdb functionality on all files.

    I am puzzled though, in my GetData.php file, if I hardcode a variable:

    $Value = 'Returned Data';

    and return it with

    echo json_encode($Value);

    it returns the data perfectly, which is exactly what I want, BUT….

    the moment I run a wpdb query, it does not return it any more.

    for Example:

    global $wpdb;
    
    	$current_user = wp_get_current_user();
    	$UID = $current_user->ID;
    
       echo json_encode($UID);

    so if i view my GetData.php file on its own, I get the UID returned and displayed, however, the moment I want to pass it like I did with the hardcoded ($Value = ‘Returned Data’;), it does not show a value.

    Can you perhaps help where I might be missing something?

    Again thank you for your help! It is a great feeling to get something right and to know at least there are people I can ask to help me learn and get these things figured out.

    Kind Regards

    Forum: Hacks
    In reply to: Nested Select Menu
    Thread Starter A31

    (@a31)

    Hi there bcworkz,

    Hope you have a wonderful 2014!

    Thank you very much for your help and your advice above, in some way pointed me into the right direction. Although I did not make use of the child-theme setup, I applied some of this information to a custom plugin.

    What I have managed to accomplish is the following:

    I can now run jquery from a wordpress plugin, which was one of the biggest goals !! ?? yay!

    One example would be:

    in my form.php file:
    at the top i have:
    `
    <div id=”responsecontainer”></div>
    `
    then in the form section i have:
    `
    <input name=”ItemCost” id=”ItemCost” type=”text”/>
    `
    then in my ajax.js file:

    jQuery(document).ready(function () {
    $("#ItemCost").change(function()
    	{
                $("#responsecontainer").html($("#ItemCost").val());
    	});
    });

    the moment my ItemCost value changes, it works beautifully, and returns the value to the response div.

    All is not solved yet though ??
    This is what I ultimately want to achieve…

    What I have currently in my form is a select box:

    <select name="MySel" id="MySel">
    <option value="">Please Select... </option>
    <option value="1">Option 1</option>
    <option value="2">Option 2</option>
    </select>

    my jquery in my ajax.js file looks like:

    jQuery(document).ready(function () {
    $("#MySel").change(function() {
    
    	$.ajax({
            type:"POST",
            url: "GetData.php",
            datatype: "json",
            success: function(data, textStatus, xhr) {
            data = JSON.parse(xhr.responseText);
    
            $("#responsecontainer").html(data);
         }
    
         });
    });
    });

    my GetData.php file contains the following:

    $ReturnedValue = "Returned Data";
    
    echo json_encode($ReturnedValue);

    very simple I realise, but only to test.
    So really at this stage it does not matter what the user chooses in the select box, I just want to return the data from the GetData.php file to the response <div>.

    Up to now however, I can’t seem to get the data back from the GetData.php file, can you please help me in returning the data to the form?

    You really do help me!
    Thank you so much for all your help!!

    Forum: Hacks
    In reply to: Nested Select Menu
    Thread Starter A31

    (@a31)

    Hi there,

    Thank you very much for your help so far, I fully understand that you wish me to figure this out on my own. I am however very confused ??
    I do not know which part of code goes where and how that applies to the front-end because from what I understand from the many many articles is that it differs.

    Also I am a bit unsure, do I have to put it in a separate .js file?

    I am sorry that I am so clueless, but am trying to learn.

    What I have done is taken the most basic AJAX jQuery example i could find that is in the general direction of what I am looking for and tested it without WP. All it does is it posts info from a form to a seperate data file and gives an alert box with the data.

    the php file:

    <?php
    	global $wpdb;
    
    	// Get Page Links
    	$MyData_PageTitle = 'MyData';
    	$MyData_page = get_page_by_title($MyData_PageTitle);
    	$MyData_myID = $MyData_page->ID;
    	$MyData_Link = get_page_link($MyData_myID);	
    
    	echo $MyData_Link;
    ?>
    	<script type="text/javascript">
    		$(function(){
    			$('#ff').form({
    				success:function(data){
    					$.messager.alert('Info', data, 'info');
    					//$.document.write('Info', data, 'info');
    				}
    			});
    		});
    	</script>
    		<form id="ff" action="<?php echo $MyData_Link; ?>" method="post">
    			<table>
    				<tr>
    					<td>Name:</td>
    					<td><input name="name" type="text"></input></td>
    				</tr>
    				<tr>
    					<td>Email:</td>
    					<td><input name="email" type="text"></input></td>
    				</tr>
    				<tr>
    					<td>Phone:</td>
    					<td><input name="phone" type="text"></input></td>
    				</tr>
    				<tr>
    					<td></td>
    					<td><input type="submit" value="Submit"></input></td>
    				</tr>
    			</table>
    		</form>

    then the MyData.php file:

    <?php
    
    $name = $_POST['name'];
    $email = $_POST['email'];
    $phone = $_POST['phone'];
    
    echo "Your Name: $name <br/> Your Email: $email <br/> Your Phone: $phone";
    
    ?>

    but Alas, it is not working ?? I am terribly confused.

    Can you please help?

    Forum: Hacks
    In reply to: Nested Select Menu
    Thread Starter A31

    (@a31)

    Ok I have tried a number of different methods and I am now so confused… most of these methods are so much more code than my origional code as well…

    So I tried to simplify as much as i could and went back to what I knew worked. I tested it outside of WordPress and it works 100%, inside WordPress… not at all.

    I understand that WP manages all these things differently, can you please teach me how to put this simplified code of mine into a working WordPress format?

    Form.php

    <?php
    	global $wpdb;
    ?>
    <form>
    	<select name="sel_CostCentre" id="sel_CostCentre" onchange="showUser(this.value)">
    		<option selected="selected">Please Select...</option>
    	    <option value="Expense">Expense</option>
    	    <option value="Income">Income</option>
    	</select>
        <select name="Sel" id="txtHint"></select>
    </form>
    
    <script type="text/javascript">
    function showUser(str)
    {
    if (str=="")
      {
      document.getElementById("txtHint").innerHTML="";
      return;
      }
    if (window.XMLHttpRequest)
      {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
      }
    else
      {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    xmlhttp.onreadystatechange=function()
      {
      if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
        document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
        }
      }
    xmlhttp.open("GET","GetData.php?q="+str,true);
    xmlhttp.send();
    }
    </script>

    GetData.php

    <?php
    
    $q=$_GET["q"];
    
    $i = 0;
    while ($i < 5)
    {
    	return "<option value='$i'>$q $i</option>";
    	$i++;
    }

    If i can just get this simple code to return the value through wordpress, it will surely help me to resolve this problem.

    Can you please show me how to convert this code into WordPress Format?

    Thank you again for all your help!!!

    Forum: Hacks
    In reply to: Nested Select Menu
    Thread Starter A31

    (@a31)

    Thank you very much!

    I think your new documentation is clear and well written, and I already picked up on some of the mistakes I’ve made. However, this is my first attempt to really using Ajax (the above code I understood as Javascript), and well… I don’t really understand how to implement this to a nested / multi-leveled dropdown list box.

    Is there perhaps any possibility that you could teach me how to do that or maybe even include such an example in your documentation?

    Thank you very much for your help so far!

    Thread Starter A31

    (@a31)

    Ok, so I have done some more tests to try and isolate where the issue lies.

    Firstly I tested with my old method on another custom non-wordpress site to see if the data was correctly inserted in the databases, and yes, the insert worked perfectly I can view the pdf as normal when not using wordpress.

    The second test I did was to replace the WPDB and use the exact code I use for the non-wordpress site and see what it does, and thats where the problem kicks back. It then gives me the bunch of garbage code and does not ask me to open / save the pdf file.

    So it seems that the problem is then not with the database connection methods at all but possibly rather the way that wordpress display the content.

    Does this make any sense?
    If so, do you perhaps know of a way where I can “bypass” wordpress method of displaying pages for one specific page?

    Again thank you for helping me figure this out!

    Thread Starter A31

    (@a31)

    Hi there,
    No problem and thank you for all the help so far, you really did help me a lot! Unfortunately because of the volumes of files that will be stored, I will have to store the pdf files in a database, for audits as well as other fields in the table used for searching the correct document.

    Perhaps you might know the following that might help solve this matter?

    In my sites before I started using WordPress, I just echo’d the variable that contained the actual pdf file content and then the browser asked me to save the file or open it.
    If I do the same now in WordPress, it only prints the ‘garbage’ onto the page and does not ask to open or save the file any more.

    Do you perhaps know why wordpress is doing this and what I should do to get the open / save dialogue box back?

    Thread Starter A31

    (@a31)

    Hi,
    Thank you for your response.

    I am sorry but I am not getting this right…

    I managed to send the Header through the hook, which worked great, but when I echo the $FileContent, I still end up with a bunch of garbage on the screen:

    [ Moderator note: binary PDF file header deleted, please do not post ninary gobbley gook like that here. ]

    Is there perhaps any chance that you can provide me with some code that you use so I can learn from that?
    I am not getting any closer to a solution at this stage on my own ??

    Thank you very much for your help!

    Thread Starter A31

    (@a31)

    o yes, and of course I get the “Headers have already been sent” error.
    But when I echo the different variables, I can see the correct info, all except $FileContent.

    Thread Starter A31

    (@a31)

    Hi,
    yes, I followed the same way I used to before using WordPress.

    <?php
    global $wpdb;
    
    $mydataset = $wpdb->get_row("SELECT * FROM esdb_attachments WHERE ID = 1119");
    
    $recordID = $mydataset->ID;
    $FileType = $mydataset->FileType;
    $FileSize = $mydataset->FileSize;
    $FileName = $mydataset->FileName;
    $FileContent = $mydataset->FileContent;
    
    // Print headers
        header("Content-Type: ". $FileType);
        header("Content-Length: ". $FileSize);
    	header("Content-Disposition: attachment; filename=". $FileName);
    
    // Print Data
        echo $FileContent;

    Usually the browser automatically asked me to save or open the file, but now it just prints garbage on the page.
    Could you perhaps shine more light on what / how you mean that I should build a HTML link?

    Thnx again for all your help!

    Thread Starter A31

    (@a31)

    Hi,

    I cant believe I missed that for two hours! ??

    Thank you VERY much!

    It inserts the data into the database now.
    Do you have any suggestions on how to retrieve the data and view the pdf file again?

    Thank you very much for your help, much appreciated!

    When everything is done and working and cleaned up, I will post all the code, so that perhaps it might help someone else.

    Thread Starter A31

    (@a31)

    Hi, thank you very much for your reply, and I do apologize for the late reply, i was out of town for a while.

    I am still not getting this thing right….

    my form code looks like this:

    <?php
    require_once(ABSPATH . WPINC . '/ms-functions.php');
    
    	$PageTitle = 'TEST_Process';
    	$page = get_page_by_title($PageTitle);
    	$myID = $page->ID;
    	$myPageRedirect = get_page_link($myID);
    
    ob_start()
    
    ?>
    <script language="javascript">
    		function Checkfiles()
    		{
    		var fup = document.getElementById('uploaded_file');
    		var fileName = fup.value;
    		var ext = fileName.substring(fileName.lastIndexOf('.') + 1);
    		if(ext == "pdf")
    		{
    		return true;
    		}
    		else
    		{
    		alert("Upload PDF Files only");
    		fup.focus();
    		document.getElementById('file').value = '';
    		return false;
    		}
    		}
    	</script>
    <div class='wrap'>
    
    <form action="<?php echo $myPageRedirect; ?>" method="post" enctype="multipart/form-data"> 
    
    	<input name="file" id="file" type="file" size="80" required="required" onchange="Checkfiles(this)"/>
    	<input type="submit" name="btn_Submit" id="btn_Submit" value="Submit" />
    
    </form>
    
    <?php

    then my processing file code lookes like this:

    <?php
    if ($_FILES["file"]["error"] > 0)
      {
      echo "Error: " . $_FILES["file"]["error"] . "<br>";
      }
    else
      {
    
    		$PreFileName = ($_FILES["file"]["name"]);
    		$FileName = str_replace(" ","", $PreFileName);
    		$FileType = ($_FILES["file"]["type"]);
    		$FileSize = intval($_FILES['file']['size']);
    		$FileLocation = $_FILES["file"]["tmp_name"];
    		$FileContent = (file_get_contents($_FILES  ['file']['tmp_name']));
    
    		echo "FileName: " . $FileName;
    		echo "<br>";
    		echo "FileType: " . $FileType;
    		echo "<br>";
    		echo "FileSize: " . $FileSize;
    		echo "<br>";
    		echo "FileLocation: " . $FileLocation;
    		echo "<br>";
    
    		$url = plugin_dir_path( __FILE__ );
    		move_uploaded_file($_FILES["file"]["tmp_name"], $url . $_FILES["file"]["name"]);
    
      }
    
    $wpdb->insert(
    	'wp_attachments',
    	array(
    		'FileName' => $FileName,
    		'FileType' => $FileType,
    		'FileSize' => $FileSize,
    		'FileContent' => $FileContent
    	)
    );
    
    ?>

    I can actually echo the file name and the other details and see it, but I now get this error when I try to inert it into the database:

    Fatal error: Call to a member function insert() on a non-object

    Can you perhaps help? I am kind of in a pickle here and can’t seem to get this sorted.

Viewing 14 replies - 16 through 29 (of 29 total)