Jump to content

ayok

Members
  • Posts

    340
  • Joined

  • Last visited

    Never

Everything posted by ayok

  1. Hi, I have another question. I have a php page with some includes, like sessions, functions, queries, etc within the <head> tags. However, when I open my page on a browser and look at the page source, I have couple of blank lines in the <head> tags where my includes and php scripts is written there. My question is, is that OK? and how to get rid of those whitespace? thanks ayok
  2. Hi, I have a question about session_destroy(). For example I have some sessions like: <?php $_SESSION['language'] == "english"; $_SESSION['name'] == "john"; $_SESSION['cart'] == "1"; $_SESSION['password'] == "admin123"; ?> And somehow I want to change only the $_SESSION['language'] into "dutch", for example, and keep the value of the others. How can I do that? Everythime I create session_destroy(), it destroys all the sessions. Any helps? Thank you. ayok
  3. ayok

    php4 to php5

    It's solved. Well.. not completely. Still one more Notice: Undefined offset: 1: And it's always this line: <?php function roundToTwoDecimals($price){ $price = round($price, 2); $p = explode(".",$price); if(strlen($p[1]) == 0) ---------> this line $price = $p[0].".00"; else if(strlen($p[1]) == 1) $price = $p[0].".".$p[1]."0"; return str_replace(".",",",$price); } ?>
  4. ayok

    php4 to php5

    Hey thanks. But i'm still stuck. This $o is error is in a function. I'd better post the whole function here. <?php function retrieveProductModelById($id) { $sql = "SELECT * FROM Products WHERE id = '".$id."'"; $do = mysql_query($sql) or die (mysql_error()); $o = mysql_fetch_object($do); //var_dump($o); --> bool(false) $artNr = $o->artNr; $pm = new ProductModel(); if(mysql_num_rows($do)){ $pm->setId($o->id); $pm->setName($o->name); $pm->setPrice($o->price); $pm->setSale($o->sale); $pm->setSaleActive($o->saleActive); $pm->setArtNr($o->artNr); $pm->setPosition($o->position); $pm->setVisibility($o->visibility); $pm->setMenuId($o->menuId); $pm->setBTWPerc($o->BTWPerc); $pm->setDescription(stripslashes($o->description)); } $sql = "SELECT * FROM Images WHERE prodId = '".$o->artNr."'"; $do = mysql_query($sql); while($o = mysql_fetch_object($do)){ $pm->setImages($o->name); } $sql = mysql_query("SELECT * FROM ProductAliases WHERE prodId = '".$artNr."'"); while($fetch = mysql_fetch_object($sql)) { if($fetch->language == "EN") $pm->setNameEN(stripslashes($fetch->alias)); if($fetch->language == "DU") $pm->setNameDU(stripslashes($fetch->alias)); if($fetch->language == "FR") $pm->setNameFR(stripslashes($fetch->alias)); } $sql = mysql_query("SELECT * FROM ProductDescriptions WHERE prodId = '".$artNr."'") or die(mysql_error()); while($fetch = mysql_fetch_object($sql)) { if($fetch->language == "EN") $pm->setDescriptionEN(stripslashes($fetch->description)); if($fetch->language == "DU") $pm->setDescriptionDU(stripslashes($fetch->description)); if($fetch->language == "FR") $pm->setDescriptionFR(stripslashes($fetch->description)); } return $pm; } ?> More hints? Thank you in advanced.
  5. ayok

    php4 to php5

    Yes I'm trying to move scripts from php4 to php5. I have to change some $var into $_GET['var'] or $_POST['var']. Is this the cause?
  6. ayok

    php4 to php5

    It says:bool(false)
  7. ayok

    php4 to php5

    Thank you for the helps. Now I'm stuck with this message: Notice: Trying to get property of non-object in ... everytime there is these codes: <?php $sql = "SELECT * FROM Products WHERE id = '".$id."'"; $do = mysql_query($sql); $o = mysql_fetch_object($do); $artNr = $o->artNr; ?> Can anyone tell me how should I write it?
  8. Hi, I have a php webstore application that has been used for php4. Now I'm trying to migrate those scripts to php5 server, and I've got problem. The scripts doesn't work. I knew this would be happened, but i'll try to fix the errors. There are a lot of notices and i see no fatal errors, but it still doesn't work. Now I'm stuck with this:Notice: Undefined property: stdClass::$language in /var/www/vhosts/WEBSHOP/WEBSHOP_OUTPUT/Control/LanguageControl.php on line 12. There is a class on this line, which I guess the cause of these errors. <?php class LanguageControl{ function retrieveSet($lang) { $arr = array(); $lang = $language; $a = mysql_query("SELECT * FROM LanguageSet"); while($b = mysql_fetch_object($a)) { $arr[$b->key] = $b->$language; } return $arr; } } ?> I'm a newbie for oop. Any help would be appriciated. thank you, ayok
  9. No, that doesn't work with other language. I need to convert it to english. I know that with <? setlocale(LC_TIME, "nl_NL"); echo strftime("%e %B %G"); ?> I could get "7 januari 2009", but how to get other way around?
  10. Hi guys, First, Happy New Year 2009 for all of you. This forum is the best for php. Furthermore, I have question about time(). I have this standard date in Dutch "7 januari 2009". How can I got the time() string for this date? Thank you, ayok
  11. Ok thx guys. I'll find other way then..
  12. Hi guys, I'm looking for a way to add text on an animated gif with php. I have already a simple gif animation, and I want just put text on it with php. I've tried common way like: <?php header("Content-type:image/gif"); $theText = "This text is on my animated gif"; $im = @imagecreatefromgif("../gfx/banner.gif") or die("No GD lib"); $text_color = imagecolorallocate($im,255,255,255); imageTTFtext($im, 16, 0, 40, 60, $text_color, "../font/georgia.TTF", $theText); imagegif($im); imagedestroy($im); ?> I've got the text on banner.gif, however the animation is stop. No more animation. Would anybody tell me how to solve this out? thanks, ayok
  13. Thanks guys, @bobbinsbro: Thanks for explaining that one. I knew it's like if-else statement, but I had difficulty to read it. It works with neil.johnson's codes; ($_POST['publish'] == 1) ? "yes" : "no";
  14. Should I pass $id again with <input type="hidden" />? Because the first $id value is the same as the second $id value.
  15. Hi thanks, I have tried this, but I keep getting ´no´ value. Could you please explain what this means? isset($POST[publish]) ? 'yes' : 'no'; thanks, ayok
  16. Hi, I have a simple and irritating problem with updating a column (boolean) with checkbox. For example: I got this data's on mysql _______________ ID | published | ----------------- |1 | yes | |2 | no | |3 | yes | etc. For example, I want to update ID no. 2 into "yes" with a checkbox: <?php include "db.php"; $id = $_GET[íd]; $select = mysql_query("select * from table where ID = '$id'"); $data = mysql_fetch_array($select); ?> <form method="post" ><input type="checkbox" name="publish" value="<?php echo $data['publish']; ?>" <?php if($data['publish'] == 'yes'){ echo "checked='yes'"; } ?> /><input type="submit" ></form> When it's submitted it sends the variables "publish". So to change no. 2 into yes, i simply check the box. <?php $publish = $POST[publish]; $query = mysql_query("UPDATE table SET publish = '$publish' WHERE ID = '$id'"); ?> However it doesn't work. Not as simple as to insert a new record. Would anybody help me? Thanks, ayok
  17. Anyone? I need to remove that <img src="img.jpg" align="left" width="100" etc />.
  18. Sorry Alex, I just thought it was a stupid question.. But it's right that I was looking for strtotime(). greets, ayok
  19. Nevermind, I found it! Thanks, ayok
  20. Hi, I've been trying to find the numbers of time() from a date. For example: if we echo a time(), then we'll get numbers like 1203432432 which show the time today from 1 jan 1970. But how can I find those numbers in other way around from an existing date like 24 October 2008? Is it possible? thanks, ayok
  21. Thanks valtido, I've tried, but got the same result as preg_replace('#(<[/]?img.*>)#U',$cutNews); The other text is gone. ayok
  22. Hi r-it, I've tried strip_tags, but it only removes the html tag and leaves the rest like src="blabla.jpg" align="left" etc which looks messy. ayok
  23. Hi, I've been creating a news site which shows the news list on the front page with some parts of the news content. So I cut the news and people can click on "complete news" button to see the detail. My problem is when there are images inside the news which are also shown in the news list. What I have to do is to remove the img tag from the list so the image will not be shown. Recently I used str_replace to remove the "<img src=", "align=", etc. However I cannot remove the whole text inside <img>. My question is how can I remove those? I have tried this code as well <?php $cutNews = preg_replace('#(<[/]?img.*>)#U',$cutNews); ?> , but it doesn't work. It removes the whole news content. Anybody has a solution for me?? Thank you, ayok
  24. Thank you guys.. I was really pissed off, and almost cut off the business. But he actually likes my works so far from the result. I don't understand why he would like to see it. My mistake is that he hasn't paid yet... I even charged him with a low rate. I didn't realize that it was the reason why I was so upset. Thanks. Next time I'll ask the payment first. ayok
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.