Members Online
Total Online: 56 Web Spiders: 14
Guests Online: 48
Members Online: 8
Registered Members: 50572 Newest Member: thefatlord
|
View Thread
| Author |
RE: PHP help |
MoshBat
I am awesome

Posts: 4364
Location: Somewhere that I hope you think is witty.
Joined: 13.08.06 Rank: Newbie Warn Level: 100
|
|
Are you running Linux?
   |
|
| Author |
RE: PHP help |
michelfalke
Member
Posts: 9
Location: Longitude l = new Longitude();
Joined: 08.01.10 Rank: HBH Guru |
|
/**
* sendConfirmation - Sends a confirmation to users
* who click a "Send confirmation" button. This
* only needs to be used if the EMAIL_WELCOME constant
* is changed to true and the user's 'valid' field is 0
*/
put ur user's valid field in db on 1 or put the constant on false and u can login to ur own site again =)
for testing purposes i would say hire a cheap ass server or google for free webservers with smtp
School sux hbh teaches me way more =)
Edited by michelfalke on 17-02-10 11:14 |
|
| Author |
RE: PHP help |
MoshBat
I am awesome

Posts: 4364
Location: Somewhere that I hope you think is witty.
Joined: 13.08.06 Rank: Newbie Warn Level: 100
|
|
|
michelfalke wrote:
/**
* sendConfirmation - Sends a confirmation to users
* who click a "Send confirmation" button. This
* only needs to be used if the EMAIL_WELCOME constant
* is changed to true and the user's 'valid' field is 0
*/
put ur user's valid field in db on 1 or put the constant on false and u can login to ur own site again =)
for testing purposes i would say hire a cheap ass server or google for free webservers with smtp
He can't use a server, other than localhost.
And for the love of God, use full words, and people might take what you say seriously, or better yet, read it without thinking you're 11.
   |
|
| Author |
RE: PHP help |
michelfalke
Member
Posts: 9
Location: Longitude l = new Longitude();
Joined: 08.01.10 Rank: HBH Guru |
|
MoshBat wrote:
michelfalke wrote:
/**
* sendConfirmation - Sends a confirmation to users
* who click a "Send confirmation" button. This
* only needs to be used if the EMAIL_WELCOME constant
* is changed to true and the user's 'valid' field is 0
*/
put ur user's valid field in db on 1 or put the constant on false and u can login to ur own site again =)
for testing purposes i would say hire a cheap ass server or google for free webservers with smtp
He can't use a server, other than localhost.
And for the love of God, use full words, and people might take what you say seriously, or better yet, read it without thinking you're 11.
I don't know what u'r using on localhost but i'm using a database there aswell. And the comment in the scblockedript says what to do aswell.
And for testing purposes with the email validation there will come a point which i mentioned. Hire a server or check the internet for a free host.
School sux hbh teaches me way more =) |
|
| Author |
RE: PHP help |
fuser
Member

Posts: 818
Location: in front of a computer (duh)
Joined: 05.04.07 Rank: HBH Guru |
|
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: blockedript-tutorial.php'target='_blank'>http://www.zimmertech.com/tutorials/php/25/comment-form-scblockedript-tutorial.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.







Telling modern Internet users to stop whining is like telling them to stop breathing — it seems unrealistic and inhumane. Paul Lutus
|
|
| Author |
RE: PHP help |
define
Member
Posts: 196
Location:
Joined: 13.12.08 Rank: Moderate Warn Level: 1
|
|
$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 scblockedript, 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.
Yeah. |
|
| Author |
RE: PHP help |
fuser
Member

Posts: 818
Location: in front of a computer (duh)
Joined: 05.04.07 Rank: HBH Guru |
|
|
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 scblockedript, 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.

results in:

Here's the upload and download 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)
<?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]







Telling modern Internet users to stop whining is like telling them to stop breathing — it seems unrealistic and inhumane. Paul Lutus
|
|
| Author |
RE: PHP help |
define
Member
Posts: 196
Location:
Joined: 13.12.08 Rank: Moderate Warn Level: 1
|
|
|
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.
<?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.
Yeah. |
|
| Author |
RE: PHP help |
fuser
Member

Posts: 818
Location: in front of a computer (duh)
Joined: 05.04.07 Rank: HBH Guru |
|
I implemented the changes you suggested, but I got a few problems I
will show through screenshots:
post comments:
[IMG]http://img52.imagesha
ck.us/img52/1596/wtfdg.th.jpg[/IMG]
download:
after I try to download any of the files listed, I get this:
[IMG]http://img641.image
shack.us/img641/6650/dlprob.th.jpg[/IMG]
[IMG]http://img62.images
hack.us/img62/9082/dlprob2.th.jpg[/IMG]
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:
[IMG]http://img62.images
hack.us/img62/972/dlprob3.th.jpg[/IMG]







Telling modern Internet users to stop whining is like telling them to stop breathing — it seems unrealistic and inhumane. Paul Lutus
Edited by fuser on 20-02-10 10:13 |
|
| Author |
RE: PHP help |
fuser
Member

Posts: 818
Location: in front of a computer (duh)
Joined: 05.04.07 Rank: HBH Guru |
|
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
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?







Telling modern Internet users to stop whining is like telling them to stop breathing — it seems unrealistic and inhumane. Paul Lutus
|
|
| Author |
RE: PHP help |
MoshBat
I am awesome

Posts: 4364
Location: Somewhere that I hope you think is witty.
Joined: 13.08.06 Rank: Newbie Warn Level: 100
|
|
|
fuser wrote:
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?
if(isset($_SESSION['username'])){
uploadFunction();
}else{
die();
}
Something like that...?
   |
|
| Author |
RE: PHP help |
fuser
Member

Posts: 818
Location: in front of a computer (duh)
Joined: 05.04.07 Rank: HBH Guru |
|
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.







Telling modern Internet users to stop whining is like telling them to stop breathing — it seems unrealistic and inhumane. Paul Lutus
|
|
| Author |
RE: PHP help |
define
Member
Posts: 196
Location:
Joined: 13.12.08 Rank: Moderate Warn Level: 1
|
|
|
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.
Yeah. |
|
| Author |
RE: PHP help |
fuser
Member

Posts: 818
Location: in front of a computer (duh)
Joined: 05.04.07 Rank: HBH Guru |
|
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.







Telling modern Internet users to stop whining is like telling them to stop breathing — it seems unrealistic and inhumane. Paul Lutus
|
|
| Author |
RE: PHP help |
fuser
Member

Posts: 818
Location: in front of a computer (duh)
Joined: 05.04.07 Rank: HBH Guru |
|
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.







Telling modern Internet users to stop whining is like telling them to stop breathing — it seems unrealistic and inhumane. Paul Lutus
|
|
| Author |
RE: PHP help |
MoshBat
I am awesome

Posts: 4364
Location: Somewhere that I hope you think is witty.
Joined: 13.08.06 Rank: Newbie Warn Level: 100
|
|
|
fuser wrote:
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.
You're right. I am laughing at your misfortune.
Cheer up, take some "happy pills". Shit happens.
   |
|
| Author |
RE: PHP help |
define
Member
Posts: 196
Location:
Joined: 13.12.08 Rank: Moderate Warn Level: 1
|
|
|
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.
Yeah. |
|
|
|
|