Jump to content

Search the Community

Showing results for tags 'object'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 15 results

  1. Hi I'm currently connecting to a API to retrieve info. The info I'm retrieving is in the form of Std Class Object. The problem I'm experiencing is that the results I get from one call is limited to 25. They say I should iterate it. But im not sure how to do so. My code so far <html> <?php require_once('MxitAPI.php'); try { $key = '************************'; $secret = '*****************************'; $api = new MxitAPI($key, $secret); if (isset($_GET) && isset($_GET['code'])) { $api->get_user_token($_GET['code'], 'http://********************'); // Get Contacts $contacts = $api->get_contact_list('@Friends', 0, 25); //print_r($contacts); foreach ($contacts->Contacts as $data) { echo $data->DisplayName."<br>"; $invite = $data->UserId; $invite1 = $invite . ','; /* generate the message */ $id = $_SERVER["HTTP_X_MXIT_USERID_R"]; $msg = "Hey! Come join me on {0}! And lets chat like a boss... :-P :-D"; $link = array( array( 'CreateTemporaryContact' => true, 'TargetService' => '********', 'Text' => '*****' ) ); /* send the message */ $api->send_message($id, $invite1, $msg, 'true', $link); } } elseif (isset($_GET) && isset($_GET['error']) && isset($_GET['error_description'])) { echo "<h2>There was an error requesting access from the API</h2>"; echo '<strong>Error:</strong> '. $_GET['error'] .'<br />'; echo '<strong>Error Description:</string> '. $_GET['error_description'] .'<br />'; } else { $api->request_access('***********************', 'graph/read message/user'); } } catch (Exception $e) { echo $e->getMessage(); } ?> <a href="page.php">Back</a> </html> They say I should turn $contacts = $api->get_contact_list('@Friends', 0, 25); into a loop but not sure how to do so the 0 is the files to skip and 25 is the amount to retrieve with each call. they say There is a default page limit of 26, so to access the user's complete contact list you will be iterate this call. More info can be found here regarding the API im trying to use with print_r option my object looks like stdClass Object ( [Contacts] => Array ( [0] => stdClass Object ( [DisplayName] => Zyco [FirstName] => zyco [LastName] => [State] => stdClass Object ( [Availability] => 4 [IsOnline] => [LastModified] => /Date(1426134583000+0200)/ [LastOnline] => /Date(1426139350470+0200)/ [StatusMessage] => ) [UserId] => 0769114834 [Blocked] => [Group] => Galaxy Universe Admin [ContactType] => 0 [SubscriptionType] => 66 ) [1] => stdClass Object ( [DisplayName] => cobusbo [FirstName] => Cobus [LastName] => Botma [State] => stdClass Object ( [Availability] => 2 [IsOnline] => 1 [LastModified] => /Date(1426162593000+0200)/ [LastOnline] => /Date(1426180367476+0200)/ [Mood] => 0 [StatusMessage] => checkout spamchat ) [UserId] => 27765238453 [Blocked] => [Group] => Galaxy Universe Admin [ContactType] => 0 [SubscriptionType] => 66 ) [2] => stdClass Object ( [DisplayName] => Bassmaker [FirstName] => Stefan [LastName] => Hattingh [State] => stdClass Object ( [Availability] => 4 [IsOnline] => [LastModified] => /Date(1425535612000+0200)/ [LastOnline] => /Date(1426232999571+0200)/ [StatusMessage] => Lesson learned!!!! Never fall inlove!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ) [UserId] => 27828456765 [Blocked] => [Group] => MXit [ContactType] => 0 [SubscriptionType] => 66 ) [3] => stdClass Object ( [DisplayName] => SHERIFF [FirstName] => ``ॐ☀☺ॐB.I.G5☺™♦.+LIONKIng [LastName] => ँ๏°˚ _♥_☺™♦☀LORDMINATI☀☺™♦๏° [State] => stdClass Object ( [Availability] => 4 [IsOnline] => [LastModified] => /Date(1420610808000+0200)/ [LastOnline] => /Date(1426171691976+0200)/ [StatusMessage] => #ff425a #ff425aLaVeyan sHaitAn Bible. ) [UserId] => m11231391002 [Blocked] => [Group] => Galaxy Universe Admin [ContactType] => 0 [SubscriptionType] => 66 ) [4] => stdClass Object ( [DisplayName] => HunterPoint. [FirstName] => Caroline [LastName] => Boot [State] => stdClass Object ( [Availability] => 4 [IsOnline] => [LastModified] => /Date(1426227463000+0200)/ [LastOnline] => /Date(1426240850456+0200)/ [StatusMessage] => Friend isn't about who you've know the longest it's about who walked into your life said "I'm here for you" and proved it. ) [UserId] => m18323190002 [Blocked] => [Group] => Galaxy Universe Admin [ContactType] => 0 [SubscriptionType] => 66 ) [5] => stdClass Object ( [DisplayName] => $Sugar$ $Max$ [FirstName] => $sugar$ $max$ [LastName] => Sugar$ $max$ [State] => stdClass Object ( [Availability] => 4 [IsOnline] => [LastModified] => /Date(1425995353000+0200)/ [LastOnline] => /Date(1426237305719+0200)/ [StatusMessage] => ) [UserId] => m19055694002 [Blocked] => [Group] => MXit [ContactType] => 0 [SubscriptionType] => 66 ) [6] => stdClass Object ( [DisplayName] => .-.-.-KID☀BIG [FirstName] => *#c0c00c.+.+.+KID #c0c0c0BIG* [LastName] => *#c0c0c0.+.+.+BUMS#00ff00HAKA* [State] => stdClass Object ( [Availability] => 4 [IsOnline] => [LastModified] => /Date(1424843034000+0200)/ [LastOnline] => /Date(1425665935177+0200)/ [StatusMessage] => ) [UserId] => m24542119002 [Blocked] => [Group] => Galaxy Universe Admin [ContactType] => 0 [SubscriptionType] => 66 ) [7] => stdClass Object ( [DisplayName] => Kλzεhιτsυjι [FirstName] => [LastName] => [State] => stdClass Object ( [Availability] => 4 [IsOnline] => [LastModified] => /Date(1425991633000+0200)/ [LastOnline] => /Date(1425991773513+0200)/ [StatusMessage] => #9966fb phone broken ) [UserId] => m25912500002 [Blocked] => [Group] => Galaxy Universe Admin [ContactType] => 0 [SubscriptionType] => 66 ) [8] => stdClass Object ( [DisplayName] => (H)FATIMA(H) [FirstName] => /#ff0000Fatima/ [LastName] => /#ff0000Japhta/ [State] => stdClass Object ( [Availability] => 4 [IsOnline] => [LastModified] => /Date(1425912639000+0200)/ [LastOnline] => /Date(1426239237672+0200)/ [StatusMessage] => Busy..... Flaming spirit-: SITTER ) [UserId] => m35370741002 [Blocked] => [Group] => Galaxy Universe Admin [ContactType] => 0 [SubscriptionType] => 66 ) [9] => stdClass Object ( [DisplayName] => ��m�H� W�YB�Y [FirstName] => Francois Barnard [LastName] => [State] => stdClass Object ( [Availability] => 4 [IsOnline] => [LastModified] => /Date(1426006669000+0200)/ [LastOnline] => /Date(1426183951042+0200)/ [StatusMessage] => ...... Ķãmãķãżī Wãřłøřđś .... If anyone knows coding pls msg me ... or if u know wapka msg me pls ((( Checkout Extreme_gamers ))) ) [UserId] => m37042581002 [Blocked] => [Group] => Galaxy Universe Admin [ContactType] => 0 [SubscriptionType] => 66 ) [10] => stdClass Object ( [DisplayName] => *#ff0000 #0000ffXena* [FirstName] => Km vnd yt [LastName] => Vra jw nek [State] => stdClass Object ( [Availability] => 4 [IsOnline] => [LastModified] => /Date(1424576823000+0200)/ [LastOnline] => /Date(1424577160006+0200)/ [StatusMessage] => .+#0000ff ) [UserId] => m40566397002 [Blocked] => [Group] => Galaxy Universe Admin [ContactType] => 0 [SubscriptionType] => 66 ) [11] => stdClass Object ( [DisplayName] => {{*BL!TZKR!3G#]] [FirstName] => [LastName] => [State] => stdClass Object ( [Availability] => 4 [IsOnline] => [LastModified] => /Date(1425809938000+0200)/ [LastOnline] => /Date(1425818270545+0200)/ [StatusMessage] => Cheers Galaxy Wars. ) [UserId] => m41544489002 [Blocked] => [Group] => Galaxy Universe Admin [ContactType] => 0 [SubscriptionType] => 66 ) [12] => stdClass Object ( [DisplayName] => Lord of chaose [FirstName] => [LastName] => [State] => stdClass Object ( [Availability] => 4 [IsOnline] => [LastModified] => /Date(1426188520000+0200)/ [LastOnline] => /Date(1426224169262+0200)/ [StatusMessage] => ) [UserId] => m42930422002 [Blocked] => [Group] => Galaxy Universe Admin [ContactType] => 0 [SubscriptionType] => 66 ) [13] => stdClass Object ( [DisplayName] => Morning-staR• [FirstName] => Apocalypse [LastName] => [State] => stdClass Object ( [Availability] => 4 [IsOnline] => [LastModified] => /Date(1426016522000+0200)/ [LastOnline] => /Date(1426236913282+0200)/ [StatusMessage] => D.N.A femceE's Crew be Making a one hella sick tour around DBN. Lol err don't even ask about the Males Crew but i'm happy for all my gals daddy cant wait for ya'll to come back so we can start eating some MoOLa(((LMAO))) ) [UserId] => m43239048002 [Blocked] => [Group] => Galaxy Universe Admin [ContactType] => 0 [SubscriptionType] => 66 ) [14] => stdClass Object ( [DisplayName] => #Ff0000*.+.+.+©£MP£ROR©#Ff0000*.+.+.+ [FirstName] => #Ff0000*.+.+JUMONG#Ff0000*.+.+ [LastName] => #cc00cc*.+.+DYNA§TY#Ff0000*.+.+ [State] => stdClass Object ( [Availability] => 4 [IsOnline] => [LastModified] => /Date(1421736155000+0200)/ [LastOnline] => /Date(1426225275110+0200)/ [StatusMessage] => #ff00ff®eally.. Visit my download portal- VENTRICK | Home Of Downloads Remember d sabbath dat 2 kip it holy. I can do all tins 2ru christ which streghteneth me! ) [UserId] => m46623264004 [Blocked] => [Group] => Galaxy Universe Admin [ContactType] => 0 [SubscriptionType] => 66 ) [15] => stdClass Object ( [DisplayName] => kira [FirstName] => Kira [LastName] => [State] => stdClass Object ( [Availability] => 4 [IsOnline] => [LastModified] => /Date(1426111312000+0200)/ [LastOnline] => /Date(1426231189633+0200)/ [StatusMessage] => Havent! ) [UserId] => m48340699002 [Blocked] => [Group] => MXit [ContactType] => 0 [SubscriptionType] => 66 ) [16] => stdClass Object ( [DisplayName] => DEATHANGEL [FirstName] => DEATH [LastName] => ANGEL [State] => stdClass Object ( [Availability] => 3 [IsOnline] => 1 [LastModified] => /Date(1426239062000+0200)/ [LastOnline] => /Date(1426239536392+0200)/ [Mood] => 1 [StatusMessage] => ) [UserId] => m49191486002 [Blocked] => [Group] => Galaxy Universe Admin [ContactType] => 0 [SubscriptionType] => 66 ) [17] => stdClass Object ( [DisplayName] => Shadow Reaper [FirstName] => dont [LastName] => know [State] => stdClass Object ( [Availability] => 1 [IsOnline] => 1 [LastModified] => /Date(1426189573000+0200)/ [LastOnline] => /Date(1426237783400+0200)/ [Mood] => 6 [StatusMessage] => Leave me alone not in the mood...tik verby ) [UserId] => m51256041002 [Blocked] => [Group] => Galaxy Universe Admin [ContactType] => 0 [SubscriptionType] => 66 ) [18] => stdClass Object ( [DisplayName] => 《■□●◆8-)¿¥¤UNG §K@T£R¿8-)●■●♧》 [FirstName] => #fe333d??? [LastName] => [State] => stdClass Object ( [Availability] => 4 [IsOnline] => [LastModified] => /Date(1425840233000+0200)/ [LastOnline] => /Date(1425126238187+0200)/ [StatusMessage] => #669966 ) [UserId] => m52626156002 [Blocked] => [Group] => Galaxy Universe Admin [ContactType] => 0 [SubscriptionType] => 66 ) [19] => stdClass Object ( [DisplayName] => .+_*#ffff00ICON*_ [FirstName] => .+*MCKINGO #ffff00 [LastName] => [State] => stdClass Object ( [Availability] => 4 [IsOnline] => [LastModified] => /Date(1424897461000+0200)/ [LastOnline] => /Date(1425331624085+0200)/ [StatusMessage] => THE ICON NOT AND NEVER WILL BE XCON.AM THE APEX OF APEX PREDATORS ) [UserId] => m56408943004 [Blocked] => [Group] => Galaxy Universe Admin [ContactType] => 0 [SubscriptionType] => 66 ) [20] => stdClass Object ( [DisplayName] => *N-R* [FirstName] => [LastName] => [State] => stdClass Object ( [Availability] => 4 [IsOnline] => [LastModified] => /Date(1424209196000+0200)/ [LastOnline] => /Date(1426181775833+0200)/ [StatusMessage] => ) [UserId] => m58722247002 [Blocked] => [Group] => Galaxy Universe Admin [ContactType] => 0 [SubscriptionType] => 66 ) [21] => stdClass Object ( [DisplayName] => ZIYAD [FirstName] => [LastName] => [State] => stdClass Object ( [Availability] => 4 [IsOnline] => [LastModified] => /Date(1426097756000+0200)/ [LastOnline] => /Date(1426182338901+0200)/ [StatusMessage] => I'm not here right now ) [UserId] => m60626483002 [Blocked] => [Group] => Galaxy Universe Admin [ContactType] => 0 [SubscriptionType] => 66 ) [22] => stdClass Object ( [DisplayName] => king•othello [FirstName] => [LastName] => [State] => stdClass Object ( [Availability] => 4 [IsOnline] => [LastModified] => /Date(1426175909000+0200)/ [LastOnline] => /Date(1426176930152+0200)/ [StatusMessage] => ) [UserId] => m61831903002 [Blocked] => [Group] => Galaxy Universe Admin [ContactType] => 0 [SubscriptionType] => 66 ) [23] => stdClass Object ( [DisplayName] => #c0c00c.+.+.+*Mxit hacker* [FirstName] => $Mxit hacker$ [LastName] => $Mxit hacker$ [State] => stdClass Object ( [Availability] => 4 [IsOnline] => [LastModified] => /Date(1423285744000+0200)/ [LastOnline] => /Date(1423285748616+0200)/ [StatusMessage] => 2015 comes with new cheat tricks tht i created [Image] [Image] ) [UserId] => m62798876002 [Blocked] => [Group] => MXit [ContactType] => 0 [SubscriptionType] => 66 ) [24] => stdClass Object ( [DisplayName] => james basson [FirstName] => [LastName] => [State] => stdClass Object ( [Availability] => 4 [IsOnline] => [LastModified] => /Date(1425222833000+0200)/ [LastOnline] => /Date(1425224038803+0200)/ [StatusMessage] => ¿Grim Give¿ ) [UserId] => m63089464002 [Blocked] => [Group] => Galaxy Universe Admin [ContactType] => 0 [SubscriptionType] => 66 ) [25] => stdClass Object ( [DisplayName] => Kizer Dengram [FirstName] => Clinton [LastName] => Ifeanyichukwu [State] => stdClass Object ( [Availability] => 4 [IsOnline] => [LastModified] => /Date(1424621304000+0200)/ [LastOnline] => /Date(1426236525690+0200)/ [StatusMessage] => Ooh Lord My havenly father, as i arrange my wonderful bed (Future) so i will lie on it... But lord as i am part of your family, please lord come and help me to arrange my Bed (My Future) coz only me cant arrange a whole wide Bed, for fear of Wolves! Amen! ) [UserId] => m63748006002 [Blocked] => [Group] => Galaxy Universe Admin [ContactType] => 0 [SubscriptionType] => 66 ) ) ) this is only the first 26 people info on my contact list I need to get a way to iterate it when the call is done with the first 26 to move on to the next 26. and then the next 26 etc. I looked at $contacts = $api->get_contact_list('@Friends', 0, 25) and saw the 0 for skipped items and 25 for page limit. is there maybe a way to create a loop to say with the first call skip 0 with the second recall skip the first 25 and with 3rd recall skip the first 50 till its done...
  2. Hello guys! I really really really hope anyone can help me because I am quite desperate about a little project I'm making. I want to construct a sort of online catalog for books with a "shoppingcart" and a profile for every user, but object orientated. I have a database with the table products which contains: ID, title, author, genre, price etc etc etc My main question is: How can I get one single field from the database with e.g. a function called getPrice(); I tried everything but nothing displays the data the way i want to. I simply want to have a sql-statement in this function and when I am calling the function getPrice() later on it displays just the number and no Array, code or whatever. Is there a way to call getPrice() and get "20.00" back? Please Help!
  3. Hello, I've just started learning PHP, JavaScript and I've got a big problem on my website. I'm getting this ReferenceError. I know what's the problem, but I don't know how to solve it, and I know people can do it for money but I don't have money, I'm searching for someone who's willing to help newbie. As I said I'm begginer, and I know something. The main problem is because I want to use GKPlugin and Player(jwplayer). Plugin need to use object, example: <object id="flashplayer" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="600" height="400"> <param name="movie" value="player.swf" /> <param name="allowFullScreen" value="true" /> <param name="allowScriptAccess" value="always" /> <param name="FlashVars" value="plugins=plugins/proxy.swf&proxy.link=http://www.vidbull.com/53qx9uo10k5d" /> <embed name="flashplayer" src="player.swf" FlashVars="plugins=plugins/proxy.swf&proxy.link=http://www.vidbull.com/53qx9uo10k5d" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="600" height="400" /> </object> Script is generetad just to embed with iframe, and the problem is when I replace it with object, then I'm getting this error. I know that JS can't "call" that iframe to show because I've replaced it with object. You guys probably know about what I'm talking. I'm just searching for some instructions, guidelines from you. ReferenceError: embeds is not defined if (embeds[embedid].indexOf("rapidplayer")== iframe_ad){ Here's the rest of code, I think it's used to show iframe. elseif (substr_count($link,"gorillavid")){ $video_id = explode("/",$link); if (isset($video_id[count($video_id)-1])){ $video_id = $video_id[count($video_id)-1]; $embed = '<object id="flashplayer" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="600" height="400"> <param name="movie" value="http://www.kiinc.com/videott/player.swf" /> <param name="allowFullScreen" value="true" /> <param name="allowScriptAccess" value="always" /> <param name="FlashVars" value="plugins=http://www.kiinc.com/videott/plugins/proxy.swf&proxy.link=http://gorillavid.in/'.$video_id.'" /> <embed name="flashplayer" src="player.swf" FlashVars="plugins=http://www.kiinc.com/videott/plugins/proxy.swf&proxy.link=http://gorillavid.in/'.$video_id.'" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="600" height="400" /> </object>'; This is the original code. Don't look at providers(source as gorillavid) because I used gorillavid in previous an posted another example from another source (zalaa) elseif (substr_count($link,"zalaa")){ $video_id = explode("/",$link); if (isset($video_id[count($video_id)-1])){ $video_id = $video_id[count($video_id)-1]; $embed = '<IFRAME SRC="http://www.zalaa.com/embed-'.$video_id.'.html" FRAMEBORDER=0 MARGINWIDTH=0 MARGINHEIGHT=0 SCROLLING=NO WIDTH='.$width.' HEIGHT='.$height.'></IFRAME>'; Function which embed links and should embed GKPlugin/Player: // general image link if (!$embed){ $embed = "<div style='background-color:#000000; width: ".$width."px; height: ".$height."px;text-align:center;cursor:pointer;' onclick='window.open(\"$link\");'>"; $embed.= "<p style='text-align:center; padding-top: 70px;'>"; $embed.= "<a href='$link' target='_blank' style='font-size:24px; color: #ffffff !important'>Click here to play this video</a>"; $embed.= "</p>"; $embed.= "</div>"; } return $embed; } JavaScript code: function getEmbed(embedid){ if (embeds[embedid].indexOf("rapidplayer")== iframe_ad){ var html_content = "<div class='fake_embed' id='fake_embed"+embedid+"' onclick='closeFakeEmbed("+embedid+");'>" + "<br /><br />" + "<div class='fake_embed_ad_close'><a href='javascript:void(0);' onclick='closeFakeEmbed("+embedid+");'>Close Ad</a></div>" + "<div class='fake_embed_ad' id='fake_embed_ad" + embedid +"'>" + "<iframe src='"+baseurl+"/iframe_ad.php' width='300' height='300' frameborder='NO' border='0'></iframe>" + "</div>" + "<div class='fake_embed_bar'><span class='fake_embed_bar_right'></span></div>" + "</div>" + "<div id='real_embed"+embedid+"' style='display:none'>"+embeds[embedid]+"</div>"; jQuery('#videoBox'+embedid).html(html_content); jQuery('#videoBox'+embedid).show(); } else { jQuery('#videoBox'+embedid).html(embeds[embedid]); jQuery('#videoBox'+embedid).show(); } } function countDown(embedid){ showCounter = showCounter-1; jQuery('span#counter').html(showCounter); if (showCounter>0){ showTimer = setTimeout('countDown('+embedid+');',1000); } else { showTimer = null; showCounter = 20; getEmbed(embedid); } } function changeEmbed(embedid, counter){ if (counter == 0){ jQuery('.embedcontainer').html(''); jQuery('.embedcontainer').hide(); getEmbed(embedid); } else { if (showTimer){ clearTimeout(showTimer); } showTimer = null; showCounter = counter; jQuery('.embedcontainer').html(''); jQuery('.embedcontainer').hide(); jQuery('#videoBox'+embedid).html(js_lang.ticker); jQuery('#videoBox'+embedid+' span#counter').html(showCounter); jQuery('#videoBox'+embedid).slideDown("slow"); showTimer = setTimeout('countDown('+embedid+');',1000); } /* jQuery('li.selected').removeClass('selected'); jQuery('#selector'+embedid).addClass('selected'); */ }
  4. Hi Guys, I'm new to OOP. I've mastered some basic syntax, but am wondering about an issue of design. To clarify in this example, I'm simply looking to pull Team data from a Database (I've not included my db class (PDO wrapper) although I know it is working. Although I have seen this sort of method below in a book (I believe and on the net) and it does work, I cannot help thinking coupling the DB class so tightly with the Team Class isn't a great approach. Can anyone give me feedback as to whether my approach is valid? While I can see the negative issue of tight coupling (i.e. changes to any database method would require multiple changes in Team (as team methods were added), I cannot really see an alternative way of doing this? I guess this is an issue of a design pattern or more advance OOP. Can anyone suggest an alternative way and/or more reading on making the coupling looser while still achieving my objectives? Should, for example, all DB functionality in getName be done during implementation? I initally thought pushing all db related functionality inside a Team method was wise and the best way then to add further methods, i.e. getResults method would be similar to getName but obviously with a different query and processing afterwards inside Team, but now I wonder if all should be in the implementation, or is there another approach? Thanks in advance. // create team class class Team { private $db; private $team_name; private $team_id; private $result; // in constructor lets pass DB object public function __construct($db) { $this->db = $db; } //function to get team name public function getName($team_id) { $this->team_id = $team_id; $this->db->query("SELECT team_name, nickname, founded FROM club WHERE team_id=:teamid"); $this->db->bind(':teamid', $this->team_id); if ($result = $this->db->single()); { return $result[]; } } }// end class // Implementation $team_id=1; //passed from user input // First Create Db Object with correct passed variables $database = new Database($server,$db_type); // Invoke DB connect method $database->connect(); // Now create Team object, pass it database object $team = new Team($database); // call Team method $team_display = $team->getName($team_id); // close db $database->closedb();
  5. This is the function I am currently working with... /** * Retrieve search query text * * @return string */ public function getQueryText() { if (!isset($this->_queryText)) { $this->_queryText = $this->_getRequest()->getParam($this->getQueryParamName()); $noescape = preg_replace("/%u([0-9a-f]{3,4})/i","\\1;",urldecode($this->_queryText)); if ($this->_queryText === null) { $this->_queryText = ''; } else { /* @var $stringHelper Mage_Core_Helper_String */ $stringHelper = Mage::helper('core/string'); $this->_queryText = is_array($this->_queryText) ? '' : $stringHelper->cleanString(trim($this->_queryText)); echo '<span style="display: none;">'; echo '<pre>'; var_dump ( $noescape ); echo '</pre>'; echo '</span>'; $maxQueryLength = $this->getMaxQueryLength(); if ($maxQueryLength !== '' && $stringHelper->strlen($this->_queryText) > $maxQueryLength) { $this->_queryText = $stringHelper->substr($this->_queryText, 0, $maxQueryLength); $this->_isMaxLength = true; } } } return $this->_queryText; } I can echo what I need to output in this function with $noescape however I need to modify return $this->_queryText; to include the preg_replace and rawurldecode from $noescape. Please could someone be kind enough to advise of the correct syntax/way of handling this? I did post this on StackOverflow but had no response as of yet. Thanks in advance.
  6. I'm writing some classes right now for a website with a shopping cart. There are all kinds of classes, Blog, Cart, Product, Database, etc. I am trying to make a design choice about where to store the requested quantity for a particular product. I feel like it should NOT go into the Product class, because the requested quantity does not semantically relate to any of the standard product detail. I was considering maybe setting the quantity property of the product instance, to the requested quantity, once it is put into the cart. For some reason my instinct says no, that it should be abstracted out, perhaps into the Cart class. If that is the case, how do you couple the requested quantity with the requested object? As array key/value pair? Is there another class it could go into? Does anyone have practical experience to shed some light on this?
  7. My apologies if I've placed this in the wrong section. It concerns a basic connection to n SQL database, and doing a simple count of the records. I'm learning from DAVID POWERS PHPSOLOUTIONS book. Examples in his book show connecting to the local db differently than my host wants me to connect, and I believe therin lies the issue. If I can figure out the method or problem I'm having, I'll be very thankful. I'm just connecting to a database, running one query, and counting records. The code that I altered, and I am trying to use, looks like this: <?php //Sample Database Connection Syntax for PHP and MySQL. include ('/includes/imageconn.inc.php'); include ('/includes/imagetableconn.inc.php'); mysql_select_db($dbname); # Check If Record Exists $sql = "SELECT * FROM $usertable"; $result = $conn->query($sql) or die(mysqli_error()); $numrows = $result->num_rows; ?> <html> <head> <title>PHP Test</title> </head> <body> <?php echo $numrows; ?> </body> </html> ----------------------------------------------------------------------- My imageconn.inc.php file holds a set of variables needed for the connection. I have verified it works (online, where I want), using other simple pages I made. This is the imagetableconn.inc.php file. It contains one line of code (which also works in the test file the host sent me). $conn = mysql_connect($hostname, $username, $password) or die ('Error connecting to mysql'); ------------------------------------------------------------------------- I'm pretty sure the problem lies in this line (which is from the BOOK, which I can't figure out how to modify for my online needs): $result = $conn->query($sql) or die(mysqli_error()); My error message: Fatal error: Call to a member function query() on a non-object in D:\Hosting\4641474\html\testimagedb1.php on line 12
  8. Hi, i'm using SoapClient. i want to save result of SoapClient to a mysql database. my php code for webservice: $client = new SoapClient("http://sms-webservice.ir/v1/v1.asmx?wsdl"); $params = array( 'Username'=>$username, 'PassWord'=>$password, 'numberOfMessages'=>$numberOfMessages, 'destNumber'=>$destNumber, 'ErrNum'=>$ErrNum, ); $result = $client->GetAllMessages( $params ); if (is_soap_fault($result)) { echo '<h2>Fault:</h2><pre>'; print_r($result); echo '</pre>'; } else { $res = $result->GetAllMessagesResult->ArrayOfString; echo "<div dir=ltr>"; foreach($res as $key => $value){ print_r ($value); //$MyResult = ew_Execute("INSERT INTO receivedsms (MessageID, ReceiverNumber, SenderNumber, MessageTxt, ReceiveDate) VALUES ('', '', '', '', '')"); } echo "</div>"; //end get messages } my SoapClient results return the following data: stdClass Object ( [string] => Array ( [0] => 32979916 [1] => 5000206060500 [2] => 9140544602 [3] => A [4] => 10/16/2013 11:13:03 PM ) ) stdClass Object ( [string] => Array ( [0] => 32979917 [1] => 5000206060500 [2] => 9140544602 [3] => B [4] => 10/16/2013 11:13:13 PM ) ) stdClass Object ( [string] => Array ( [0] => 32979923 [1] => 5000206060500 [2] => 9140544602 [3] => C [4] => 10/16/2013 11:13:23 PM ) ) Please help me complete my code to save the soapclient results to mysql table! Regards Mansour
  9. And it doesn't work! Im trying to write my first simple object which will just echo out a logo. I don't think the var $IDSystem is being passed through. As its my first attempted I'm struggling to see what I have wrong. class System{public $IDSystem = '1'; public function __construct() {$this->IDSystem = $IDSystem; } public function SystemLogo() { mysql_select_db($database_dbconnect, $dbconnect); $Query = sprintf("SELECT BSLogo, BSName FROM BusinessSettings WHERE IDBusinessSettings = %s", GetSQLValueString($this->IDSystem, "int")); $Query = mysql_query($Query, $dbconnect) or die(mysql_error()); $Result = mysql_fetch_assoc($Query); if(!empty($Result['BSLogo'])){ echo "<img src='/images/uploads/logo/{$Result['BSLogo']} width='220px' height='100px'/>"; } else {echo "<h1>{$Result['BSName']}</h1>"; } } } then on the page I'm writing $logo = new System;echo $logo->SystemLogo(); [/php]
  10. I've got some code that displays a feed from a wordpress xml and it does perfectly on my mamp localhost but when I put it on the windows server everthing just falls apart. <?php $curl = curl_init(); curl_setopt_array($curl, Array( CURLOPT_URL => 'http://blog.thisisfusion.com/feed/', CURLOPT_USERAGENT => 'spider', CURLOPT_TIMEOUT => 120, CURLOPT_CONNECTTIMEOUT => 30, CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_ENCODING => 'UTF-8' )); $data = curl_exec($curl); curl_close($curl); $xml = simplexml_load_string($data, 'SimpleXMLElement', LIBXML_NOCDATA); ?> And the loop portion here: <?php $i = 0; foreach ($xml->channel->item as $item) { $creator = $item->children('dc', TRUE); echo '<h2>' . $item->title . '</h2>'; echo '<small>Posted on '. date('l F d, Y', strtotime($item->pubDate)) .' by '.$creator.'</small> </p>'; echo '<p class="description">' . $item->description . '</p>'; if (++$i > 2) break; } ?> It's having a fit on the server saying that THIS section foreach ($xml->channel->item as $item) is trying to get the property of a nonobject and that it's an invalid argument in foreach. If this was truly the case, why is it working on my localhost? I've tried a lot of different methods and I have no clue what to do anymore. I var_dumped and didn't see anything maybe something in $xml is null and I missed it? But I checked to make sure that wasn't the case. I don't know. I would appreciate some help. Thank you.
  11. I'm fairly new to object orientated PHP and I was trying to think of a better way to connect to a MySQLi database within classes and functions, instead of just putting down an include everywhere. So far I came up with this: database.php <?php class database { protected $db_name = 'database'; protected $db_user = 'root'; protected $db_password = 'password'; protected $db_host = 'localhost'; function __construct(){ $this->connect(); } public function connect(){ $this->db = new mysqli($this->db_host, $this->db_user, $this->db_password, $this->db_name); } } $db = new database; ?> test.php class test{ private function getDb(){ include("database.php"); return $db; } public function test1(){ $find = $this->getDb()->db->query("SELECT * FROM user"); $rows = $find->num_rows; return $rows; } } and then just putting echo $test->test1(); on my page. I did have other functions inside the database class, but I've since scrapped those, so it just looks like that atm. It does work... however, I'm not sure how good or bad it is. In particular the first line in the test1() function. I have a feeling its a terrible way to do it... Or is it fine? like efficiency wise etc? before I would just use an include within every function. so I'd just do: $db->query(" "); Eventually I will have a few classes like user, etc, and these would all need to manipulate the database. So I was just thinking of plopping the getDb() function at the top of each of them and just include the database stuff... I tried looking at how phpBB and wordpress handle databases, but theirs are just full of unnecessary stuff for me and its just difficult to decipher. They use a global I think?
  12. Hi, I can send SoapVar from my client to my server and from my server to my client - it works ok. The SOAP requests and responses seem to be ok. Everything is ok, until i try make it more "dynamic". How can I access to "Identifier" and "Status" ? Below is the code for client and server. Thanks for your time! <?php header('Content-type: application/xml'); try{ $sClient = new SoapClient('mywsdl.wsdl', array('trace'=>1)); $Identifier = "123456"; $Status = "Hey, how are you today?"; $part_request = array(); $part_request[] = new SoapVar($Identifier,XSD_STRING,NULL,NULL,"Identifier"); $part_request[] = new SoapVar($Status,XSD_STRING,NULL,NULL,"Status"); $request = new SoapVar($part_request, SOAP_ENC_OBJECT, NULL, NULL,"RegisterRequest"); $response = $sClient->Register($request); print_r ($sClient->__getLastRequest()); print_r ($sClient->__getLastResponse()); } catch(SoapFault $e){ var_dump($e); } ?> <?php //ini_set("soap.wsdl_cache_enabled","0"); $server = new SoapServer("wsdl.wsdl"); function Register($request) { /* How to access to "Identifier and Status?" $request->Identifier or $request->RegisterRequest->Identifier dont work ;/ */ /* BELOW THIS EVERYTHING WORKS, but it's static */ $ResponseId = "1234"; $Status = "Fine"; $part_response = array(); $part_response[] = new SoapVar($ResponseId,XSD_STRING,NULL,NULL,"ResponseId"); $part_response[] = new SoapVar($Status,XSD_STRING,NULL,NULL,"Status"); $response = new SoapVar($part_response,SOAP_ENC_OBJECT,NULL,NULL,"RegistrationResponse"); return $response; } $server->AddFunction("Register"); $server->handle(); ?>
  13. I have a simple category table in which 5 or 6 names are there. Now I want to retrieve them. When I connect to mysql database in procedural way, the while loop is working great, giving nice output. But when I go through a class and trying to retrieve the data, it stops after giving the first table name. My procedural code is here: mysql_connect("localhost", "root", ""); mysql_selectdb("12reach"); $cat = mysql_query("SELECT * FROM `category` LIMIT 0 , 30"); if (!$cat){ die ('Error'); } while ($row = mysql_fetch_array($cat)) { extract($row); echo $row['name'].'<br>'; } It works fine. Giving six category name. But problem begins with the following code: I have two classes and a php file where I created an instance of category class and trying to get the category table names one by one. class ConnectClass { private $_connection; public function getConnect() { $this->_connection = mysql_connect("localhost", "root", ""); if (mysql_errno()) { throw new RuntimeException('Cannot access database: '.mysql_error()); } else { mysql_selectdb("12reach", $this->_connection); } } include 'ConnectClass.php'; class CatClass extends ConnectClass{ public function getcat() { $cat = mysql_query("SELECT * FROM `category` LIMIT 0 , 30"); if (!$cat){ die ('Error'); } while ($row = mysql_fetch_array($cat)) { extract($row); return $row['name'].'<br>'; } } } include 'CatClass.php'; $obj=new CatClass(); $obj->getConnect(); echo $obj->getcat(); Probably while loop is working inside the class. As I want to return the last name of the category table, I can get it placing it outside the loop. But if I want the full name list, it does not work in object oriented format. Any idea, where is my fault?
  14. I am not able to successfully pass a JSON object as a parameter, i get an uncaught referenceError..any ideas? $.getJSON('./getMe.php', function(data){ $.each(data, function(key, pack){ var id = key.toLowerCase().replace(" ", "_"); $('#breadcrumbs').append(" <span id='" + id + " 'onclick='DoSomething(id, pack);'>" + key + "</span> "); }); $('#breadcrumbs').append('</br></br>'); }) .success(function(){ $('#loader').hide(); }); function DoSomething(id, pack){ $.each(pack, function(stage, items){ alert(stage); }); $('#packages').html('→ ' + id); }
  15. Hello everyone. i'm new on this site and also new on PHP coding. I want to make a loop using the values of an object (name of the object is test). my object has categoryid,parentid and i want to make something like this forearch(categoryid){ foreach(parentid){ if (parentid == categoryid){ do something } } } Can anyone help me to do this loop? Thank you
×
×
  • 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.