Search found 124 matches

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

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: <?php $dir = 'sample'; $archi...
by nyo
Wed Nov 28, 2012 8:53 am
Forum: PHP
Topic: Zip and Download a folder
Replies: 5
Views: 1604

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. <?php // Locati...
by nyo
Wed Nov 28, 2012 8:35 am
Forum: PHP
Topic: Sorting an array by a key
Replies: 2
Views: 1168

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: 967

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: http://www.youtube.com/watch?v=6qCb0rLGT48 It shows how to create a .zip file for a folder that contains files only. I have the following code at the moment: <?php $dir =...
by nyo
Wed Nov 21, 2012 9:00 am
Forum: PHP
Topic: Zip and Download a folder
Replies: 5
Views: 1604

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. $files = array('file1.txt', 'file2.txt', 'file3.txt'); $archive = 'archive.zip'; $zip = new ZipA...
by nyo
Thu Jul 19, 2012 12:04 pm
Forum: Tutorials
Topic: Pagination doesn't work.
Replies: 3
Views: 1240

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: 1240

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: 772

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: 772

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: 27954

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

The lines 109. error_reporting 110. Default Value: E_ALL & ~E_NOTICE 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 . [PHP] ;;;;;;;;;;;;;;;;;;; ; About php.ini ; ;;;;;;;;;;;;;;;;;;;...
by nyo
Sun Oct 09, 2011 10:32 am
Forum: PHP
Topic: Fatal error: Call to undefined function mysql_connect()
Replies: 10
Views: 27954

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: 27954

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: 857

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: 857

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: 1376

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 (http://betterphp.co.uk/playlist.html?pid=6553244EA7CE6B37) and everything worked fine. There was one issue...
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: 870

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: function add_comment($name, $author, $email, $body) { if(valid_post($name) == false){ return false; } $name = mysql_real_escape_string(htmlentities($name)); $author =...
by nyo
Tue Jul 12, 2011 10:34 am
Forum: PHP
Topic: Showing IP Address of the visitor
Replies: 22
Views: 3925

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: 3925

Re: Showing IP Address of the visitor

No. But you will need to add some php code. For instance: <?php echo $post['post_body'] . 'Your IP is: ' . $_SERVER['REMOTE_ADRR']; ?> 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 database. I get the fee...
by nyo
Mon Jul 11, 2011 12:36 pm
Forum: PHP
Topic: Showing IP Address of the visitor
Replies: 22
Views: 3925

Re: Showing IP Address of the visitor

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

Re: Showing IP Address of the visitor

Could you please post the full code ? Sorry, here it is (post.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></h1> <p>Posted...
by nyo
Mon Jul 11, 2011 11:19 am
Forum: PHP
Topic: Showing IP Address of the visitor
Replies: 22
Views: 3925

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...