anf.etienne Posted February 1, 2009 Share Posted February 1, 2009 is it possible to use php to override the same record over and over again in a MySQL database? or is there a way to make php store info in the mysql then once the form process is complete delete the last record it created? if neither is possible.....how can you get php to recall the last record made from mysql? Quote Link to comment Share on other sites More sharing options...
Lucky_PHP_MAN Posted February 1, 2009 Share Posted February 1, 2009 is it possible to use php to override the same record over and over again in a MySQL database? or is there a way to make php store info in the mysql then once the form process is complete delete the last record it created? if neither is possible.....how can you get php to recall the last record made from mysql? I would assume that you are trying to update the record on your database by means of using a form to retrieve the old records and updating its new value. If it is as of above, you can retrieve the old values of the record and populate that into your forms and when the user submit, you can use the UPDATE method in MySQL to update your data. Regards, LPM Quote Link to comment Share on other sites More sharing options...
anf.etienne Posted February 1, 2009 Author Share Posted February 1, 2009 thanks that works. im having some trouble getting my php to submit html to mysql. Am I missing something here??? my code is below <? $username="vecre0_tempU"; $password="auction"; $database="vecre0_templates"; $header=$_POST['header']; $css=$_POST['css']; $content=$_POST['content']; $footer=$_POST['footer']; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query = "INSERT INTO layout (header,css,content,footer)VALUES ('" . mysql_real_escape_string($header) . "','" . mysql_real_escape_string($css) . "','" . mysql_real_escape_string($content) . "','" . mysql_real_escape_string($footer) . "')"; mysql_query($query); mysql_close(); ?> Quote Link to comment Share on other sites More sharing options...
Lucky_PHP_MAN Posted February 1, 2009 Share Posted February 1, 2009 What's the error you get? o.O The code looks pretty fine with me. Regards, LPM Quote Link to comment Share on other sites More sharing options...
anf.etienne Posted February 1, 2009 Author Share Posted February 1, 2009 i don't get an error, the inputs with special characters and html doesn't save within the database but if i just type a normal word with no special characters or codes within it it works perfectly fine Quote Link to comment Share on other sites More sharing options...
anf.etienne Posted February 1, 2009 Author Share Posted February 1, 2009 I have got the code to work properlly inserting html into the sql DB and the querying it to be shown in a text area. is there a way to get php to upload an image(s) to sql DB so that it can be linked to a flash file or is it better to use xml with flash? Quote Link to comment Share on other sites More sharing options...
Lucky_PHP_MAN Posted February 1, 2009 Share Posted February 1, 2009 The current MySQL that I knew does able to store images, provided you define the "MIME Transformation" in the column of the table that you've created. But it would be very heavy resources if you are handling big big queries. I would recommend inserting the "path/to/the/image" into the database as it will speed up process as MySQL Engine only had to work with text rather than some MIME-type. For the Flash, I used XML to work with because some of the APIs in actionscript that make retrieving data from XML easy. Regards, LPM Quote Link to comment Share on other sites More sharing options...
anf.etienne Posted February 1, 2009 Author Share Posted February 1, 2009 thanks for the advice. is it therefore possible to use a file upload which then adds to a table the file name that is generated? If so once the details are in the DB can it be queried in a xml for a flash gallery? bearing in mind i need the flash gallery to show the images that are uploaded at that point not all images within the upload folder.....can this be done? Quote Link to comment Share on other sites More sharing options...
Lucky_PHP_MAN Posted February 1, 2009 Share Posted February 1, 2009 Yes, It is possible to use a file upload. PHP provide function such as $_FILES, which is used to get the file and some of its properties. check out this link http://sg.php.net/manual/en/features.file-upload.post-method.php you can do a query to insert the filename and its path to the database. As for the Flash part, it is possible to generate the XML for the particular image. You just have to echo with "XML" in mind. Here is a short example. // declare XML $xml = "<?xml version=\"1.0\"?>\n"; // insert root node example $xml = "<root></root>"; // insert node example $xml = "<child></child>"; echo $xml; the above will echo out the XML in which in ur flash, you might want to do a URLRequest and URLLoader to load the file above. Flash will read the file header and regard it as XML file. Regards, LPM Quote Link to comment Share on other sites More sharing options...
anf.etienne Posted February 1, 2009 Author Share Posted February 1, 2009 thanks a lot.....im going to get started on this. loool im a newbie at all of this but ill get it in the end......thanks for pointing me in the right direction Quote Link to comment Share on other sites More sharing options...
Lucky_PHP_MAN Posted February 1, 2009 Share Posted February 1, 2009 NP Good luck Regards, LPM Quote Link to comment Share on other sites More sharing options...
anf.etienne Posted February 1, 2009 Author Share Posted February 1, 2009 ooohhhh 1 last question..... in flash the URLrequest or URLLoader are they editable to the extent of getting them to request or load the latest 4 images.....ive never had the pleasure of using them so im not too familiar with it Quote Link to comment Share on other sites More sharing options...
Lucky_PHP_MAN Posted February 1, 2009 Share Posted February 1, 2009 ooohhhh 1 last question..... in flash the URLrequest or URLLoader are they editable to the extent of getting them to request or load the latest 4 images.....ive never had the pleasure of using them so im not too familiar with it I have yet to try them. But you can specify a GET variables. When you try a URLRequest, you might want to specify some like "http://localhost/example.php?var1=value1&var2=value2" that should work when ur PHP script contains $_GET to get these values. Regards, LPM Quote Link to comment Share on other sites More sharing options...
anf.etienne Posted February 1, 2009 Author Share Posted February 1, 2009 okkk i see....so if i create the php with all my variables that basically access the location of the images that are sent to the DB i should be able to request it in flash..... so for example if i query the DB for the location http://www.yourdomain.com/resources/private/upload/image010101.jpg i can link the returned variable to the $_GET? sorry if im being a pain....i understand what you said but im just trying to figure out in my head how i get this part "?var1=value1&var2=value2"" Quote Link to comment Share on other sites More sharing options...
Lucky_PHP_MAN Posted February 1, 2009 Share Posted February 1, 2009 Yes. For example, the url looks something like this "http://localhost/get_image.php?image_path=http://www.yourdomain.com/resources/private/upload/image010101.jpg" in ur PHP scripts $image_path = $_GET['image_path']; /* the above would return "http://www.yourdomain.com/resources/private/upload/image010101.jpg" */ Hope this helps Regards, LPM Quote Link to comment Share on other sites More sharing options...
anf.etienne Posted February 1, 2009 Author Share Posted February 1, 2009 THANK YOUUUUUU lol Quote Link to comment Share on other sites More sharing options...
Lucky_PHP_MAN Posted February 1, 2009 Share Posted February 1, 2009 Not A Problem Good luck Regards, LPM Quote Link to comment Share on other sites More sharing options...
anf.etienne Posted February 1, 2009 Author Share Posted February 1, 2009 hi....ive gone through the php page and a tutorial worked out a coding to upload a file and it works but from this code how do i get the path to save to my DB <? $username="vecre0_tempU"; $password="auction"; $database="vecre0_templates"; $ufile=$_POST['$ufile']; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query = "INSERT images VALUES ('','$ufile')"; mysql_query($query); mysql_close(); ?> <?php $file_name = $HTTP_POST_FILES['ufile']['name']; $random_digit=rand(000000,999999); $new_file_name=$random_digit.$file_name; $path= "upload/".$new_file_name; if($ufile !=none) { if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $path)) { echo "Successful<BR/>"; echo "File Name :".$new_file_name."<BR/>"; echo "File Size :".$HTTP_POST_FILES['ufile']['size']."<BR/>"; echo "File Type :".$HTTP_POST_FILES['ufile']['type']."<BR/>"; } else { echo "Error"; } } ?> i thought that $ufile=$path would surfice but all it did was put a blank entry in the DB, i done something right but something wrong Quote Link to comment Share on other sites More sharing options...
Lucky_PHP_MAN Posted February 1, 2009 Share Posted February 1, 2009 That would depends on how are you going to query it out from the database. In all my usual projects, I would do a SQL query to the database to save the name of the folder and the name of the file. It would be something like "uploads/my.new.file.name.ext Again, that would depend on how would your flash is going to read this database. Regards, LPM Quote Link to comment Share on other sites More sharing options...
anf.etienne Posted February 2, 2009 Author Share Posted February 2, 2009 okkkk so i have gon over varios flash and xml tutorials racked my brains out....and i ended up with a malibu and coke and the code below lol.......from the coding it brings in a xml file that is created from php..... i just don't understand at all how i can get my upload php to upload the file store the location in my DB and create a xml file that calls the location of the 5 images that are uploaded at the time and not all images within the upload folder.....everything i have tried has failed this is my flash code below and i dont know where to start with getting php to do as you stated. stop(); var initXML_default = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><slideshow version=\"3\"><styles><Background backgroundColor=\"#CECED5\" backgroundAlpha=\"100\" bevelColor=\"#FFFFFF\" bevelStrength=\"70\" /><LoaderAnimation type=\"circle\" color=\"#FFFFFF\" alphaBackground=\"20\" alphaInner=\"40\" frameWidth=\"1\" width=\"30\" height=\"30\" /> <!-- or type=\"basic\" --><DataLoader useAnimation=\"true\" useLabel=\"true\" labelPlacement=\"bottom\" fadeOutDuration=\"400\" textFormat=\"loader_text\" /></styles><localization><text orig=\"Loading Data...\" local=\"Loading Data...\" /></localization><fonts>\t<font id=\"loader_text\" name=\"Pixelade\" embed=\"true\" size=\"13\" color=\"#666666\" bold=\"false\" selectable=\"false\" />\t</fonts></slideshow>"; var xml_default; xml_default = "(No data file specified)"; var initObj = {}; initObj.fillStage = true; initObj.forceWidth = 100; initObj.forceHeight = 100; initObj.initXML = _root.initXML != undefined ? (unescape(_root.initXML)) : (initXML_default); initObj.xml = _root.xml != undefined ? (unescape(_root.xml)) : (xml_default); initObj.preventCache = true || (_root.preventCache != undefined ? (_root.preventCache == "true") : (_root.preventCache == true)); initObj.disableMultipleXML = _root.disableMultipleXML != undefined ? (_root.disableMultipleXML == true) : (false); createClassObject(com.ui.Slideshow, "slideshow_mc", getNextHighestDepth(), initObj); Quote Link to comment Share on other sites More sharing options...
anf.etienne Posted February 3, 2009 Author Share Posted February 3, 2009 help??? anybody??? lol Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.