Jump to content

CyberShot

Members
  • Content Count

    312
  • Joined

  • Last visited

Community Reputation

0 Neutral

About CyberShot

  • Rank
    Advanced Member

Profile Information

  • Gender
    Not Telling
  1. CyberShot

    fatal error: call to a member function

    this is true that the error does give you the line number but it isn't true that the line it points out is always the problem. It could be 2 or 3 lines above the actual line pointed out. I have seen this before. That said, I do not have any formal programming schooling. I am trying to teach myself which is not as easy as it sounds. There are lots of tutorials out there but they are notorious for leaving out information. They do things but do not tell you why they did them. I just finally came to understand the use of "$this->" as of yesterday.
  2. CyberShot

    fatal error: call to a member function

    I see in my post that the braces are messed up. I just didn't copy the code correctly. They are not messed up in the class
  3. I am trying to create a class and I ran into a problem. The connect function is returning a fatal error on the line below and I can't figure out the issue. $result = $this->conn->query("SELECT unit FROM address"); class database { private $server = "localhost"; private $db_user = "my user"; private $db_pass = "my pass"; private $db_name = "my database"; private $conn; private $result = array(); function connect(){ // Create connection $this->conn = new mysqli($this->server, $this->db_user, $this->db_pass, $this->db_name); if ($this->conn->connect_error) { echo "Not connected, error: " . $mysqli_connection->connect_error; } else { //echo "Connected."; return $this->conn; } public function displayHeader(){ $result = $this->conn->query("SELECT unit FROM address"); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { echo '<li>' . $row["unit"] . '</li>'; } } else { echo "0 results"; } $conn->close(); } } }
  4. CyberShot

    unserialize trouble

    when I first get the information out of WordPress, it looks like this ( this is just a short bit of it ) $theID = get_post_meta(get_the_ID()); $string = $theID['panels_data']; var_dump($string); //gives me the below line string(748) "a:3:{s:7:"widgets";a:1:{i:0;a:3:{s:5:"title";s:4:"home"; When I pass the string to unserialize function, I get an error $string = unserialize($string); echo $string; "warning" unserialize() expects parameter 1 to be string, array given in
  5. CyberShot

    unserialize trouble

    That helps a little but my main problem still exists. I get my data and when I dump the variable, it says it's a string that looks like this a:3:{i:1;s:6:"elem 1";i:2;s:6:"elem 2";i:3;s:7:" elem 3" yet when I pass that variable into the unserialize function, I get an error. I thought this is what unserialize was for. it says unserialize() expects parameter 1 to be string, array given in This is why I am confused.
  6. CyberShot

    unserialize trouble

    I have what I think is a serialized information in my WordPress site.. Here is a partial chunk a:3:{s:7:"widgets";a:1:{i:0;a:3:{s:5:"title";s:4 I thought that if I use unserialize, it would put it into an array or something. I thought unserialize takes a string which according to the data type looks like what I would be passing after going through my foreach loop but when I try to unserialize it, it tells me i am trying to convert an array to a string. Not sure what I am doing wrong here. foreach ( $string as $option) { echo unserialize($option) ; }
  7. I have this array and I am trying to get the image value print_r($image); Array ( [0] => Array ( [image] => 32 [image_fallback] => ) [1] => Array ( [image] => 31 [image_fallback] => ) ) The only way I have been able to get it to work is by doing this foreach($image as $key){ foreach($key as $value){ $imageID = wp_get_attachment_image($value,'full'); // gets the attachment image from the image ID.. 31, 32 from the above array echo $imageID; // prints out the image tag with the url to the image } } The above code does give me the desired result. What I want to know is if there is a sexier way to getting it done? Is this considered propper?
  8. should this line $result1 = mysql_query($query1); be this $result1 = mysqli_query($query1); ?
  9. CyberShot

    undefined index problem

    Looks like the problem was that I missed adding the class index to one of the options. The error is gone
  10. CyberShot

    undefined index problem

    I am working in WordPress building a widget for siteorigin page builder. The widget is working just fine but I am getting an undefined index error and I don' t know why. I have a file that returns and array. That is all that it does. It looks like this but has a lot more indexes. 'facebook' => array( 'label' => __( 'Facebook', 'mosty' ), 'base_url' => 'https://www.facebook.com/', 'class' => 'fa fa-facebook', ), 'twitter' => array( 'label' => __( 'Twitter', 'mosty' ), 'base_url' => 'https://twitter.com/', 'class' => '', ), I have added the class index to the array and I am using the facebook one as my test. I need to get the result of the "class" index and send it to the front end of the site. I have that working. It does display on the front end. In the front end file, I have a bit of code to error check to see if I can get the value I brought the array file into the back end like this if( empty( $this->networks ) ) { $this->networks = include plugin_dir_path( __FILE__ ) . 'data/networks.php'; } ?php foreach ($network_names as $key => $value){ echo '<ul><li>The key is '. $key . ' The value is ' . $value . '</li></ul>'; } ?> Here is the output of my test loop and at this point, this is all I would expect and the first entry is correct The key is facebook The value is fa fa-facebook The key is twitter The value is The key is google-plus The value is The key is linkedin The value is The key is tumblr The value is The key is vk The value is The key is flickr The value is The key is delicious The value is The key is dribbble The value is The key is skype The value is The key is youtube The value is The key is github The value is The key is forrst The value is The key is digg The value is The key is soundcloud The value is On the front end of the site, I am getting this error Notice: Undefined index: class in /path to widget/team/team.php on line 111 Here is my line 111 109 $network_names = array(); 110 foreach ( $this->networks as $key => $value ) { 111 $network_names[ $key ] = $value['class']; 112 } I am sending the array to the front end of the site on line 121 of team.php I have attached my team.php class to the post for you to view. Again, the widget does work and does display the data but gives me that undefined index for "class" index of my array. How can I solve this problem? team.php
  11. CyberShot

    passing an array though anchor link

    I re-wrote it with the implode, explode. It's shorter and cleaner. It also makes the address at least look like something WordPress would do. I had hoped to find a way to hide the variable all together but I can accept this method.
  12. CyberShot

    passing an array though anchor link

    My only thing with this is that I don't see this kind of thing often. I would think there would be a better way. I think your idea has promise and I might actually look into that. I did try the http_build_query but I don't think it ended up working. This is the first time I have tried passing variables through a link
  13. I am passing an array of wordpress page IDs through an anchor link but it looks rather ugly. I am serializing my array like this $var = htmlspecialchars(serialize($pages), ENT_QUOTES); which gives me this string(45) "a:4:{i:0;i:944;i:1;i:17;i:2;i:19;i:3;i:1310;}" passing it through an anchor tag like so $link = tbpb_get_archives_link(); // returns the permalink of a WordPress page <a href="<?php echo $link . '?var='. $var ?>" class="work-all"><span><i class="fa fa-times"></i> All works</span></a> now my anchor tag looks like this in the navigation bar http://mysite.com/all-projects/?var=a:4:{i:0;i:944;i:1;i:17;i:2;i:19;i:3;i:1310;} is there a way to clean that up and make it look prettier? or another method of passing the variables from one page to another?
  14. CyberShot

    Help me design a database please

    That is interesting. Thank you. I will have to study this
×

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.