Jump to content

russianbear

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Everything posted by russianbear

  1. Hello. I'm developing an application that needs to query a device that speaks only SNMP. I would like to accomplish this using the SNMP libraries provided by PHP. I currently have PHP 5.3.2 running on a Dell rig setup with Windows 2003 SP2 and IIS 6.0. After reading the PHP home page it looks all I need to do is install the NET-SNMP package. Right? http://us.php.net/manual/en/snmp.requirements.php Basically I figure that if all I have to do is install NET-SNMP, that would be too easy....so something is wrong. There was some talk of a UCD SNMP install on a related page and in order to install that, I would have to recompile PHP after making some changes in the config.h or acconfig.h file. http://us.php.net/manual/en/snmp.installation.php Can someone help me make heads and tails of this please. What is the difference between NET-SNMP and UCD SNMP? Thanks! The Bear
  2. Yo buddy. It's not hard. Indeed - there are a lot of tutorials on-line, but here is a good example for you to use...hope it helps. I inlcuded 2 different ways to insert an image. The first way is the OO approach. Second is the procedural way. Not sure how familiar you are with Object Oriented Programming, but that would be the way that I would do it - cleaner and more modular. Also make sure that in your db script you have declared your columns that hold the images as blob type. You can read about that here if you aren't familiar with it... http://dev.mysql.com/doc/refman/5.0/en/blob.html good luck. <?php // Open a connection to the DB //$conn = new mysqli("localhost", "lamp", "", "images"); /* echo "Thanks for uploading file :" . $_FILES['userfile']['name'] . "<br>"; echo "File size is : " . $_FILES['userfile']['size'] . "<br>"; echo "File type is : " . $_FILES['userfile']['type'] . "<br>"; echo "File tmp_name is : " . $_FILES['userfile']['tmp_name'] . "<br>"; */ //$stmt = $conn->prepare("INSERT INTO images VALUES(NULL, ?)"); //$stmt->bind_param("s", $data); //$file = $_FILES['userfile']['tmp_name']; //$fp = fopen($file, "r"); //$size = 0; //while ($data = fread($fp,1024)) { // $size += strlen($data); // $stmt->send_long_data(0,$data); //} //if ($stmt->execute()) { // print "$file ($size bytes) was added to the files table\n"; //} else { // die($conn->error); //} // // //echo '<html>'; //echo '<head></head>'; //echo '<body>'; //echo '<br><a href="download.php">Retrieve Image</a>'; //echo '</body>'; //echo '</html>'; //end oo approach // Begin procedural style // database connection mysql_connect("localhost", "lamp", '') OR DIE (mysql_error()); // select the db mysql_select_db ('images') OR DIE ("Unable to select db".mysql_error()); // prepare the image for insertion $imgData =addslashes (file_get_contents($_FILES['userfile']['tmp_name'])); // our sql query $sql = "INSERT INTO images (image) VALUES ('{$imgData}')"; if(!mysql_query($sql)) { echo 'Unable to upload file'; } else { echo 'upload SUCCESS!'; } echo '<html>'; echo '<head></head>'; echo '<body>'; echo '<br><a href="download.php">Retrieve Image</a>'; echo '</body>'; echo '</html>'; ?>
  3. Need a recommendation. I'm making a mini craigslist version and I would like to implement a search functionality. The search will work such - the user will enter some search parameters that I will use to query the db of posts that match their search. The format that I would like to implement for displaying the search results is creating a list of titles that are hyperlinks to the actual posts - exactly the same way that craigslist has done it. Is it better to use AJAX to accomplish this or is there a clean way to do this using PHP... It just seems to me that it doesn't make much sense to send every single post's data across to the client when they might only end up viewing 1 of the posts.
  4. Hoping somebody can help me out. What I'm trying to do is query my db and pull from it a title and ID of a posting. The web app I'm building is a mini version of the craigslist.com Basically the user enters a bunch of information about a product they are trying to sell including pictures, etc... The LOC you see below will query the db based on user input and return a result set of ALREADY posted listings...so basically I'm trying to print out the titles of the postings and make those hyperlinks to the actual posts. The problem I'm running into isn't in the MySQL query - I already tested that and it works, but in my PHP logic in capturing the data after the query is executed! Okay - here is the rub. This code works, but only for a specific set of input. The input is captured on the prior page and it comes from 2 pull down menus that provides the SubCategoryID (i.e. option 0 = books, option 1 = art, option 2 = etc...) and the LocationID (option 0 = Cupertino, CA ; option 1 = Moscow, Russia, etc...) The results are ONLY displayed if the user chooses: LocationID = 0 and SubCategory = 0 (another words the code below only works if the user selected Cupertino and Books on the prior page). Is the problem obvious or do you need more information to further diagnose my stupidity? Thanks in advance! PS - I'll send a darn good bottle of Pinot to whoever can help me solve this issue! And if you don't drink, I'll send ya a couple of 2 liters of Mountain Dew. And if you don't drink caffeine either, well then you'll just have to settle with my thanks and BIG UPS!!!! if($stmt = $conn->prepare("SELECT Post_ID, Title FROM POSTS as p, LOCATION as l, SUBCATEGORY as s, REGION as r, CATEGORY as c WHERE((p.Location_ID=?) AND (p.SubCategory_ID=?) AND (r.Region_ID=?) AND (p.SubCategory_ID = s.SubCategory_ID) AND (p.Location_ID = l.Location_ID) AND (s.Category_ID = c.Category_ID) AND (l.Region_ID = r.Region_ID))")) { // Bind your variable to replace the ? $stmt->bind_param('iii', $field1, $field2, $field3); // Set your variables $field1 = $Sub_Category_ID; $field2 = $Location_ID; $field3 = $Region_ID; $row = array(); //Bind the result $stmt->bind_result($row['post_id'], $row['title']); //Execute the query $stmt->execute(); //Okay, got the result, how output them to the screen // Output here looks like USA->Cupertino->For Sale->Automobiles echo "<h3>$Region_Name -> $inputArray[location] -> $Category_Name -> $inputArray[sub_category]</h3>"; //here is where I'm getting the ID and title and storing them in a local 2-D array while($stmt->fetch()) { foreach($row as $key => $value) { $tmp[key] = $value; }//end foreach $this->PostArray[$count++] = $tmp; }//end while // PROBLEM IS - WHEN I attempt to print the array recursively, I get NOTHING!!!!! // Can you see anything in my logic that is BOGUS, for lack of better words. print_r($PostArray); }//end if ?>
  5. I am building a mini version of the Craigslist. Here is the gist...After a user's post info is validated, I write it to the db...Check. Now, if the same user wants to view other posts, I have a page where they can narrow their seach parameters. So, after they submit these parameters I use them in a prepared statement to return a list of post titles (which I am going to make hyperlinks to the actual posts). One step at a time though...for some reason my code is not working properly in returning the post titles. I currently have only 3 locations to choose from (for simplicity reasons - I'll add more later), but my code returns the results for ONLY the first location that I have in my pull down menu that narrows down the search parameters, none else. if($Title_Query = $conn->prepare("SELECT Title FROM POSTS as p, LOCATION as l, SUBCATEGORY as s, REGION as r, CATEGORY as c WHERE((p.Location_ID=?) AND (p.SubCategory_ID=?) AND (r.Region_ID=?) AND (p.SubCategory_ID = s.SubCategory_ID) AND (p.Location_ID = l.Location_ID) AND (s.Category_ID = c.Category_ID) AND (l.Region_ID = r.Region_ID))")) { $Title_Query->bind_param('iii', $field1, $field2, $field3); $field1 = $Sub_Category_ID; $field2 = $Location_ID; $field3 = $Region_ID; $Title_Query->execute(); $Title_Query->bind_result(&$Post_Title); //Okay, got the result, now output them to the screen echo "<h3>$Region_Name -> $inputArray[location] -> $Category_Name -> $inputArray[sub_category]</h3>"; echo "The following records were found:"; echo "<br><br>"; while($Title_Query->fetch()) { echo "<a href = \"localhost/build_listing.php\"><u>$Post_Title</u></a>"; echo "<br>"; }//end while $Title_Query->close(); }//end if I don't understand why it would work for some of the parameters, not all... Is my problem obvious or is the problem elsewhere in my code? I'm 99.999% my bind_result and fetch logic is the problem, but I can't see it!
×
×
  • 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.