PHP - Unable To Locate Resource In This Object
I am trying to make a thumbnail from an FLV using ffmpeg and ffmpeg-php. I got them all installed.
This is my script: <?php $extension = "ffmpeg"; $extension_soname = $extension . "." . PHP_SHLIB_SUFFIX; $extension_fullname = PHP_EXTENSION_DIR . "/" . $extension_soname; // load extension if(!extension_loaded($extension)) { dl($extension_soname) or die("Can't load extension $extension_fullname\n"); } include("../connect.php"); header("Content-type: image/jpeg"); $id = $_GET['id']; $query = mysql_query("SELECT filename FROM video WHERE id = '$id'"); $result = mysql_fetch_array($query); $moviefile = "../../../../armsmedia/videos/".$result['filename']; $mov = new ffmpeg_movie($moviefile,false); $img = $mov->getFrame(1); $showImg = $img->toGDImage(); $mkNewImg = new ffmpeg_frame($showImg); $maxWid = 150; $oldWid = $mkNewImg->getWidth(); if($oldWid > $maxWid) { $newWid = $maxWid; } $newHgt = $newWid / $movRatio; $mkNewImg->resize($newWid,$newHgt); $newImg = $mkNewImg->toGDImage(); imagejpeg($newImg,$mkThumbFile,40); imagedestroy($newImg); ?> I get a 500 Internal server error so I checked my apache logs and it is saying: Unable to locate ffmpeg_frame resource in this object. in /var/www/html/inc/video/thumbnail.php on line 24 which is pointing to: Code: [Select] $oldWid = $mkNewImg->getWidth(); If I do a print_r($showImg) it returns: Resouce id #7 Any ideas? Similar TutorialsThis topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=319414.0 Hi all !
I have a piece of code he
$result = display_all(fcon, $var1, $var2); function display_all( // defined in another file $query = "SELECT one, two, three four, index1, index2 FROM numbers WHERE index1 = $var1 LIMIT 0, 1"; $result = mysqli_query($fcon, $query); return ($result); )and then I use the returned variable $result to display the value as follows:- while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo "<tr>"; echo "<td>".$one."</td>"; echo "<td>".$two."</td>"; echo "<td>".$three. "</td>"; echo "<td>".$four. "</td>"; echo "<td>".$index1. "</td>"; echo "</tr>"; }and this displays the n rows of data returned. Now I have started using prepared statements and the function is now function display_all{ $query = "SELECT one, two, three four, index1 FROM numbers WHERE index1 = ? LIMIT 0, 10"; $stmt = $conn->prepare($query); $stmt->bind_param('i',$var) if($stmt->execute()) { $stmt->bind_result($one, $two, $three, $four, $index1); $stmt->store_result(); } return($stmt); }However the returned $stmt object is unable to display the n rows of data since it shows null values. I assume that this is not the right way to use the $stmt object to display data. I must be missing something. So I request you guys to help me with this. Thanks loads. Edited by ajoo, 23 December 2014 - 11:24 AM. Hey, I need a simple bit of code to do the following: I am trying to strip out a username in a string. This string will distinguish the username because the string will contain a * right before the username. For example: $string = "blah blah *username blah blah blah" The username can only contain numbers and letters. no spaces. And from that string all I want is the username, for example: $string = username (which will vary of course) Hope this makes sense, made it as clear as I possibly could. Thanks ahead! Currently I am using a script that displays the entire directory. However I am trying to use preg_match to try and figure out
how to just link to one file from the directory via a search string from a form.
I am probably not even close so please bare with me
<?php if (isset($_POST['filelook'])) { $filez = $_POST['filelook']; } /* edit $path to the directory you want to use edit $file_types to change the file types to show */ function file_type($file) { $searchString = $filez; $path_chunks = explode("/", $file); $thefile = $path_chunks[count($path_chunks) - 1]; $dotpos = strrpos($thefile, "."); return strtolower(substr($thefile, $dotpos + 1)); } $file_count = 0; $path = "./WinFiles/files"; $file_types = array('png', 'jpg'); $p = opendir($path); while (false !== ($filelook = readdir($p))) { $files[] = $filelook; } sort($files); echo "<b> Your file results:</b><br> "; if (file_exists($filez) && is_readable($filez) && preg_match($filez)) { echo '<a href="download.php?f='.$filez.'">'.$filez.'</a> <br/>'; //find filename like name searched for... if($file_count == 0) { echo "<b>No file match your file types</b>"; } } ?> I have several "sites" located in my html directory, and each has a "general" access point and an "administrator" access point:
/var/www/html/site1/index.php /var/www/html/site1/administrator/index.php /var/www/html/site2/index.php /var/www/html/site2/administrator/index.php /var/www/html/site3/index.php /var/www/html/site3/administrator/index.phpAll sites are similar except that data will be specific to site1, site2, or site3, etc. Users who log onto /var/www/html/siteX/index.php are totally unrelated to those who logon to /var/www/html/siteX/administrator/index.php, will have different logon credentials, are stored in different DB tables, and each should have their own session. If a user logs off of either the general or administrator site, it should not effect the other site even if they were previously logged on to both on the same PC (and of course not effect other sites). When a user logs off, I would like to destroy their previous cookie and associated session. Users for either will only use https. I am using Apache to rewrite https://www.mysite.com/ to https://mysite.com/. While I named the administrator site "administrator" above, the administrator user has the ability to change the directory name. I am thinking I need to use session_set_cookie_params to specify where I wish the session cookie to be stored since /var/www/html/siteX/administrator/index.php is a sub-directory to /var/www/html/siteX/index.php, but am not really sure. Sorry for the cryptic post, but I am not very well versed in this subject. How would you recommend setting up cookies/sessions for this scenario? Thank you Hey all, I want to have an object that has a property which is an object containing instances of other objects. I try this: Code: [Select] class Blog extends Posts { public $has_posts; public function __construct($a,$b,$c){ $has_posts = (object) array_merge((array) $a, (array) $b, (array) $c); } } class Posts { public $b; public function __construct($b){ $this->b = $b; } } $post1 = new Posts(1); $post2 = new Posts(2); $post3 = new Posts(3); $blog = new Blog($post1,$post2,$post3); var_dump($blog->has_posts); //null foreach($blog->has_posts as $post){ //Invalid argument supplied for foreach() echo $post->b; } But as you see, has_posts is null, not an object containing other objects. Thanks for response. I have a Soup object in a Bowl object in a Microwave object. The Microwave object has the methods: receiveItem(Bowl $b) cookItem(???) I want the Microwave to be able to set the Soup->temperature but I'm not how to do that? Make sense? TomTees Hey PHPFreaks. I made a php code, thats only needed to be showed for admin accounts only. I tryed to echo the mysql_num_rows($result); and it gave me this: Resource id #51 Heres a piece of my code where the problem is: $result = mysql_query("SELECT adminlevel FROM accounts WHERE name = '".$_SESSION['auth_username']."'") or die(mysql_error()); echo $result; echo mysql_num_rows($result); if(mysql_num_rows($result) == 1) { echo '<br /><br /><a href="home.php?admin">Admin Area</a>'; } Hope you can help I was expecting a return string, but got Resource id #2 instead. How do I have a string returned instead of that? heres my table user code Bob One Ted Two I dont get it Code: [Select] <html> <body> <?php $con = mysql_connect("localhost","user","PassWord"); if (!$con) { echo 'Could not connect to MySQL server. <br />Error # ', mysql_errno(), ' Error msg: ', mysql_error(); exit; } $db = mysql_select_db("userdb") or die("Unable to select database"); if (!$db) { echo 'Could not select db. <br />Error # ', mysql_errno(), ' Error msg: ', mysql_error(); exit; } $query = "SELECT code from usertbl WHERE user = 'Ted' LIMIT 0 , 30"; $result = mysql_query($query, $con); if (!$result) { echo 'Could not query server. <br />Error # ', mysql_errno(), ' Error msg: ', mysql_error(); exit; } echo $result; ?> </body> </html> When I use that query in phpmyadmin it works Any pointers much appreciated I keep getting a resource #6 at the top of my script and not sure why. <?php if (isset($_REQUEST['option'])) { switch ($_REQUEST['option']) { case 0: ?> <h1 class="backstage">Biographies Management</h1><br /> <h2 class=backstage>Bio Types</h2><br /> <?php $query = "SELECT * FROM efed_list_styles AS styles"; $result = mysql_query ( $query ); $rows = mysql_num_rows($result); if ($rows > 0) { print'<table width="100%" class="table1"> <tr class="rowheading"> <td> </td> <td width="40" align="center">ID</td> <td>Name</td> </tr>'; $i = 0; while ( $row = mysql_fetch_array ( $result, MYSQL_ASSOC ) ) { $sClass = 'row2'; if ($i++ % 2) $sClass = 'row1'; printf ( "<tr class=\"%s\">", $sClass ); print "<td valign=\"top\" align=\"center\" width=\"30\"><a href=\"#\" onclick=\"ajaxpage('backstage_libs/biolayout.php?option=1&id=$row[id].', 'content'); return false;\">Edit</a></td>"; printf ( "<td align=\"center\" valign=\"top\" width=\"40\">%s</td>", $row ['id'] ); printf ( "<td valign=\"top\">%s</td>", $row ['name'] ); echo '</tr>'; } echo '</table><br>'; } else { echo '<span>There are no bio types.</span><br /><br />'; } returnmain(); footercode(); break; case 1: require_once('../backstageconfig.php'); require_once('../backstagefunctions.php'); $id = $_GET['id']; $query = mysql_query("SELECT * FROM `efed_list_styles` WHERE `id` = '" . $id . "'"); $row = mysql_fetch_array($query); echo $query; ?> <h1 class="backstage">Bio Layouts Management</h1><br /> <h2 class="backstage"><?php echo $row['name']; ?> Biography Layout</h2><br /> <?php } } ?> This works...
$result = mysql_query("SELECT * FROM login_attempts"); while($row = mysql_fetch_array($result)) { $diff = strtotime($row['login_date'])-time(); if ($diff > -300){ $count = $count + 1; } if ($count > 4) { $result = "locked"; } }This returns Resource ID 5... $result = mysql_query("SELECT * FROM login_attempts WHERE login_username='$username'"); while($row = mysql_fetch_array($result)) { $diff = strtotime($row['login_date'])-time(); if ($diff > -300){ $count = $count + 1; } if ($count > 4) { $result = "locked"; } }What's the problem? Many thanks, Hello everyone, I am writing some code for a login script. I keep getting the error Resource ID #13. What does this mean and how can I fix it? Here is the code that I am having trouble with Code: [Select] function user_id_from_username($username) { $username = sanitize($username); $query = mysql_query("SELECT `user_id` FROM `users` WHERE `username` = '$username'"); return mysql_result($query, 0, 'user_id'); } function login($username, $password) { $user_id = user_id_from_username($username); $username = sanitize($username); $password = md5($password); $query = "SELECT COUNT(`user_id`) FROM `users` WHERE `username` = '$username' AND `password` = '$password'"; return (mysql_result(mysql_query($query), 0) == 1) ? $user_id : false; } Hello everyone, I am writing some code for a login script. I keep getting the error Resource ID #13. What does this mean and how can I fix it? Here is the code that I am having trouble with Code: [Select] function user_id_from_username($username) { $username = sanitize($username); $query = mysql_query("SELECT `user_id` FROM `users` WHERE `username` = '$username'"); return mysql_result($query, 0, 'user_id'); } function login($username, $password) { $user_id = user_id_from_username($username); $username = sanitize($username); $password = md5($password); $query = "SELECT COUNT(`user_id`) FROM `users` WHERE `username` = '$username' AND `password` = '$password'"; return (mysql_result(mysql_query($query), 0) == 1) ? $user_id : false; } I am currently trying create a sales system where it checks the user's username against the database to check whether they are in the list of buyers. The mysql query returns "Resource id #35", I need it to return the actual username (which I manually inserted into the database to test). PHP code that fetches from database: <?php $con = mysql_connect("x","x","x"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("x", $con); $check_buyer = "SELECT * FROM Buyers WHERE Buyer='x'"; $buyer = mysql_query($check_buyer); ?> Product page: <?php include("/home/x/public_html/scripts/buyer.php"); if ($user->data['user_id'] == ANONYMOUS) { echo 'To use ' . $product . 'you must be logged in!'; echo '<br /><a href="http://x/forum/ucp.php?mode=register">Register</a>'; echo ' or '; echo '<a href="http://x/forum/ucp.php?mode=login">Sign In</a>'; } elseif ($user->data['username_clean'] == $buyer) { echo "<h3>Welcome to x</h3>"; } else { echo "You need to buy this product to use it!"; echo $user->data['username_clean']; //test whether username is outputted correctly - which it did echo $buyer; //Fetched from mysql - returned "Resource id #35", not the desired username } ?> Any help would be great! Thanks, otester Hi, I have the following code which I have been able to put together with alot of the brilliant help on this forum. When I run this code it just came up with a blank screen and the CSS however I added another error print "echo "fetchdata: $fetchdata<br>Failed with error: " . mysql_error() . '<br>';" and the result now is "fetchdata: Resource id #2". However, when search for this on Google many of the responses data back from between 2002-2006. Does it just mean that there is an error with the second if query or does Resource id #2 refer to a specific error? Im really puzzled why I cant find anything more modern to this error on Google. <?php if( isset($_GET['id']) && ctype_digit($_GET['id']) ) { // validate that $_GET['id'] is set, and contains only numeric characters $id = (int) $_GET['id']; // cast value as an integer, and assign to $id $query = "SELECT * FROM productfeed WHERE id = $id"; if( !$fetchdata = mysql_query($query) ) { // numeric values shouldn't be quoted in query strings. echo "query: $query<br>Failed with error: " . mysql_error() . '<br>'; } else { while($row = mysql_fetch_array($fetchdata)) $id = $row['id']; $image = $row['awImage']; $link = $row['link']; $description = $row['description']; $fulldescription = $row['fulldescription']; $price = $row['price']; echo "<div class=\"productdisplayshell\"> <div class=\"productdisplayoutline\"> <div class=\"productborder\"><center> <a href=\"$link\" target=\"_blank\" ><img src=\"$image\" /></a> </center> </div></div> <div class=\"productdescriptionoutline\"><div class=\"productdescriptionbox\"> <a href=\"$link\" target=\"_blank\" >$description</a> </div><div class=\"productfulldescriptionbox\"> $fulldescription </div></div> <div class=\"productpriceoutline\"> <div class=\"productpricebox\"><center>&#163; $price</center></div> <div class=\"productbuybutton\"><center><a href=\"$link\" target=\"_blank\" ><img src=/images/buybutton.png /></a></center></div></div></div>"; echo "fetchdata: $fetchdata<br>Failed with error: " . mysql_error() . '<br>'; } } else { echo 'Product is not available. Please visit our <a href="http://www.ukhomefurniture.co.uk">Homepage</a>'; exit(); } ?> Here is what is echoing the string "Resource id #1". However I do not know if it is the php or javascript that is outputting this. Can anyone tell me why this is showing and how to make it not show? PHP: Code: [Select] $directory = "Images/items/$product/"; //get all image files with a .jpg extension. $images = glob($directory . "*.jpg"); $imgone = $images[0]; $gallery = '<tr><td valign="top" align="center">'; foreach($images as $image) { $tn = explode("/", $image); $tnname = $tn[3]; $gallery .= '<a href="#" rel="'.$image.'" class="image" alt="Images/items/'.$product.'/large/'.$tnname.'"><img src="Images/items/'.$product.'/thumbs/'.$tnname.'" class="thumb" border="1" style="margin-bottom:7px;"/></a> '; } if(is_dir("Images/items/".$product)) $gallery .= "</td></tr><tr><td width='300'>".$link."<div id='image' class='bigimg' align='left'>"; if(is_dir('Images/items/'.$product)) $gallery .= '<img src="'.$imgone.'" border="0"/></div></a></td></tr>'; JS (jQuery) Code: [Select] $(function() { $(".image").click(function() { var image = $(this).attr("rel"); var large = $(this).attr("alt"); $('#image').hide(); $('#image').fadeIn('slow'); $('#image').html('<a href="' + large + '" ><img src="' + image + '"/></a>'); return false; }); }); I'm trying to show my friend my website and it's not letting him or me view it. I am using my own IP-address. (dashed out for security, but it is correct) http://--.---.--.---/index-1.php When he and I type this into our browser, we can an error called "Resource Not Found". But, when I use localhost address, it works fine. http://localhost/index-1.php Does anyone know what is wrong? Do I need to open a specific port? USING XAMPP. How can I fix this error? Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given Code: [Select] function fetch_most_recent_fans($ctag) { $sql = "SELECT `company_fans`.`company_id`, `company_fans`.`user_id`, `company_fans`.`fan_date`, `companies`.`companytag`, `users`.`firstname`, `users`.`lastname`, `users`.`username` FROM `company_fans` LEFT JOIN `companies` ON `companies`.`companyid` = `company_fans`.`company_id` LEFT JOIN `users` ON `users`.`id` = `company_fans`.`user_id` WHERE `companies`.`companytag` = {ctag} ORDER BY `company_fans`.`fan_date` DESC LIMIT 10"; $query = mysql_query($sql); $return = array(); while (($row = mysql_fetch_assoc($query)) !== false) { $return[] = $row; } return $return; } If $result contains the result of mysql_query, a select count distinct query, how do I access the count? I've tried $result[0] to no avail and $result only returns the resource #. Hi, I was in the process of making thumnails for avatars It used to work before but now the files are being saved as resource ID and not in an image format. I can not point out what the issue is and also may I add when I try to echo nothing is happening. Code: [Select] $filename = $_FILES['myfile']['tmp_name']; if ($_POST['cpic']) { // Set a maximum height and width $width = 100; $height = 100; // Get new dimensions list($width_orig, $height_orig) = getimagesize($filename); $ratio_orig = $width_orig/$height_orig; $ratio_orig; if ($width/$height > $ratio_orig) { $width = $height*$ratio_orig; } else { $height = $width/$ratio_orig; } // Resample $image_p = imagecreatetruecolor($width, $height); $image = imagecreatefromjpeg($filename); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig); $location = "cid/$myid/$filename"; imagejpeg($image_p, $location, 100); $query =mysql_query ("UPDATE clp SET avatar ='$location' WHERE cid='1'"); header ("LOCATION: editprofile.php"); } |