Jump to content

erok

Members
  • Posts

    62
  • Joined

  • Last visited

Everything posted by erok

  1. I want to display that particular property is available for short term or long term or both short term and long term available depends on property owner's preferences. Is it possible to store more than one value in one column? Other thing i assumed when i set $period=array(), $period=$value3 would be array not string. Sounds like i was wrong.
  2. Thank you very much for analyzing my codes. I searched on several web sites but my mind is not clear about how checkboxes and radio buttons works, how to insert them into database. Maybe value 1,2,3.. or yes,no i want user would be able to, e.g. check period checkbox short and long together and code would be able to store in database period column. Yes i meant to use checkbox for period.
  3. Hi everyone, i am unable to insert radio and checkbox values into phpmyadmin d.b. columns all i see is zero values in columns. what am i doing wrong? Any help greatly appreciated. erok <form enctype="multipart/form-data" method="post" action="deneme.php" > <span>Title</span><input type="text" name="title" size="78" maxlenght="78" value="available" /> <br /> <span>Transportation</span>Yes <input type="radio" name="trans" size="3" maxlenght="3" <?php if (isset($trans) && $trans=="yes") echo "checked";?> value="yes" /> No <input type="radio" name="trans" size="3" maxlenght="3" <?php if (isset($trans) && $trans=="no") echo "checked";?> value="no" /> <br /> <span>**** Lenght(s)</span>upto 50** <input type="checkbox" name=" lenght[]" size="9" maxlenght="9" value="50" /> upto 100** <input type="checkbox" name="lenght[]" size="9" maxlenght="9" value="100" /> upto 150** <input type="checkbox" name="lenght[]" size="9" maxlenght="9" value="150" /> <br /> <span> </span>upto 200** <input type="checkbox" name="lenght[]" size="9" maxlenght="9" value="200" /> over 200** <input type="checkbox" name="lenght[]" size="9" maxlenght="9" value="201" /> <br /> <span>**** Period</span>Transient <input type="checkbox" name="period[]" size="9" maxlenght="9" value="trans" /> Short Term <input type="checkbox" name="period[]" size="9" maxlenght="9" value="short" /> long Term <input type="checkbox" name="period[]" size="9" maxlenght="9" value="long" /> <br /> <input type="submit" name="kitchen" id="forminsert" value="upload all" size="35" />. <br /> </form> <?php error_reporting(E_ALL | E_STRICT) ; ini_set('display_errors', 'on'); ini_set('html_errors', true); //connect to database server $con = mysqli_connect("localhost", "root", ""); if (mysqli_connect_error($con)) { echo "Failed to connect to MySQL: " . mysqli_connect_error() ; } // select database mysqli_select_db($con, "lima") or die("Could not find DB"); $title = $trans = $lenght = $period = "" ; if(!empty($_POST['title'])) { $title=$_POST['title'] ; } echo $title ; if(!empty($_POST['trans'])) { $trans=$_POST['trans'] ; } echo $trans ; if(!empty($_POST['lenght'])) { $lenght=array() ; $lenght1=$_POST['lenght'] ; foreach($lenght1 as $value1) { $lenght=$value1 ; } } echo $lenght ; if(!empty($_POST['period'])) { $period=array() ; $period=$_POST['period'] ; foreach($period as $value3) { $period=$value3 ; } } echo $period ; // insert into table $sql = "insert into dakdeneme (title, trans, lenght, period) values ('{$title}', '{$trans}', '{$lenght}', '{$period}')" ; $sql= mysqli_query($con, $sql) ; ?>
  4. I sent content-type header and then binary data $type = $imageData['type'] ; header("Content-type: {$type}") ; imagejpeg($content) ; imagedestroy($content) ; i see " application/msword " inserted in at the 'type' column in the database. so, i am assuming i have no problem with header "Content-type" . am i missing a function?
  5. Hi all, I am able to insert .doc file into database using the same code i used for images. I am trying to get .doc file from database and display it on browser. The code i used for displaying images does not work for .doc files. - Here is the code i tried to display .doc file; $bunu = base64_decode($dene) ; $content = imagecreatefromstring($bunu) ; if ($content !== false) { header("Content-type: {$type}") ; imagejpeg($content) ; imagedestroy($content) ; } else { echo 'an error occured. ' ; } Is there any specific function i can use for displaying .doc files or pdf ? any direction appreciated. erok
  6. Can you guys name any book for intermediate php?
  7. i tried something like this. it did not work. I am able to insert the text into table. i could not take it from table and put on a page together with image. header("Content-type: image/$image_type") ; $black = imagecolorallocate($im, 0, 0, 0) ; $caption ; $font = 'arial.ttf' ; imagettftext($im, 20, 0, 10, 20, $black, $font, $caption) ; imagejpeg($im) ; imagedestroy($im) . I tried inefficient way, selecting text(caption) from same table separate and put the text on a page under the image. in this way it works. Program have to connect to server one more time to get the text .It does not sound good idea if website has heavy image traffic. But at least it works
  8. Hi all, thank you for your help. I am able to display picture i used the following code and the program ran fine. <img src="image.php?id=<?=$imageId ?> . . header("Content-type: image/$image_type") ; imagejpeg($im) ; imagedestroy($im) ; I decided to add some more features and include a text under the picture as a caption. I am able to insert text into table as a new column. using $caption= $_POST['message'] ; I am unable to get text under the picture. I used following two separate codes, neither of these brought the text under the picture. only able to display picture. header("Content-type: image/$image_type") ; imagejpeg($im) ; imagedestroy($im) ; echo $caption or header("Content-type: image/$image_type") ; imagejpeg($im) ; echo $caption imagedestroy($im) ; What am i missing? direction appreciated erok
  9. . . $sql = stripslashes("SELECT type, image FROM images WHERE id= {$imageid}") ; // the result of the query $lresult = mysqli_query($con, $sql) or die("Problem : " . mysqli_error($con)); $id = (int) mysqli_insert_id($con); $imagedata = mysqli_fetch_array($lresult) ; $imagedata = imagecreatefromstring($imagedata) ; header("Content-type: image/jpeg") ; echo $imagedata['image'] ; } mysqli_close($con) ; ?> </body> </html> the picture i uploaded is a jpg when i ran the code, I got this error message ; <b>Notice</b>: Array to string conversion in <b>C:xampphtdocsimage_insert0.php</b> on line <b>38</b><br /> <br /> <b>Warning</b>: imagecreatefromstring(): Empty string or invalid image in <b>C:xampphtdocsimage_insert0.php</b> on line <b>38</b><br />
  10. it is not binary data like ( 00110110). it is more like " %ny#ejyy<":/$@*^ ..." two pages long. Actually i tried copy paste to show you what message is like. I could not copy/paste the message. I have not had this before. This is the first time this happen when i tried to display the picture. I still feel like i am missing some functions.
  11. This is the flow i tried so far ; $query = "INSERT INTO images (name, type, image) VALUES ('{$name}', '{$type}', '{$image}')"; . . . $sql = stripslashes("SELECT type, image FROM images WHERE id= {$imageid}") ; . $lresult = mysqli_query($con, $sql) $imagedata = mysqli_fetch_array($lresult, MYSQLI_ASSOC) ; header("Content-type: . {$imagedata['type']}") ; It did not work out. After justsomeguy' suggestion I switch to header("Content-type: image/jpeg"); Hoping might make difference. When i run, unfortunately same problem. I view computer machine language script instead of picture. Something i am missing for sure.
  12. This is the section of the code i run ; A) $sql = stripslashes("SELECT type, image FROM images WHERE id= {$imageid}") ; // the result of the query $lresult = mysqli_query($con, $sql) or die("Problem : " . mysqli_error($con)); $id = (int) mysqli_insert_id($con); $imagedata = mysqli_fetch_array($lresult, MYSQLI_ASSOC) ; header("Content-type: . {$imagedata['type']}") ; echo $imagedata ; This is the error message i got <b>Notice</b>: Array to string conversion in <b>C:xampphtdocsimage_insert0.php</b> on line <b>39</b><br />Array</body> If i type ; echo $imagedata['image']; instead of echo $imagedata ; I view computer machine language script I believe i am missing some functions ; I would appreciate any direction
  13. Hi justsomeguy, I view computer machine language script, instead of picture. What possible am i missing? erok
  14. Hi people, Actually, code is about uploading image to database table by using blob. So image is in the database table. I need to retrieve image from database table and display it.
  15. Hi everyone, Thanks birbal. mysqli_error() made difference. error was unneccesary first column '' correct code is /* $query = "INSERT INTO images (name, image) VALUES ('{$name}', '{$image}')"; */ still i have some more work to do.I need to retrieve image from database and display it Thanks again erok
  16. The following code is not working. even php error is not commenting at all. Just reading " something wrong " which is my statement in the code. i also tried ' sprintf ' function also. I failed. - HTML FORM ; <html> <body> <form enctype="multipart/form-data" method="post" action="image_insert0.php" > <input type="hidden" name="MAX_FILE_SIZE" value="1000000" /> <p id="phup">Click browse button to choose photo:<br /><input type="file" name="image" /></p> <br /> <textarea id="photoup" type="text" name="message" maxlenght="200" rows="10" col="85"></textarea> <br /> <br /> <input type="submit" name="formsubmit" value="upload here" size="35" /> </form> </body> </html> - Upload into phpmyadmin database code ; <html> <body> <?php mysqli_select_db($con, "theboatcare") or die("Could not find DB"); if (isset($_POST['formsubmit'])) { $image = $_FILES['image'] ; print_r($image); $name = $_FILES['image']['name'] ; $image = addslashes(file_get_contents($_FILES['image']['tmp_name'])) ; $query = "INSERT INTO images (name, image) VALUES ('', '{$name}', '{$image}')"; $result = mysqli_query($con, $query) or die('something wrong' . mysql_error()); $id = (int) mysqli_insert_id($result); header('Location: image_view.php?id=' . $id); exit; } ?> </body> </html> Any direction appreciated erok
  17. Thanks for help.This code running properly. It strips off white space. $phone = ($_POST['phone']);$phone = str_replace(" ", "", $phone); // Strip off white spaces $phone = mysql_real_escape_string($phone);$phone = addslashes($phone);Erok
  18. Sorry I tried this one also.It did not work.$phone = ($_POST['phone']);$phone = str_replace("\" \"", "empty()", $phone); // Strip off white spaces $phone = mysql_real_escape_string($phone);$phone = addslashes($phone);with these codes program running fine.Just not stripping off white space.
  19. Hi justsomeguy,I tried these codes below they did not make difference.They did not strip off white space$phone = ($_POST['phone']);$phone = str_replace("\" \"", "\"empty()\"", $phone); // Strip off white spaces $phone = mysql_real_escape_string($phone);$phone = addslashes($phone);and$phone = ($_POST['phone']);$phone = str_replace("\" \"", "\"\"", $phone); // Strip off white spaces $phone = mysql_real_escape_string($phone);$phone = addslashes($phone);
  20. Hi everyone, I have this statement , $phone = ($_POST['phone']);$phone = trim($phone, "\" \""); // Strip off white spaces $phone = mysql_real_escape_string($phone);$phone = addslashes($phone); when user enter phone number into phone field such as;954 333 or 954333I want database register phone number to tablelike 954333 without white space, even if the user type in 954 333.I tried trim or regexp. They did not work out.What function i should use to strip off automatically any white space in the middle.Any help appreciatedErok
  21. Thanks justsomeguy, Program case-insensitive now. it does not duplicate the same record just because using different case characters.I replaced utf8_bin to utf8_unicode_ci. I added ORDER BY id to select query. Since then last record goes to end of the list.Erok
  22. Thannkk you very much justsomeguy, Problem solved, exactly as you said. Could you help me about;I wrote a code if a record is already exist program refuse to insert the same record again and produce a warning However,Program does not recognize if it is the same record when i insert the same values with different case letters e.g. uppercase and lowercase.i do not want to duplicate the same record. How can i make this program case insensitive? Another thingWhen i insert a new record it does not go to end of the list.It inserts new record in the list randomly or i am guessing, in previously deleted row place. How can i make it inserting last record goes all the way to end of the list?Thanks anyway for your help so far.erok
  23. Here is the code for this program; <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "htpp://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head> <title>retrieve data from database</title> <META name="ROBOTS" content="NOINDEX, NOFOLLOW"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="author" content="Erol " /> <link rel="stylesheet" type="text/css" href="layyerel.css" /></head><body><?phperror_reporting(E_ALL);ini_set('display_errors', true);ini_set('html_errors', true);//connect to database server$con = mysql_connect("localhost", "root", "");if (!$con) { die('could not connect: ' .mysql_error()); }// select databasemysql_select_db("theboatcare", $con) or die("Could not find DB");$customers= "SELECT * FROM customers" ;$recordset= mysql_query($customers) ;echo "<h4>The BoatCare Customer List</h4>";echo "<table border='2' padding='3' cellspacing='3'>; <tr> <th>First Name</th> <th>Last Name</th> <th>Phone Number</th> </tr>";while( $row = mysql_fetch_array($recordset)) { echo "<tr>"; echo "<td>" . $row['firstname'] . "</td>" . "<td>" . $row['lastname'] . "</td>" . "<td>" . $row['phone'] . "</td>" . "<br />" ; echo "</tr>"; } echo "</table>";//close the database connectionmysql_close($con);?></body></html>
×
×
  • Create New...