Re: [PHP-DB] ecommerce - storing as an array or temporary record
> I am developing a script that will eventually be a "pay-to-list your whatever" script. > I am wondering if the best way to hold data throughout the four forms would be to hold > these in an array - each form would array_push() the vars into the $listing array. > Or would it be better to insert the records as they come in - each form - ? > I am thinking that one connection to the DB might be easiest to carry out. Why store them in a database? In any case, Serialize()/UnSerialize() and Sessions.. bkx -- PHP Database 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-DB] retrieving images
Hello, I'm trying to retrieve and output all the binary images in my images table. This is what I have, $result = mysql_query("SELECT * FROM images",$db); if ($myrow = mysql_fetch_array($result)) { // display list if there are records to display do { $filetype = ($myrow["filetype"]); header("Content-type: $filetype"); echo $myrow["binary_junk"]."\n"; } while ($myrow = mysql_fetch_array($result)); } else { // no records to display echo "Sorry, no records were found!"; When I run this, it only returns the first image in the table. Have really know idea where to go from here. Is one image all that can be done? Ok.. some information for you, as you seem to mis-understand some things here... A web-browser can handle certain pices of information being thrown down it's gullett.. The Content-type: is what determines this. If you start by throwing it an image/gif, then it will expenct a gif to come down. If you start throwing ""'s down, it will not only corrupt the image, but not do anything remotely related to HTML. Basically what you need to do is to set up a second PHP routine which grabs the binary data from the dataqbase and displays it, using tags. The first routine just sets up the http://elfgrove.virtual.net.au/~bekar/test.phps) hope this helps. bkx -- PHP Database 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-DB] auto_increment in mysql
> I use MySQL 3.22.23 but I just had a hunt about on the web and I found > a posting that confirmed your findings - I.E: auto_increment starts at > 1!! > > I stand corrected! The reasoning behind this a colleague of mine recently informed me of.. When an insert occurs, the new record is given the value of '0'. The auto-increment occurs once the insert is complete. If you use a 0 value in the auto_increment'd field, and you do a table modification (done this once or twice), you'll find you 0'd field jumped up to the next auto_increment value. bkx --MySQL Documentation extract-- An integer column may have the additional attribute AUTO_INCREMENT. When you insert a value of NULL (recommended) or 0 into an AUTO_INCREMENT column, the column is set to value+1, where value is the largest value for the column currently in the table. AUTO_INCREMENT sequences begin with 1. See section 23.4.30 mysql_insert_id(). If you delete the row containing the maximum value for an AUTO_INCREMENT column, the value will be reused with an ISAM table but not with a MyISAM table. If you delete all rows in the table with DELETE FROM table_name (without a WHERE) in AUTOCOMMIT mode, the sequence starts over for both table types. NOTE: There can be only one AUTO_INCREMENT column per table, and it must be indexed. MySQL Version 3.23 will also only work properly if the auto_increment column only has positive values. Inserting a negative number is regarded as inserting a very large positive number. This is done to avoid precision problems when numbers 'wrap' over from positive to negative and also to ensure that one doesn't accidently get an auto_increment column that contains 0. To make MySQL compatible with some ODBC applications, you can find the last inserted row with the following query: SELECT * from tbl_name WHERE auto_col IS NULL --End Documentation--: manual_Reference.html#IDX839 -- PHP Database 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-DB] Inserting Image as Blob in MySql DB
> Does anyone know the proper method for inserting an image(*.jpg or > *.gif) into a MySql database blob field? I am recieving the file via an > html form with the usual enctype for this and > parameters. I can save it as just a regular file and then display it > fine on the page, but no way can I update the database with this...and > have tried everything imaginable...surely this is done everyday and is > quite simple. > > code snippet below - and yes, I am a php beginner...ASP by day and > trying to learn > PHP by night.. > - > $photo = fopen($txtImage, "r"); > $filecontents = fread($photo, filesize($txtImage)); > echo ""; > echo ""; > $anotherfile = fopen("/www/htdocs/Survey/$thisfile", "a+"); > fputs($anotherfile, $filecontents); > //fclose($anotherfile); > echo ""; > echo ""; > echo ""; > echo $photo; > echo ""; > echo ""; > $crapola = "101010101"; > echo ""; > > > > $connection = mysql_connect("mysql.iticom.net","fractalv","fw348vnj") > or die ("crap!"); > $db = mysql_select_db("fractalv", $connection) or die ("db"); > $sql = "INSERT INTO Images (Image, > ImageType,ImageGallery,ImageLink,ThumbnailLink) VALUES > ('$filecontents','$txtImageType', '$txtImageGallery', '$txtImageLink', > '$txtThumbnailLink')"; > $sql_result = mysql_query($sql,$connection) or die ("could not insert > into DB"); > mysql_close($connection); > -ect. > > thanks in advance for absolutley any ideas! Phil, I can think of two possible ways.. Depending on the version of MySQL you have. If you have v3.23, MySQL has a function called LOAD_FILE() which you can pass the temporary file-name that you get from the wb page: mysql_query( "insert into Images ( Image ) values ( load_file( $txtImage ) );" ); Failing that, I would think that you have to read it in (as you do above), escape it (addslashes() in php) then isnert that escaped string into the database : mysql_query( "insert into Images ( Image ) values ( '" . addslashes( $filecontents ) . "' ); " ); Anyway.. a few possibilities to look into. Bkx -- PHP Database 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-DB] Help with displaying rest of page after MySQL error
""Stuart J. Browne"" <[EMAIL PROTECTED]> wrote in message 98ujpk$i2j$[EMAIL PROTECTED]">news:98ujpk$i2j$[EMAIL PROTECTED]... > > My first line of PHP code (embedded in HTML) has: > > > > $db = mysql_connect("x","y","z") or > > die("saysomethinghere"); > > > > If I have a connection problem, it does print the > > "die" message and the connection error, but it also > > stops the page right there: no more HTML is displayed. > > Well, you've mentioned your problem right here. 'or die ( > "saysomethinghere" );'. Die meaing just that. "Die". Don't process > anything further. > > > I know about suppressing the error message with "@" > > but this wouldn't seem to help this problem. > > Try something like: > > $db = mysql_connect("X", "Y", "Z"); err dang it.. make that: $db = @mysql_connect("x", "y", "z"); > $db_error = mysql_errno(); > if ($db_error <> 0) { > print "Error conencting to the database"; > $db_error = 1; > } else { > # Do the rest of your MySQL Queries etc. here > # or do checks to make sure $db_error is 0 prior > # to doing any... > } > > hope this helps, or atleast points you in the right direction for > resolution. bkx -- PHP Database 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-DB] Help with displaying rest of page after MySQL error
> My first line of PHP code (embedded in HTML) has: > > $db = mysql_connect("x","y","z") or > die("saysomethinghere"); > > If I have a connection problem, it does print the > "die" message and the connection error, but it also > stops the page right there: no more HTML is displayed. Well, you've mentioned your problem right here. 'or die ( "saysomethinghere" );'. Die meaing just that. "Die". Don't process anything further. > I know about suppressing the error message with "@" > but this wouldn't seem to help this problem. Try something like: $db = mysql_connect("X", "Y", "Z"); $db_error = mysql_errno(); if ($db_error <> 0) { print "Error conencting to the database"; $db_error = 1; } else { # Do the rest of your MySQL Queries etc. here # or do checks to make sure $db_error is 0 prior # to doing any... } hope this helps, or atleast points you in the right direction for resolution. bkx -- PHP Database 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]