Jump to content

terryds

Members
  • Posts

    174
  • Joined

  • Last visited

Everything posted by terryds

  1. I often see comments like /*** The database class to store PDO objects** @var object*/ What does @var mean? And, i often see @param, @return too... What do they mean? I've ever seen strange comment like this one below. Can you tell me what it mean? /*** $Id$*/
  2. i can't set my postdate column to DEFAULT CURDATE();Can you tell me how to do that?
  3. terryds

    NULL or '' ?

    Hey, i want to make a description of role column in my table.... But, i don't know what's better between DEFAULT NULL or DEFAULT '' ? Any suggestion?
  4. terryds

    Array

    See this code first <?phpinclude_once $_SERVER['DOCUMENT_ROOT'] . '/includes/magicquotes.inc.php'; if (isset($_POST['action']) and $_POST['action'] == 'upload'){ // Bail out if the file isn't really an upload if (!is_uploaded_file($_FILES['upload']['tmp_name'])) { $error = 'There was no file uploaded!'; include $_SERVER['DOCUMENT_ROOT'] . '/includes/error.html.php'; exit(); } $uploadfile = $_FILES['upload']['tmp_name']; $uploadname = $_FILES['upload']['name']; $uploadtype = $_FILES['upload']['type']; $uploaddesc = $_POST['desc']; $uploaddata = file_get_contents($uploadfile); include 'db.inc.php'; try { $sql = 'INSERT INTO filestore SET filename = :filename, mimetype = :mimetype, description = :description, filedata = :filedata'; $s = $pdo->prepare($sql); $s->bindValue(':filename', $uploadname); $s->bindValue(':mimetype', $uploadtype); $s->bindValue(':description', $uploaddesc); $s->bindValue(':filedata', $uploaddata); $s->execute(); } catch (PDOException $e) { $error = 'Database error storing file!'; include $_SERVER['DOCUMENT_ROOT'] . '/includes/error.html.php'; exit(); } header('Location: .'); exit();} if (isset($_GET['action']) and ($_GET['action'] == 'view' or $_GET['action'] == 'download') and isset($_GET['id'])){ include 'db.inc.php'; try { $sql = 'SELECT filename, mimetype, filedata FROM filestore WHERE id = :id'; $s = $pdo->prepare($sql); $s->bindValue(':id', $_GET['id']); $s->execute(); } catch (PDOException $e) { $error = 'Database error fetching requested file.'; include $_SERVER['DOCUMENT_ROOT'] . '/includes/error.html.php'; exit(); } $file = $s->fetch(); if (!$file) { $error = 'File with specified ID not found in the database!'; include $_SERVER['DOCUMENT_ROOT'] . '/includes/error.html.php'; exit(); } $filename = $file['filename']; $mimetype = $file['mimetype']; $filedata = $file['filedata']; $disposition = 'inline'; if ($_GET['action'] == 'download') { $mimetype = 'application/octet-stream'; $disposition = 'attachment'; } // Content-type must come before Content-disposition header('Content-length: ' . strlen($filedata)); header("Content-type: $mimetype"); header("Content-disposition: $disposition; filename=$filename"); echo $filedata; exit();} if (isset($_POST['action']) and $_POST['action'] == 'delete' and isset($_POST['id'])){ include 'db.inc.php'; try { $sql = 'DELETE FROM filestore WHERE id = :id'; $s = $pdo->prepare($sql); $s->bindValue(':id', $_POST['id']); $s->execute(); } catch (PDOException $e) { $error = 'Database error deleting requested file.'; include $_SERVER['DOCUMENT_ROOT'] . '/includes/error.html.php'; exit(); } header('Location: .'); exit();} include 'db.inc.php'; try{ $result = $pdo->query( 'SELECT id, filename, mimetype, description FROM filestore');}catch (PDOException $e){ $error = 'Database error fetching stored files.'; include $_SERVER['DOCUMENT_ROOT'] . '/includes/error.html.php'; exit();} $files = array();foreach ($result as $row){ $files[] = array( 'id' => $row['id'], 'filename' => $row['filename'], 'mimetype' => $row['mimetype'], 'description' => $row['description']);} include 'files.html.php'; When i remove the $files = array(); , i see there are no changes... Can you tell me what $files=array(); does ?
  5. terryds

    Storing avatars

    Hi Can you tell me which one of storing avatars to mysql using BLOB or storing avatars to ftp is better? I'm a bit confused about BLOB in SQL... When to use it instead of using ftp?
  6. terryds

    PHP timezone

    What if i want it to just specify the time difference from GMT ? How to do that? Or, should i just make the time + x hours manually using plus operator ( x is the difference time) ?
  7. terryds

    PHP timezone

    @niche : In date_default_timezone_set, i have to type the location. But, what i want is to type the GMT+7 not the location, because not every location is supported by the timezone identifiers.. Can you tell me another way to change the timezone to GMT + x without using date_default_timezone_set or changing the php.ini ? I want my bulletin board users can see the time based on their location....
  8. terryds

    PHP timezone

    Hey, can you tell me how to change the php default timezone to GMT+7 ?
  9. What do you think of my author table ? CREATE TABLE `authors` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(30) NOT NULL DEFAULT '', `gender` enum('Male','Female') NOT NULL, `email` varchar(30) NOT NULL DEFAULT '', `country` varchar(30) NOT NULL DEFAULT '', `url` varchar(20) NOT NULL DEFAULT '', `birthday` varchar(10) NOT NULL DEFAULT '', `motto` varchar(60) NOT NULL DEFAULT '', `password` char(40) NOT NULL DEFAULT '', PRIMARY KEY (`id`), KEY `birthday_idx` (`birthday`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 Is it right tuned ? I make it as my blog cms's author table...
  10. Take a look at http://www.mysqltutorial.org/mysql-transaction.aspx At the last code script example, there is @orderNumber and ' := ' ... I don't understand what they are... Can you explain me about them ?
  11. This is what it says #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF NOT EXISTS(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHA' at line 1
  12. This is my code CREATE TABLE author IF NOT EXISTS(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(30) NOT NULL ); CREATE TABLE post IF NOT EXISTS (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, text TEXT, date DATE, authorid INT, FOREIGN KEY(authorid) REFERENCES author (id) ON DELETE CASCADE ON UPDATE CASCADE ); INSERT INTO author ('name') VALUES ('Andi'), ('Budi'), ('Amir');INSERT INTO post ('text','date','authorid') VALUES('aaaa', CURDATE(), '1'),('bbbb', CURDATE(), '2'),('ccc', CURDATE(), '3'); Can you please help me fix the error ?
  13. You should change the last section of your code to this one if($err == false){$sql="INSERT INTO orders(cufrist_name,culast_name,phone,mobile,address,email,product_cod,product_namee,product_bod,gheymatevahed,etebaregheymat,mizanesefaresh,tedadehaml,payment,tarikhsefaresh,color) VALUES ('".$cufrist_name."','".$culast_name."','".$phone. "','".$mobile."','".$address."', '".$email."','".$product_cod."','".$product_name."','".$product_bod."','".$gheymatevahed."','".$etebaregheymat."','".$mizanesefaresh ."',,'".$tedadehaml."','".$payment."','".$tarikhsefaresh."','".$color."')"; $result = mysql_query($sql);if (!$result) { die('Invalid query: ' . mysql_error());}}}?> </div><!-- rtl --></div><!-- contentpage rtl --></body></html><?phpob_end_flush();?> Hope that will work
  14. terryds

    TEXT vs VARCHAR

    I'm confused which one of TEXT and VARCHAR is better to use as a data type to store a blog post, title blog (which have a large amount of text)... Can you give me any suggestion?
  15. Hi... Can you tell me how to make PHP not display any errors, warnings, etc... ? I want to change the PHP display error page with my html template.... Please help !
  16. terryds

    PHP-XML Error

    Look at my code below : <?php $xmlData =<<< END<?xml version="1.0"?><datas> <cars> <car> <manufacture country="japan">Honda</manufacture> <type>Honda Jazz</type> </car> <car> <manufacture country="korea">Nissan</manufacture> <type>Nissan Livina</type> </car> </cars></datas>END; $xml = simplexml_load_file($xmlData) or die("Error: Cannot create object"); foreach($xml->children() as $cars){foreach($cars->children() as $car => $data){ echo $data->manufacture['country']; echo "<br />";}} ?> When executed, it gives me an error, can you help me fix that?
  17. terryds

    Blog page .php

    Just give it a CSS float .attachment-thumbnail.wp-post-image {float: left;} This is the additional style for you .read-more {display: inline-block;} .post-data {display: inline-block;} Hope that'll be helpful !
  18. I'm wondering about how easy installer works... The installer will ask you to type the database name, username, password, and the host... Then, after i input them all, it will store the data (my dbname, username, pw, and host)... I'm guessing now the way it store the data : Maybe, a. It uses OOP set-get function. b. Or, it uses the database server to store the dbname, username,pw, host. c. Or, it edit a php file containing the configuration for the CMS (But, i don't know how to do this) So... Can you tell me the right way to make an easy-install helper ? And, if it's possible, Can you tell me how to do the point C ? Sorry for my bad English
  19. Regular console what ? Can you tell me where that is ? I use XAMPP (the path is C:xampp)... And, my vld-0.11-2.tgz is downloaded from http://pecl.php.net/get/vld .. I place it in drive C:\xampp\php\vld-0.11.2.tgz and i've extracted it too so there is vld-0.11.2 folder ... Can you tell me step by step how to install that (i'm very new in command line and don't know what console i should open) ? Please explain till it's very crystal clear... Do you mean the cmd.exe ? What should i write there ? I try cd xampp.php, then phpize, but it gives me an error.. And, what do the symbol $ and # mean ?PS : My OS is Windows 7
  20. I've installed PuTTY.. Now, what ? What will the setting be?I've changedthe translation to UTF-8,selection to xterm,data-->Auto-login username to root,Preferred SSH protocol version to 2 only,Host Name = localhost, and the port = 80,Connection type = SSH,then i click 'open'An error message appears ('The server unexpectedly close the connection')..Can you help me ?
  21. terryds

    What is var $this?

    See my code.. <?phpfunction bark() { print "{$this->Name} says Woof!\n";} bark(); The error appears : Fatal error: Using $this when not in object context in C:\xampp\htdocs\terrytest\scratches\$this.php on line 3I get the code from http://www.tuxradar.com/practicalphp/6/5/0 Can you tell me how to fix it? Or give me another simple example of using $this ? I still don't understand about it
  22. terryds

    What is var $this?

    I often found variable $this, but until now, i still don't understand about that....I still see that in functions and OOP.. Can you explain about that to me?
  23. terryds

    What is raw ?

    SOLVED!!! I found this myself <?php// Functions function raw(){if (preg_match('/^[0-9]+$/', $_POST['post'])) {$a = (int) $_POST['post'];var_dump($a);} else if (preg_match('/^[0-9]+\.[0-9]+$/', $_POST['post'])) {$a = (float) $_POST['post'];var_dump($a);} else {$a = (string) $_POST['post'];var_dump($a);}} ?><!DOCTYPE html><html><head><meta charset="utf-8"><title>$_POST check type</title></head><body><form action="" method="post"><label for="post">Check the type</label><input type="text" id="post" name="post"></form><?php if (isset($_POST['post'])): ?><p>The type is <?php raw(); ?></p><?php endif; ?></body></html>
  24. terryds

    What is raw ?

    Oh.. I found that (int) $var; can convert that.... But, when i type a string "aaa" in the input, the result's always be 0... How to make the result become a string "aaa" too ? And, When i type a float number, how to make the result become a float too ? Can you tell me how to do that ?
  25. terryds

    What is raw ?

    Would you please tell me how to convert it.. When i input int(1) in the form with the post method, the result will always be string(1) "1"....Can you tell me how to convert it so the result won't be a string but int(1) ??
×
×
  • Create New...