Re: [PHP] Resource ID# 5 and Resource id #5 8561 errors....help
On Fri, Dec 12, 2008 at 16:54, Terion Miller webdev.ter...@gmail.com wrote: $query = SELECT * FROM importimages WHERE Category='Obits' ; $result = mysql_query ($query); $arr = mysql_fetch_row($result); $result2 = $arr[0]; echo ($result2); Try this to get yourself started: ?php $sql = SELECT * FROM `importimages` WHERE `Category` = 'Obits'; $result = mysql_query($sql) or die(Error in .__FILE__.:.__LINE__. - .mysql_error()); while($row = mysql_fetch_array($result)) { foreach($row as $k = $v) { echo stripslashes($k).: .stripslashes($v).br /\n; } } ? NOTE: You shouldn't need stripslashes(), but it's put there just for backwards-compatibility in case you're on an older (or poorly-configured) installation. -- /Daniel P. Brown http://www.parasane.net/ daniel.br...@parasane.net || danbr...@php.net 50% Off Hosting! http://www.pilotpig.net/specials.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Resource ID# 5 and Resource id #5 8561 errors....help
On Fri, Dec 12, 2008 at 4:02 PM, Daniel P. Brown daniel.br...@parasane.netwrote: On Fri, Dec 12, 2008 at 16:54, Terion Miller webdev.ter...@gmail.com wrote: $query = SELECT * FROM importimages WHERE Category='Obits' ; $result = mysql_query ($query); $arr = mysql_fetch_row($result); $result2 = $arr[0]; echo ($result2); Try this to get yourself started: ?php $sql = SELECT * FROM `importimages` WHERE `Category` = 'Obits'; $result = mysql_query($sql) or die(Error in .__FILE__.:.__LINE__. - .mysql_error()); while($row = mysql_fetch_array($result)) { foreach($row as $k = $v) { echo stripslashes($k).: .stripslashes($v).br /\n; } } ? NOTE: You shouldn't need stripslashes(), but it's put there just for backwards-compatibility in case you're on an older (or poorly-configured) installation. -- /Daniel P. Brown http://www.parasane.net/ daniel.br...@parasane.net || danbr...@php.net 50% Off Hosting! http://www.pilotpig.net/specials.php Thanks Daniel that did get me further, am I now to build an object from the array, or take off one of the array to make an object, your snippet did grab the names of the images and print them to the page but then I get stuck where the page is trying to get the property of a non-object ..so I guess im asking is a possible to turn an array into an object? or in this case separate objects?
Re: [PHP] Resource ID# 5 and Resource id #5 8561 errors....help
On Fri, Dec 12, 2008 at 4:52 PM, Terion Miller webdev.ter...@gmail.comwrote: On Fri, Dec 12, 2008 at 4:02 PM, Daniel P. Brown daniel.br...@parasane.net wrote: On Fri, Dec 12, 2008 at 16:54, Terion Miller webdev.ter...@gmail.com wrote: $query = SELECT * FROM importimages WHERE Category='Obits' ; $result = mysql_query ($query); $arr = mysql_fetch_row($result); $result2 = $arr[0]; echo ($result2); Try this to get yourself started: ?php $sql = SELECT * FROM `importimages` WHERE `Category` = 'Obits'; $result = mysql_query($sql) or die(Error in .__FILE__.:.__LINE__.well I changed it to - .mysql_error()); while($row = mysql_fetch_array($result)) { foreach($row as $k = $v) { echo stripslashes($k).: .stripslashes($v).br /\n; } } ? NOTE: You shouldn't need stripslashes(), but it's put there just for backwards-compatibility in case you're on an older (or poorly-configured) installation. -- /Daniel P. Brown http://www.parasane.net/ daniel.br...@parasane.net || danbr...@php.net 50% Off Hosting! http://www.pilotpig.net/specials.php Thanks Daniel that did get me further, am I now to build an object from the array, or take off one of the array to make an object, your snippet did grab the names of the images and print them to the page but then I get stuck where the page is trying to get the property of a non-object ..so I guess im asking is a possible to turn an array into an object? or in this case separate objects? Well I did some changes and I must be learning because although I have the same error I don't have new ones... so now the code is like this: $sql = SELECT * FROM `importimages` WHERE `Category` = 'Obits'; $result = mysql_query($sql) or die(Error in .__FILE__.:.__LINE__. - .mysql_error()); while($object = mysql_fetch_object($result)) { foreach($object as $k = $v) { echo stripslashes($k).: .stripslashes($v).br /\n; } } $FileName = $object-Image; ---This is the line that is telling me it is trying to get the properties of a non-object
Re: [PHP] Resource ID# 5 and Resource id #5 8561 errors....help
On Fri, Dec 12, 2008 at 18:03, Terion Miller webdev.ter...@gmail.com wrote: Well I did some changes and I must be learning because although I have the same error I don't have new ones... so now the code is like this: $sql = SELECT * FROM `importimages` WHERE `Category` = 'Obits'; $result = mysql_query($sql) or die(Error in .__FILE__.:.__LINE__. - .mysql_error()); while($object = mysql_fetch_object($result)) { foreach($object as $k = $v) { echo stripslashes($k).: .stripslashes($v).br /\n; } } $FileName = $object-Image; ---This is the line that is telling me it is trying to get the properties of a non-object That's because you're calling that as an object using OOP standards, where I gave you procedural code. To interface with my code, just call it as: ?php // other code here while($row = mysql_fetch_array($result)) { echo $row['Image'].br /\n; // If `Image` is the column name. } // code continues ? -- /Daniel P. Brown http://www.parasane.net/ daniel.br...@parasane.net || danbr...@php.net 50% Off Hosting! http://www.pilotpig.net/specials.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Resource ID# 5 and Resource id #5 8561 errors....help
On Fri, Dec 12, 2008 at 5:08 PM, Daniel P. Brown daniel.br...@parasane.netwrote: On Fri, Dec 12, 2008 at 18:03, Terion Miller webdev.ter...@gmail.com wrote: Well I did some changes and I must be learning because although I have the same error I don't have new ones... so now the code is like this: $sql = SELECT * FROM `importimages` WHERE `Category` = 'Obits'; $result = mysql_query($sql) or die(Error in .__FILE__.:.__LINE__. - .mysql_error()); while($object = mysql_fetch_object($result)) { foreach($object as $k = $v) { echo stripslashes($k).: .stripslashes($v).br /\n; } } $FileName = $object-Image; ---This is the line that is telling me it is trying to get the properties of a non-object That's because you're calling that as an object using OOP standards, where I gave you procedural code. To interface with my code, just call it as: ?php // other code here while($row = mysql_fetch_array($result)) { echo $row['Image'].br /\n; // If `Image` is the column name. } // code continues ? -- /Daniel P. Brown http://www.parasane.net/ daniel.br...@parasane.net || danbr...@php.net 50% Off Hosting! http://www.pilotpig.net/specials.php Here is the full chunk: $sql = SELECT * FROM `importimages` WHERE `Category` = 'Obits'; $result = mysql_query($sql) or die(Error in .__FILE__.:.__LINE__. - .mysql_error()); while($object = mysql_fetch_object($result)) { foreach($object as $k = $v) { echo stripslashes($k).: .stripslashes($v).br /\n; } } $FilePath = output/WebImagesHiRes/; $BackupPath = output/WebImagesHiRes/backup/; $FileName = $object-Image; //because it is going to process an image doesnt that make it oop? $FileName = str_replace(/, , $FileName); $FileName = str_replace(.jpg, , $FileName); Well its late friday afternoon here, I'm ready to break away from my desk...maybe on monday I will be able to get it working (right now our obit pics in the online paper are not getting posted...oops) Thanks folks yawn LEts call it a weekend wt terion
Re: [PHP] Resource ID# 5 and Resource id #5 8561 errors....help
Terion Miller wrote: On Fri, Dec 12, 2008 at 5:08 PM, Daniel P. Brown daniel.br...@parasane.netwrote: On Fri, Dec 12, 2008 at 18:03, Terion Miller webdev.ter...@gmail.com wrote: Well I did some changes and I must be learning because although I have the same error I don't have new ones... so now the code is like this: $sql = SELECT * FROM `importimages` WHERE `Category` = 'Obits'; $result = mysql_query($sql) or die(Error in .__FILE__.:.__LINE__. - .mysql_error()); while($object = mysql_fetch_object($result)) { foreach($object as $k = $v) { echo stripslashes($k).: .stripslashes($v).br /\n; } } $FileName = $object-Image; ---This is the line that is telling me it is trying to get the properties of a non-object That's because you're calling that as an object using OOP standards, where I gave you procedural code. To interface with my code, just call it as: ?php // other code here while($row = mysql_fetch_array($result)) { echo $row['Image'].br /\n; // If `Image` is the column name. } // code continues ? -- /Daniel P. Brown http://www.parasane.net/ daniel.br...@parasane.net || danbr...@php.net 50% Off Hosting! http://www.pilotpig.net/specials.php Here is the full chunk: $sql = SELECT * FROM `importimages` WHERE `Category` = 'Obits'; $result = mysql_query($sql) or die(Error in .__FILE__.:.__LINE__. - .mysql_error()); while($object = mysql_fetch_object($result)) { foreach($object as $k = $v) { echo stripslashes($k).: .stripslashes($v).br /\n; } } $FilePath = output/WebImagesHiRes/; $BackupPath = output/WebImagesHiRes/backup/; $FileName = $object-Image; //because it is going to process an image doesnt that make it oop? $FileName = str_replace(/, , $FileName); $FileName = str_replace(.jpg, , $FileName); Well its late friday afternoon here, I'm ready to break away from my desk...maybe on monday I will be able to get it working (right now our obit pics in the online paper are not getting posted...oops) Thanks folks yawn LEts call it a weekend wt terion Try this ?php $FilePath = output/WebImagesHiRes/; $BackupPath = output/WebImagesHiRes/backup/; #setup query $sql = SELECT * FROM `importimages` WHERE `Category` = 'Obits'; #excute query and return results, if any $result = mysql_query($sql) or die(Error in .__FILE__.:.__LINE__. - .mysql_error()); # Loop through results, pulling each resulting row as an object while($object = mysql_fetch_object($result)) { # Grab the Image contents and work with it. $FileName = $object-Image; // Watch it, this is case-sensitive!!! $FileName = str_replace(/, , $FileName); $FileName = str_replace(.jpg, , $FileName); echo $FileName; ... Do the rest of what you place to do with each row ... } ? -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] resource id#
When I try to insert a field into my database it shows as Resource id#21? I must be doing something dim. Some could would definetely help here... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] resource id#
Ross wrote: When I try to insert a field into my database it shows as Resource id#21? I must be doing something dim. Right after you try to do the insert, echo out mysql_error() -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Resource id #X
On Thu, August 18, 2005 1:00 am, Chris Boget wrote: * User A accesses page X, which makes a connection to the database. Echoing out the result of the mssql_pconnect() function shows it's using 'Resource id #10'. * User B accesses the same page, X, making another connection to the database. Echosing out the result of the pconnection function shows it's using 'Resource id #10' Now, even though they are showing the same resource id, it's not actually the same connection, correct? Correct. If you echo out EVERY connection/result/resource, you will see that PHP pretty much just starts counting at 1 at the beginning of a script and increments the resource counter on each resource. Change the script to, say, connect to some other database at the top, and everything will be off by 1 from the previous user. BEGIN TRAN (user a) BEGIN TRAN (user b) Query (user b) Query (user a) ROLLBACK (user b) COMMIT (user a) with User B rolling back User A's transaction and User A committing User B's transaction (or no transaction at all). Hm. Take out the _pconnect. Or switch to MySQL or PostgreSQL maybe for a test, just to see if their transactions exhibit the same behaviour. SQL Server is the least-broken Microsoft product... You could also try using the Sybase drivers to connect to MS SQL. Last I heard, they were faster anyway. Though it's been years since anybody has had enough money to get me to use an MS product. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Resource id #1
It's probably a database result set or a connection object or something similar. Shaunak -Original Message- From: Mike Mapsnac [mailto:[EMAIL PROTECTED] Sent: Monday, February 16, 2004 11:53 AM To: [EMAIL PROTECTED] Subject: [PHP] Resource id #1 I print variable to the screen and get the result Resource id #1. Any ideas waht Resource id #1 is? Thanks _ Plan your next US getaway to one of the super destinations here. http://special.msn.com/local/hotdestinations.armx -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Resource ID??
John, This is the output: Resource id #15 or some other seemingly arbitrary Resource ID number? First of all what is a resource ID and second how do I get it to actually show what I am trying to get it to show! =When MySQL returns data to PHP, the information is put into a variable called a resource special data type. When you attempt to treat this as if it were a string data type, all that it 'reveals' is the ResouceID (as you have found). =Please return to the manual, re-read the MySQL_query entry, and then move on to the MySQL_fetch_... series of functions. These are designed to extract (most usually) a row of data at a time from the ResourceID/MySQL resultset and make it available to your PHP script - examples given in the annotated manual. Regards, =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] resource ID?
Kurth Bemis [EMAIL PROTECTED] wrote: i get this: Resource id #2 when i run this code.whats resource id 2 mean? i just want to know if the query was ok or not $result = mysql_query(SELECT authcode FROM users WHERE email='$email',$db); echo $result; because $result is the result of a mysql query and you can not echo this to get the values instead you for example have to use mysql_fetch_array to get all the values from the $result. php.net/mysql -- Henrik Hansen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] resource ID?
heh, that basically means that query was ok at least techincally. When you echo that $result and get nothing - then something went wrong. The right way to check if query was ok is: if(is_resource($result)) echo Query OK; or just: if($result) echo Query OK; lenar. Kurth Bemis [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... i get this: Resource id #2 when i run this code.whats resource id 2 mean? i just want to know if the query was ok or not $result = mysql_query(SELECT authcode FROM users WHERE email='$email',$db); echo $result; ~kurth -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] resource ID?
this is because mysql_query() returns a result identifier for select statements NOT a string or whatever you expected... if ($result) { my query was syntactically ok, but I still don't know anything about the result } else { my query was semantically invalid. } have a look at mysql_result() and mysql_num_rows() to find out more about the result ouf your query... - andi Kurth Bemis [EMAIL PROTECTED] schrieb in im Newsbeitrag: [EMAIL PROTECTED] i get this: Resource id #2 when i run this code.whats resource id 2 mean? i just want to know if the query was ok or not $result = mysql_query(SELECT authcode FROM users WHERE email='$email',$db); echo $result; ~kurth -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] resource id #2
try $query="Select pass from members where uname='$username'"; $result = mysql_query($query) or die("You are not authorized to be here."); the mysql_query command is executing the statement morgan At 10:40 AM 4/16/2001, Greg K wrote: I am trying to run a query and in my log I am getting a message the message resource id #2. $query=mysql_query("Select pass from members where uname='$username'"); $result = mysql_query($query) or die("You are not authorized to be here."); Can someone tell me what I am doing wrong and guide me in the right direction -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] resource id #2
$query=mysql_query("Select pass from members where uname='$username'"); $result = mysql_query($query) or die("You are not authorized to be here."); ? $query=mysql_query("Select pass from members where uname='$username'"); $result = mysql_query($query); // If the number of rows is less than one (meaning zero) then die() if ($mysql_num_rows($result) 1)) { die("You are not authorized to be here."); } ? What you are doing is checking if the query is valid. Your die() would print only if you had a faulty query (try changing pass to pass2), but if the username is wrong, it returns an empty set. The mysql_query() returns the "resource id #2" that you can use with the mysql_fetch_array, mysql_num_rows etc to get printable information. // Tobias -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] resource id #2
Greg K schrieb: I am trying to run a query and in my log I am getting a message the message resource id #2. $query=mysql_query("Select pass from members where uname='$username'"); $result = mysql_query($query) or die("You are not authorized to be here."); Can someone tell me what I am doing wrong and guide me in the right direction Please check the docs http://www.php.net/manual/en/ref.mysql.php / http://www.php.net/manual/en/function.mysql-fetch-row.php (don't forget to read the user comments!) and the usual sites for tutorials e.g. http://www.phpbuilder.com . Ulf -- Neu: PEAR Menu 3 - Navigationsstrukturen dynamisch dargestellt http://www.ulf-wendel.de/projekte/menu/tutorial.php | http://www.phpdoc.de -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]