Follow us on Twitter!
Things are more like they are now than they have ever been before. - Dwight D. Eisenhower
Wednesday, April 16, 2014
Navigation
Home
HellBoundHackers Main:
HellBoundHackers Find:
HellBoundHackers Information:
Learn
Communicate
Submit
Shop
Challenges
HellBoundHackers Exploit:
HellBoundHackers Programming:
HellBoundHackers Think:
HellBoundHackers Track:
HellBoundHackers Patch:
HellBoundHackers Other:
HellBoundHackers Need Help?
Other
Members Online
Total Online: 22
Guests Online: 16
Members Online: 6

Registered Members: 82810
Newest Member: TheDuke777
Latest Articles
View Thread

HellBound Hackers | Computer General | Programming

Page 3 of 3 < 1 2 3
Author

RE: PHP help

fuser
Member



Posts: 960
Location: in front of a computer (duh)
Joined: 05.04.07
Rank:
Mad User
Posted on 18-02-10 17:47
well, of course I'm using a database as well.

btw, I have an issue, nothing too big but it's annoying nonetheless.

Following the tutorial showed at: http://www.zimmer. . .torial.php I now have a working comment box, but there are a few problems that still puzzles me. The problem is that, after I implement the shoutbox at any artist's profile page, it will show an error like this:

Notice: Undefined variable: PHP_SELF in C:\wamp\www\mplayer\artists\c14.php on line 79

but after I post a comment, it shows that my comment is accepted, and then it shows this error on the redirect page:


Notice: Undefined index: tuturl in C:\wamp\www\mplayer\artists\submitcomment.php on line 16

Notice: Undefined index: tutid2 in C:\wamp\www\mplayer\artists\submitcomment.php on line 17

Notice: Undefined index: name in C:\wamp\www\mplayer\artists\submitcomment.php on line 18

Notice: Undefined index: url in C:\wamp\www\mplayer\artists\submitcomment.php on line 19

Notice: Undefined index: email in C:\wamp\www\mplayer\artists\submitcomment.php on line 20

Notice: Undefined index: message in C:\wamp\www\mplayer\artists\submitcomment.php on line 21
Submission Successful
Your comment has been submitted. You will now be redirected back to the last page you visited. Thanks!

So, I usually have to go a few pages back, and then have re-visit the page I posted a comment earlier to see if it is included (usually it is).

The problem is that even though it works, the error messages still makes me think that I must've done something wrong, although I'm not sure what.







img.userbarz.com/51/10006.png
img.userbarz.com/146/29144.gif
img.userbarz.com/99/19602.jpg
img.userbarz.com/4/600.png
img.userbarz.com/45/8814.gif
img360.imageshack.us/img360/9231/bfbarlr0.jpg
[url=http://userbarz.com/][img]ht
catinthecpu@hotmail.com
Author

RE: PHP help


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 18-02-10 22:45
$PHP_SELF only works when you have register_globals on in your php.ini. Since it's a security risk, don't enable it. Just change $PHP_SELF to $_SERVER['PHP_SELF'].

For lines 16-21 of the submit php script, it looks like it's not finding those indexes in the $_POST superglobal. Right above line 16, put this:

var_dump($_POST);

... and post what it comes back with here. It will be at the top of the page.


Author

RE: PHP help

fuser
Member



Posts: 960
Location: in front of a computer (duh)
Joined: 05.04.07
Rank:
Mad User
Posted on 19-02-10 14:31
define wrote:
$PHP_SELF only works when you have register_globals on in your php.ini. Since it's a security risk, don't enable it. Just change $PHP_SELF to $_SERVER['PHP_SELF'].

For lines 16-21 of the submit php script, it looks like it's not finding those indexes in the $_POST superglobal. Right above line 16, put this:

var_dump($_POST);

... and post what it comes back with here. It will be at the top of the page.


well, I implemented your suggestions, but what it came out is:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in E:\xampplite\htdocs\mplayer\artists\c14.php on line 71

to be fair, I tried to change $_SERVER['PHP_SELF']. with and without the notation point.


I also have a slight problem that I can't figure out. My site has an upload and download feature, and while the upload feature works, I can't seem to download any files.

img693.imageshack.us/img693/5799/error3p.th.jpg

results in:

img535.imageshack.us/img535/2333/error2a.th.jpg

Here's the upload and download code:

Code

<?php
ini_set( 'upload_max_filesize', '100M' );
$uploadDir = 'C:\wamp\www\mplayer\music\music';
$filetype = 'audio/mpeg';

if(isset($_POST['upload']))
{
$fileName = $_FILES['data']['name'];
$tmpName = $_FILES['data']['tmp_name'];
$fileSize = $_FILES['data']['size'];
$fileType = $_FILES['data']['type'];
$filePath = $uploadDir . $fileName;

$result = move_uploaded_file($tmpName, $filePath);
if (!$result) {
echo "Error uploading file";
exit;
}

include 'conn1.php';

if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
$filePath = addslashes($filePath);
}

$query = "INSERT INTO upload (name, size, type, path ) ".
"VALUES ('$fileName', '$fileSize', '$fileType', '$filePath')";

mysql_query($query) or die('Error, query failed : ' . mysql_error());

echo "<br>Files uploaded<br>";

}
?>





(upload)

Code

<?php

$server="localhost";
$database="uploads";
$admin="fuser";
$password="projectpass";

$link=mysql_connect($server,$admin,$password);
mysql_select_db($database,$link);
$query = "SELECT id, name FROM upload";
$result = mysql_query($query) or die('Error, query failed');

if(mysql_num_rows($result) == 0)
{
echo "Database is empty <br>";
}

else
{
while(list($id, $name) = mysql_fetch_array($result))
{

?>

<a href="download.php?id=<?php echo urlencode($id);?>"><?php echo urlencode($name);?></a> <br>

<?php
}
}
mysql_close($link);

?>

<?php
if(isset($_GET['id']))
{
$server="localhost";
$database="uploads";
$admin="fuser";
$password="projectpass";

$link=mysql_connect($server,$admin,$password);

mysql_select_db($database,$link);

$id=$_GET['id'];

$query = "SELECT name, type, size, content " .

        "FROM upload WHERE id = '$id'";

$result = mysql_query($query) or die('Error, query failed');

list($name, $type, $size, $content)=mysql_fetch_array($result);

header("Content-length: $size");
header("Content-type: $type");
header("Content-Disposition: attachment; filename=$name");

echo $content;
mysql_close($link);
exit;
}
?>





[download]


img.userbarz.com/51/10006.png
img.userbarz.com/146/29144.gif
img.userbarz.com/99/19602.jpg
img.userbarz.com/4/600.png
img.userbarz.com/45/8814.gif
img360.imageshack.us/img360/9231/bfbarlr0.jpg
[url=http://userbarz.com/][img]ht
catinthecpu@hotmail.com
Author

RE: PHP help


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 20-02-10 00:55
fuser wrote:
well, I implemented your suggestions, but what it came out is:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in E:\xampplite\htdocs\mplayer\artists\c14.php on line 71

to be fair, I tried to change $_SERVER['PHP_SELF']. with and without the notation point.

Unless you removed about 8 lines of code in the process, that error is occurring on a different line. Also, after referencing the comment form link you posted in one of your previous posts, I found that they were doing this:

submitComments("1","$PHP_SELF");

... which is stupid. Quotes are not needed around either of those, and that may be where you're encountering an issue... especially if you did this:

submitComments("1","$_SERVER['PHP_SELF']");

It should be this:

submitComments(1,$_SERVER['PHP_SELF']);

For reference, if you want to have an array value in a string, you'd have to surround it with {}. For example:

$str = "I like to code {$language[0]} on {$day['third']}";

fuser wrote:
I also have a slight problem that I can't figure out. My site has an upload and download feature, and while the upload feature works, I can't seem to download any files.
Code

<?php
if(isset($_GET['id']))
{
...

$query = "SELECT name, type, size, content " .

        "FROM upload WHERE id = '$id'";

$result = mysql_query($query) or die(mysql_error());

...
}
?>




(download)

Start by making the change in bold above; that will give you a more relevant error message. Also, try surrounding the field names in your query with ` characters, since "type" may or may not be a MySQL keyword. Like this:

"SELECT `name`, `type`, `size`, `content` FROM upload WHERE id = '$id'"

Also, if your "id" field in the table is not a string, there's no need to put ' around $id in the query.


Author

RE: PHP help

fuser
Member



Posts: 960
Location: in front of a computer (duh)
Joined: 05.04.07
Rank:
Mad User
Posted on 20-02-10 09:06
I implemented the changes you suggested, but I got a few problems I

will show through screenshots:

post comments:

img52.imagesha<br />
<br />
ck.us/img52/1596/wtfdg.th.jpg

download:

after I try to download any of the files listed, I get this:

img641.image<br />
<br />
shack.us/img641/6650/dlprob.th.jpg

img62.images<br />
<br />
hack.us/img62/9082/dlprob2.th.jpg

If I save the file to disc, it doesn't show the filetype of the file

downloaded.

And if I chose the open file option, it opens a page similar to the

download page, and then I get this:

img62.images<br />
<br />
hack.us/img62/972/dlprob3.th.jpg


img.userbarz.com/51/10006.png
img.userbarz.com/146/29144.gif
img.userbarz.com/99/19602.jpg
img.userbarz.com/4/600.png
img.userbarz.com/45/8814.gif
img360.imageshack.us/img360/9231/bfbarlr0.jpg
[url=http://userbarz.com/][img]ht

Edited by fuser on 20-02-10 10:13
catinthecpu@hotmail.com
Author

RE: PHP help

fuser
Member



Posts: 960
Location: in front of a computer (duh)
Joined: 05.04.07
Rank:
Mad User
Posted on 22-02-10 09:34
well, I also managed to fix the problem in the last post, and this is the last request for help, I promise (there's three days left, and everything's done except this one)

I just realised that I had to limit the upload feature of my site, so that only registered users can upload content on my site. The upload and user tables are in the same database, and when using the query

Code
select * from users

right join upload on users.id

where users.id = upload.id




it shows the username of the that had uploaded the content. The problem now is that even unregistered users can upload files to this site, so is there any suggestions on restricting this from happening?


img.userbarz.com/51/10006.png
img.userbarz.com/146/29144.gif
img.userbarz.com/99/19602.jpg
img.userbarz.com/4/600.png
img.userbarz.com/45/8814.gif
img360.imageshack.us/img360/9231/bfbarlr0.jpg
[url=http://userbarz.com/][img]ht
catinthecpu@hotmail.com
Author

RE: PHP help

fuser
Member



Posts: 960
Location: in front of a computer (duh)
Joined: 05.04.07
Rank:
Mad User
Posted on 22-02-10 10:45
yeah, darksun helped me walkthrough it. thanks for all those that've replied for this thread. And wish me luck, I need it since if I fail, I might have to repeat another semester.


img.userbarz.com/51/10006.png
img.userbarz.com/146/29144.gif
img.userbarz.com/99/19602.jpg
img.userbarz.com/4/600.png
img.userbarz.com/45/8814.gif
img360.imageshack.us/img360/9231/bfbarlr0.jpg
[url=http://userbarz.com/][img]ht
catinthecpu@hotmail.com
Author

RE: PHP help


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 23-02-10 01:04
fuser wrote:
yeah, darksun helped me walkthrough it. thanks for all those that've replied for this thread. And wish me luck, I need it since if I fail, I might have to repeat another semester.

Glad you got help. What's darksun up to these days?

... and, no offense, but if any of this was information taught in the current semester, you should consider relearning it, regardless.


Author

RE: PHP help

fuser
Member



Posts: 960
Location: in front of a computer (duh)
Joined: 05.04.07
Rank:
Mad User
Posted on 23-02-10 04:08
nah, the whole web programming class wasn't taught this semester, it was taught way earlier when I started studying in college. There's not much technical classes this semester, mainly business. And if I recall correctly, I got a B for my web programming class.

This is a final year project, basically a project I have to work on so that I can graduate. You know how terrible it can get if I fail it.


img.userbarz.com/51/10006.png
img.userbarz.com/146/29144.gif
img.userbarz.com/99/19602.jpg
img.userbarz.com/4/600.png
img.userbarz.com/45/8814.gif
img360.imageshack.us/img360/9231/bfbarlr0.jpg
[url=http://userbarz.com/][img]ht
catinthecpu@hotmail.com
Author

RE: PHP help

fuser
Member



Posts: 960
Location: in front of a computer (duh)
Joined: 05.04.07
Rank:
Mad User
Posted on 11-03-10 09:10
if you're gonna scold me for necroing my own thread, go choke on your own vomit and I hope that your family gets eaten.

Well, I basically flunked it. I have to re-do the entire thing from scratch cause they don't like the damned thing. Why do I even bother telling you people?

You're just gonna make fun of me anyway.



img.userbarz.com/51/10006.png
img.userbarz.com/146/29144.gif
img.userbarz.com/99/19602.jpg
img.userbarz.com/4/600.png
img.userbarz.com/45/8814.gif
img360.imageshack.us/img360/9231/bfbarlr0.jpg
[url=http://userbarz.com/][img]ht
catinthecpu@hotmail.com
Author

RE: PHP help


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 12-03-10 01:22
fuser wrote:
Well, I basically flunked it. I have to re-do the entire thing from scratch cause they don't like the damned thing. Why do I even bother telling you people?

You're just gonna make fun of me anyway.

Your misfortune isn't funny to me, but your attitude about the whole thing is.

From the start of this thread to the last post before the flunk, you spent a month, possibly off and on, mostly posting reams of code (sometimes yours, sometimes not) and asking us to troubleshoot it. In the course of that month, you should have spent...

2-3 weeks: Learning PHP through simple examples online to demonstrate concepts and asking general PHP questions here if needed

1-2 weeks: Doing the project start to finish.

The reason why you failed is because you failed to learn enough to actually do what was needed to pass. So, now you have a chance to do it right this time.

Learn PHP. If you have questions, ask. I always answer PHP-related PMs, and I'm sure others do, too. Also, there are loads of threads on PHP topics in the web whatever category of the forum. There are LOADS of threads at PHPFreaks, also, and there are obviously more users there that are experienced with PHP than there are here.

You can learn... if you choose to.


Page 3 of 3 < 1 2 3