Search found 124 matches

by nyo
Thu Nov 29, 2012 8:18 am
Forum: PHP
Topic: Zip and Download a folder
Replies: 5
Views: 1062

Re: Zip and Download a folder

That is probably caused by the ziping stuff causing a php error which makes the file invalid. comment out everything after $zip->close() and reload the page. That should show you the error instead of including it at the start of the file. I further modified the script: [syntax=php]<?php $dir = 'sam...
by nyo
Wed Nov 28, 2012 8:53 am
Forum: PHP
Topic: Zip and Download a folder
Replies: 5
Views: 1062

Re: Zip and Download a folder

You could use scandir() or glob() to list all of the files instead of using a static list. Ok, I modified my script a little more as follows. It creates a .zip archive but it gives an error when you try to open it. Also, its size is 470b, whereas the files in it should be about 8kb. [syntax=php]<?p...
by nyo
Wed Nov 28, 2012 8:35 am
Forum: PHP
Topic: Sorting an array by a key
Replies: 2
Views: 661

Re: Sorting an array by a key

If you are reading the array of entries from a database, you can use "ORDER BY" (MySQL command) to sort entries based on date. Other than that, you can give ksort() function a try. Can't give specific answer without seeing your code.
by nyo
Thu Nov 22, 2012 9:34 am
Forum: Tutorials
Topic: PHP Tutorial: Creating .zip Files
Replies: 1
Views: 585

PHP Tutorial: Creating .zip Files

I am trying to create and download a .zip archive from a folder that contains files and folders in it. I watched the tutorial on: m It shows how to create a .zip file for a folder that contains files only. I have the following code at the moment: [syntax=php]<?php $dir = 'sample'; $archive = 'sample...
by nyo
Wed Nov 21, 2012 9:00 am
Forum: PHP
Topic: Zip and Download a folder
Replies: 5
Views: 1062

Zip and Download a folder

Hi, I am working on a script to create a .zip archive from a folder and download it. So far, I have the following, which creates and downloads a .zip archive of a pre-defined number of files in an array. [syntax=php]$files = array('file1.txt', 'file2.txt', 'file3.txt'); $archive = 'archive.zip'; $zi...
by nyo
Thu Jul 19, 2012 12:04 pm
Forum: Tutorials
Topic: Pagination doesn't work.
Replies: 3
Views: 823

Re: Pagination doesn't work.

Thank you very much Jacek, I guess I missed that question mark. Removing it fixed the issue. Now it works as it should.
by nyo
Mon Jul 16, 2012 7:49 am
Forum: Tutorials
Topic: Pagination doesn't work.
Replies: 3
Views: 823

Pagination doesn't work.

Hi, I am working on a pagination system. What I have is a slightly modified version of the pagination tutorial . It displays 10 listings on the first page as it should but when I click on page links (2nd page, etc.)on the pagination, nothing happens. It doesn't give any error and I can't see what I ...
by nyo
Wed Nov 30, 2011 4:07 pm
Forum: PHP
Topic: Backslash is auto-inserted before double quotes
Replies: 2
Views: 580

Re: Backslash is auto-inserted before double quotes

SOLVED

The problem was solved when I disabled magic quotes in php.ini file.

magic_quotes_gpc = Off
by nyo
Wed Nov 30, 2011 8:48 am
Forum: PHP
Topic: Backslash is auto-inserted before double quotes
Replies: 2
Views: 580

Backslash is auto-inserted before double quotes

Hi, I have the following code for my simple write.php page where I compile posts for my blog. The problem is, when you click on buttons that insert code with a double quotes (e.g. IMG, A Post), it adds backslashes automatically. You will see what I mean when you try it. Is there a solution for that?...
by nyo
Sun Oct 09, 2011 12:13 pm
Forum: PHP
Topic: Fatal error: Call to undefined function mysql_connect()
Replies: 10
Views: 25428

Re: Fatal error: Call to undefined function mysql_connect()

The lines [syntax=text]109. error_reporting 110. Default Value: E_ALL & ~E_NOTICE[/syntax] should be commented out I think. Can you post your full php.ini ? But if you comment that out, you will not see errors, not? The link to my php.ini file is here . [syntax=text][PHP] ;;;;;;;;;;;;;;;;;;; ; ...
by nyo
Sun Oct 09, 2011 10:32 am
Forum: PHP
Topic: Fatal error: Call to undefined function mysql_connect()
Replies: 10
Views: 25428

Re: Fatal error: Call to undefined function mysql_connect()

I tried running cmd.exe with "php -m" and it gave a PHP Error:

"syntax error, unexpected '&' in C:\PHP\php.ini on line 110"

which is about the line:

109. error_reporting
110. Default Value: E_ALL & ~E_NOTICE
by nyo
Sun Oct 09, 2011 9:37 am
Forum: PHP
Topic: Fatal error: Call to undefined function mysql_connect()
Replies: 10
Views: 25428

Fatal error: Call to undefined function mysql_connect()

Hi, I have been trying to solve this for two days but nothing seems to work. I installed Apache, PHP and MySQL on my computer. Apache works fine, PHP works fine, MySQL works fine but when I try to connect to MySQL through PHP, I get this error. Here is all the details about my system: Windows 7 (Hom...
by nyo
Sun Oct 09, 2011 4:55 am
Forum: PHP
Topic: PHP Web Server Setup doesn't see Apache
Replies: 2
Views: 645

Re: PHP Web Server Setup doesn't see Apache

No there is not. That screenshot is to show there is no Apache option.

EDIT: Solved. I was trying the non thread safe version. Thread safe version of PHP worked fine.
by nyo
Sat Oct 08, 2011 7:37 pm
Forum: PHP
Topic: PHP Web Server Setup doesn't see Apache
Replies: 2
Views: 645

PHP Web Server Setup doesn't see Apache

Hi, I formatted my computer recently (Windows 7 Home Premium 32bit) and trying to install a local server from scratch. I installed Apache (from ApacheLounge.com) and it seems to work, but when I try to install PHP, the installation wizard doesn't see Apache. What could be wrong? http://www.nailyener...
by nyo
Fri Aug 12, 2011 9:29 am
Forum: Tutorials
Topic: Pagination Tutorial - Page Existence Check
Replies: 0
Views: 909

Pagination Tutorial - Page Existence Check

I was going to ask this as a question but I tried a bit more and I was able to solve it myself. I am posting this because others might need this as well. I went through the Pagination tutorial (m) and everything worked fine. There was one issue though. When you insert an integer other than (1,2,3) i...
by nyo
Fri Jul 29, 2011 8:32 am
Forum: Tutorials
Topic: Help needed with the "add_comment" function in the blog tut.
Replies: 1
Views: 587

Help needed with the "add_comment" function in the blog tut.

Hi, I am working on the add_comment function and I have a slight issue I don't know how to solve. Here is the function I want to use: [syntax=php]function add_comment($name, $author, $email, $body) { if(valid_post($name) == false){ return false; } $name = mysql_real_escape_string(htmlentities($name)...
by nyo
Tue Jul 12, 2011 10:34 am
Forum: PHP
Topic: Showing IP Address of the visitor
Replies: 22
Views: 2863

Re: Showing IP Address of the visitor

Ok, I found the answer on another forum. "Use iframe".

Thank you all for your ideas.
by nyo
Mon Jul 11, 2011 1:27 pm
Forum: PHP
Topic: Showing IP Address of the visitor
Replies: 22
Views: 2863

Re: Showing IP Address of the visitor

No. But you will need to add some php code. For instance: [syntax=php]<?php echo $post['post_body'] . 'Your IP is: ' . $_SERVER['REMOTE_ADRR']; ?>[/syntax] Certainly I need to add some php code, but up to now I couldn't find an answer to how to add that php code into a post that is stored in the da...
by nyo
Mon Jul 11, 2011 12:36 pm
Forum: PHP
Topic: Showing IP Address of the visitor
Replies: 22
Views: 2863

Re: Showing IP Address of the visitor

More or less what has already been said then... [syntax=php] <?php // some of the file echo 'Your IP is '.$_SERVER['REMOTE_ADDR']; // rest of file ?> [/syntax] Whatismyip.com most certainly uses this: [syntax=php]echo $_SERVER['REMOTE_ADDR];[/syntax] Believe it or not, this is what they use. Here's...
by nyo
Mon Jul 11, 2011 12:06 pm
Forum: PHP
Topic: Showing IP Address of the visitor
Replies: 22
Views: 2863

Re: Showing IP Address of the visitor

Could you please post the full code ? Sorry, here it is (post.php): [syntax=php]<?php include 'inc/header.php'; $post = get_post($_GET['p']); ?> <div id="main"> <div id="content"> <h1><a href="<?php echo $post['post_name']; ?>"><?php echo $post['post_title']; ?></a></h...
by nyo
Mon Jul 11, 2011 11:19 am
Forum: PHP
Topic: Showing IP Address of the visitor
Replies: 22
Views: 2863

Re: Showing IP Address of the visitor

Can you post the full code ? Also, if you have to resort to using eval() then it's probably time to rethink the design of your site. Honestly, I don't know if I have to resort to eval() or not. I am just trying to learn how to show the user IP. I have modified the design of the site a couple of tim...