HTML helping

Discuss, argue, whine, talk but not about Elma.

Moderator: Moporators

User avatar
benson
Kuski
Posts: 49
Joined: 21 Oct 2004, 15:35
Location: Hong Kong
Contact:

Post by benson »

I'd like to know the best way to include music (html probably) in web pages, which can be played in different platforms with different players. (besides flash)
and how about if the format of the song is asf (which cannot be changed)?
Hoping Elma can spread in Hong Kong... but... nearly impossible
[JAB] TT: 53:57:14...
User avatar
niN
Kuski
Posts: 2631
Joined: 22 Aug 2005, 12:23
Team: HoHo
Location: Sweden, Gothemburg
Contact:

Post by niN »

Hey again!

I'm pretty annoied now since I've been trying to find a script of how to create folders on my server via php. I thought I'd found one but it didn't work (grr!). Does anyone know how to create folders on my server through php?

EDIT: nvm, soulved the problem
Team HotHorses, and I'm converting to Icelandian now...
User avatar
The_BoneLESS
38mins club
Posts: 4604
Joined: 7 Sep 2003, 00:30
Team: HHIT
Location: Dangerously close to the St-Lawrence River
Contact:

Post by The_BoneLESS »

ok, not really html but.

I'm actually building a little website, just to practice my PHP skills and i'm using easyPHP.

I'd like to know if mySQL accepts foreign keys, because there is no option in phpmyadmin and when i alter the table with some SQL, it seems to work but, there is no concrete sign that it worked.

If someone knows, please let me know.

thanx
Website || TT:38:05:33 || WC5:15th || HHIT for life || 9th world wide ... BAP is next
User avatar
skint0r
39mins club
Posts: 768
Joined: 16 Jun 2002, 07:36
Location: Oslo, Norway

Post by skint0r »

If I remember right (you could just google it), you need to use InnoDB tables to use foreign keys, not MyISAM.
Prestigious member of 14.6x Tutor14 club
User avatar
niN
Kuski
Posts: 2631
Joined: 22 Aug 2005, 12:23
Team: HoHo
Location: Sweden, Gothemburg
Contact:

Post by niN »

I'm kind of in an evil circle here. I need to rename replay-files (with php) like this: "LENUMUSE" where LE = levelpack (in this example lets use Ni), NUM = levelnumber (in this example lets use 022) and USE = user (in this example lets use kat).

In other words I want to upload a replayfile and when it's uploaded to my server it should be renamed to Ni022kat.rec with some ez php coding.

As you see for the first two variables, LE and NUM, I need to use skints recinfo script. The only problem is that I need to upload the replay-file in able to read this info off it, and since I want to rename the replay before I upload it I'm in an evil circle.

Have anyone got any idea of how I can soulve this problem? I've been thinking about it for quite some time but haven't really found any good solution. One idea was to upload the replay-file, read and save the info into variables, and then reupload it (deleting the old of course). The only problem is that I cant really do a script like this due to lack of knowledge.
Some help would be much apprechiated :)
Team HotHorses, and I'm converting to Icelandian now...
User avatar
skint0r
39mins club
Posts: 768
Joined: 16 Jun 2002, 07:36
Location: Oslo, Norway

Post by skint0r »

I do the same thing for my site, it's not too hard. If you're using forms to upload your replays, then the file should be stored in a tmp directory on your server, where you can perform actions on it, before finally moving it to where you want.

Here's an example of how I do it, hopefully you'll figure out how to change it for your options (I left out a lot of extra safety measures and such, but you get the idea):

Code: Select all

/* If the form was submitted, we do the file processing */
if ($_POST['uprec']) {

	/* Set a variable that holds the path to where we'll save the new file.
	   This directory *should* already exist, as it should have been created
	   when the user registered, so we won't bother checking for errors */
	$uploaddir = '/home/.hector/k10x/skintatious.net/' . $recdir . '/';
	
	/* Temporary filename ('file' being the name of the file field in the upload form) */
	$tmpfilename = $_FILES['file']['tmp_name'];
	
	/* Get the level name from the replay */
	$levname = getRecInfo($tmpfilename, l);
	
	/* Check if the level name in the replay matches any valid options using
	   regular expressions. (levelpack, 2-4 numbers and .lev in the end) */
	if (!preg_match('/(skint|sntl|bask[gp]?|skvar|skhoyl)(\d{2,4})\.lev/i', $levname, $levtmp)) {
		echo("$levname is not a valid level.");
		return;
	}
	
	/* If it is indeed valid, set variables accordingly from the back references */
	else {
		$levpack = $levtmp[1];
		$levnumber = (int) $levtmp[2];
	}
	
	/* Do some formatting to the filename elements we're using later.
	   '%02s' means 2 digits (zero-padded), and the last number in the substr();
	   is the number of letters you want from the nick. */ 
	switch ($levpack) {
		case 'SNTL':
			$levpack = 'SN';
			$levnumber = sprintf('%02s', $levnumber);
			$nick = substr($nick, 0, 4);
			break;
		case 'BaSk':
			$levpack = 'Bs';
			$levnumber = sprintf('%04s', $levnumber);
			$nick = substr($nick, 0, 2);
			break;
		case 'SkVar':
			$levpack = 'SkV';
			$levnumber = sprintf('%03s', $levnumber);
			$nick = substr($nick, 0, 2);
			break;
	}

	/* If everything is in order, we build a new name for the file
	   based on the level and the user name */
	$filename = $levpack . $levnumber . $nick . '.rec';
	
	/* We append the newly created filename to the user's replay path */
	$newfile = $uploaddir . $filename;
	
	/* Since everything is in order with the uploaded file, it's time
	   to finally rename and move it */
	if (move_uploaded_file($tmpfilename, $newfile)) {
		echo('<h1>Success!</h1><p>Your record has been added</p>');
	}
Prestigious member of 14.6x Tutor14 club
User avatar
niN
Kuski
Posts: 2631
Joined: 22 Aug 2005, 12:23
Team: HoHo
Location: Sweden, Gothemburg
Contact:

Post by niN »

Thank you skint0r, dont know what I'd do without you ;P. I'll definately give it a try!
Team HotHorses, and I'm converting to Icelandian now...
User avatar
niN
Kuski
Posts: 2631
Joined: 22 Aug 2005, 12:23
Team: HoHo
Location: Sweden, Gothemburg
Contact:

Post by niN »

I've been up quite late finishing this Replayrenaming script. Thought I might share it if anyone is interested. The first half is skint0rs recinfo script, needed that in there aswell.
Anyways, here it is. Hope it's all valid! :)

Now I'll sleep
Team HotHorses, and I'm converting to Icelandian now...
User avatar
zworqy
Kuski
Posts: 3706
Joined: 19 May 2002, 23:17
Location: Lilla Edet, Sweden
Contact:

Post by zworqy »

It didn't occur to you to do this?

http://php.net/manual/en/function.rename.php
<Fihlvein> another case of zworqy-is-always-right closed i guess
<yoosef> zworqy doesnt suck at anything
User avatar
skint0r
39mins club
Posts: 768
Joined: 16 Jun 2002, 07:36
Location: Oslo, Norway

Post by skint0r »

That whole "original.rec" thing is sort of superfluous. Just work with the temporary file instead and use the move_uploaded_file() afterwards and skip that whole step. What do you think happens if two people upload a file at the same time (ok, highly unlikely, but...)?
Prestigious member of 14.6x Tutor14 club
User avatar
niN
Kuski
Posts: 2631
Joined: 22 Aug 2005, 12:23
Team: HoHo
Location: Sweden, Gothemburg
Contact:

Post by niN »

skint0r wrote:That whole "original.rec" thing is sort of superfluous. Just work with the temporary file instead and use the move_uploaded_file() afterwards and skip that whole step. What do you think happens if two people upload a file at the same time (ok, highly unlikely, but...)?
hm, you're right. I'll give your script another look ;)

EDIT:

Code: Select all

   /* Temporary filename ('file' being the name of the file field in the upload form) */
   $tmpfilename = $_FILES['uploadedfile']['tmp_name'];

   /* If the file which was uploaded is a .rec file then we upload it into $target_path */
   if(substr($_FILES['uploadedfile']['name'], strlen($_FILES['uploadedfile']['name'])-3, 3) == "rec")
   {
   
   /* Get levinfo with skints recinfo script */
   $level = getRecInfo($target_path, l);
   
   $k = strpos($level, '.lev');
   if ($k > 0) {
   $level = substr($level, 0, $k+4);
   }

   /* This is where we rename the replay file, we remove the last 4 chars from the info we got earlier. 
   $rem_b is a variable which removes levelnumber in able for me to know which levelpack the level belong */
   $rem = substr($level, 0, -4);
   $rem_b = substr($rem, 0, -3);

   /* This is where we decide which levelpack the replay belong. We replace the chars with something more convenient */
   if($rem_b = "nIN")
   {
   $rem_c = ereg_replace("nIN", "Ni", $rem);
   }

   elseif($rem_b = "katBa")
   {
   $rem_c = ereg_replace("katBa", "kB", $rem);
   }

   else
   {
   $rem_c = ereg_replace("katPa", "kP", $rem);
   }
   
   /* just add the *.rec* chars to the replay name */
   $replayname = $rem_c.".rec";

   /* Now when we have the name waiting to be used, it's time we uploaded the replay with it's brand new name */
   move_uploaded_file( $_FILES['uploadedfile']['tmp_name'], $replayname );

   echo "File ".$replayname." was successfully uploaded!";

}
This doesn't work, it then says: "File The filename specified does not ex.rec was successfully uploaded!" Any ideas :P?

EDIT #2
I figured it out, hadn't been paying too much attention. Sorry!
Team HotHorses, and I'm converting to Icelandian now...
User avatar
niN
Kuski
Posts: 2631
Joined: 22 Aug 2005, 12:23
Team: HoHo
Location: Sweden, Gothemburg
Contact:

Post by niN »

How do I select rows from a database WHERE level='$bläh' AND username='$what'

Basically this is my code:

Code: Select all

   $records = mysql_query( "SELECT * FROM mytable WHERE Level ='$level'" );
But I want it to select the row where level is $level And user is $user. Do you understand what I mean? I've tryed all these:

Code: Select all

   $records = mysql_query( "SELECT * FROM mytable WHERE Level ='$level' AND Username ='$user'" );

   $records = mysql_query( "SELECT * FROM mytable WHERE Level ='$level', Username ='$user'" );

   $records = mysql_query( "SELECT * FROM mytable WHERE Level ='$level' Username ='$user'" );
but neither worked. Any idea? :)
Team HotHorses, and I'm converting to Icelandian now...
User avatar
The_BoneLESS
38mins club
Posts: 4604
Joined: 7 Sep 2003, 00:30
Team: HHIT
Location: Dangerously close to the St-Lawrence River
Contact:

Post by The_BoneLESS »

Code: Select all

   $records = mysql_query( "SELECT * FROM mytable WHERE Level ='$level' AND Username ='$user'" );
This one should work,...

maybe the concatenation is not done correctly. Don't you have to use . to concatenate correctly? (Though i don't always use them)

Or maybe does the the query simply returns nothing? (database not filled correctly)

are level and user from the same table?
Website || TT:38:05:33 || WC5:15th || HHIT for life || 9th world wide ... BAP is next
User avatar
niN
Kuski
Posts: 2631
Joined: 22 Aug 2005, 12:23
Team: HoHo
Location: Sweden, Gothemburg
Contact:

Post by niN »

The_BoneLESS wrote:

Code: Select all

   $records = mysql_query( "SELECT * FROM mytable WHERE Level ='$level' AND Username ='$user'" );
This one should work,...

maybe the concatenation is not done correctly. Don't you have to use . to concatenate correctly? (Though i don't always use them)

Or maybe does the the query simply returns nothing? (database not filled correctly)

are level and user from the same table?
You're a pearl :*

The problem wasn't that code, but the code following. Wasn't valid php :P fixed teh :)

I also need some help with getting date with php. Does anyone knows how to get the same date for everyone (no matter what timezone) with php?
Team HotHorses, and I'm converting to Icelandian now...
User avatar
skint0r
39mins club
Posts: 768
Joined: 16 Jun 2002, 07:36
Location: Oslo, Norway

Post by skint0r »

niN wrote:I also need some help with getting date with php. Does anyone knows how to get the same date for everyone (no matter what timezone) with php?
Not sure what you mean here -- PHP is server side and will always give the server's date and time. The only way you can get the date and time for someone automatically is through Javascript (maybe Flash and some others too possibly).
Prestigious member of 14.6x Tutor14 club
User avatar
niN
Kuski
Posts: 2631
Joined: 22 Aug 2005, 12:23
Team: HoHo
Location: Sweden, Gothemburg
Contact:

Post by niN »

skint0r wrote:
niN wrote:I also need some help with getting date with php. Does anyone knows how to get the same date for everyone (no matter what timezone) with php?
Not sure what you mean here -- PHP is server side and will always give the server's date and time. The only way you can get the date and time for someone automatically is through Javascript (maybe Flash and some others too possibly).
hm okay I'll try that out, or just use normal php and forget about the hour difference :P
Team HotHorses, and I'm converting to Icelandian now...
User avatar
skint0r
39mins club
Posts: 768
Joined: 16 Jun 2002, 07:36
Location: Oslo, Norway

Post by skint0r »

You could of course just have some settings/preferences page where the user can select his timezone/offset and calculate the datetime through that.
Prestigious member of 14.6x Tutor14 club
User avatar
niN
Kuski
Posts: 2631
Joined: 22 Aug 2005, 12:23
Team: HoHo
Location: Sweden, Gothemburg
Contact:

Post by niN »

hm, yes that would work. But my knowledge about timezoning isn't the best so I'd have to read a bit about it. I know it's prolly not that difficult but still.. I'll give it a think. For not I'll do it the simplier way.
Team HotHorses, and I'm converting to Icelandian now...
User avatar
niN
Kuski
Posts: 2631
Joined: 22 Aug 2005, 12:23
Team: HoHo
Location: Sweden, Gothemburg
Contact:

Post by niN »

omg, I dont get it. Can someone tell me what teh heck is wrang with this variable:

Code: Select all

$updrectime = "<a>" . $rectime . "</a>";
I dont get it, I've been trying to get teh fak to work for bloody hours but that stupid variable wont work :(
Team HotHorses, and I'm converting to Icelandian now...
User avatar
skint0r
39mins club
Posts: 768
Joined: 16 Jun 2002, 07:36
Location: Oslo, Norway

Post by skint0r »

Nothing wrong with that. Are you sure $rectime is not empty or something? Easiest way to test what's wrong with variables is to just explicitly set their values in the script and see where it fails and what is missing. Like try setting $rectime = "test"; on the line above for instance.
Prestigious member of 14.6x Tutor14 club
User avatar
niN
Kuski
Posts: 2631
Joined: 22 Aug 2005, 12:23
Team: HoHo
Location: Sweden, Gothemburg
Contact:

Post by niN »

skint0r wrote:Nothing wrong with that. Are you sure $rectime is not empty or something? Easiest way to test what's wrong with variables is to just explicitly set their values in the script and see where it fails and what is missing. Like try setting $rectime = "test"; on the line above for instance.
Hm, I'm quite sure there's nothing wrong with that part. I tryed changing $upldrectime to "lol" and then it worked perfectly fine! I tell you, I've been stearing at the script for hours and not found anything wrong! I'll upload it and post link here because the code system here on lauta doesn't work fully. That variable I showed you is actually a bit different, but lauta couldn't show it.

I've marked the spots you need to know with many *:s. But you might want to know that I'm writing that variable into a database, and the problem might lie in the database.

http://up.k10x.net/ckcpivtxurrcl/ReplayHandler.php
Team HotHorses, and I'm converting to Icelandian now...
User avatar
skint0r
39mins club
Posts: 768
Joined: 16 Jun 2002, 07:36
Location: Oslo, Norway

Post by skint0r »

First of all, what a mess :D
There's quite a lot of unecessary things done there, but as long as it works... You should consider reading about ]date(); (http://se.php.net/date), as it makes that whole date if-else thing you got going on obsolete. You can get all values directly from date(); zeropadded and make a string with your desired syntax right from that one function.

It's really too hard to see through this script. It should be an easy problem to find since you now know there's something wrong with the variable. It's obviously not being set somehow since it's empty.
Hm, I'm quite sure there's nothing wrong with that part. I tryed changing $upldrectime to "lol" and then it worked perfectly fine!
That's kinda lolz, the fact that setting the variable to "lol" and it worked should be enough to convince you that it IS the exact location of your problem :P

When you're testing out a script and run into errors you can't find, the first step (which usually helps the most) is to simply echo all variables etc out and see what's missing.

You can use the constant __LINE__ to help you with this, as it tells you the current line in the script.
Prestigious member of 14.6x Tutor14 club
User avatar
niN
Kuski
Posts: 2631
Joined: 22 Aug 2005, 12:23
Team: HoHo
Location: Sweden, Gothemburg
Contact:

Post by niN »

skint0r wrote:First of all, what a mess :D
There's quite a lot of unecessary things done there, but as long as it works... You should consider reading about ]date(); (http://se.php.net/date), as it makes that whole date if-else thing you got going on obsolete. You can get all values directly from date(); zeropadded and make a string with your desired syntax right from that one function.
Okay! thanks! Ye will do :P. I didn't know how I should soulve that problem but I'll get to work now!
skint0r wrote:
Hm, I'm quite sure there's nothing wrong with that part. I tryed changing $upldrectime to "lol" and then it worked perfectly fine!
That's kinda lolz, the fact that setting the variable to "lol" and it worked should be enough to convince you that it IS the exact location of your problem :P

When you're testing out a script and run into errors you can't find, the first step (which usually helps the most) is to simply echo all variables etc out and see what's missing.
I tryed replacing $updrectime with "echo" and it did in fact write the correct thing, it worked. There is no reason to why this shouldn't work, right? I mean, I dont see one.
Team HotHorses, and I'm converting to Icelandian now...
User avatar
skint0r
39mins club
Posts: 768
Joined: 16 Jun 2002, 07:36
Location: Oslo, Norway

Post by skint0r »

Well when you first told about this variable, what exactly was wrong?

As for the dates, you could probably just do this instead of everything you're doing:

Code: Select all

$todayDate = date('H:i:s F, d Y');
$date = date('Y-m-d H:i:s');
Prestigious member of 14.6x Tutor14 club
User avatar
niN
Kuski
Posts: 2631
Joined: 22 Aug 2005, 12:23
Team: HoHo
Location: Sweden, Gothemburg
Contact:

Post by niN »

skint0r wrote:As for the dates, you could probably just do this instead of everything you're doing:

Code: Select all

$todayDate = date('H:i:s F, d Y');
$date = date('Y-m-d H:i:s');
haha, thank you man :D
skint0r wrote: Well when you first told about this variable, what exactly was wrong?
Well since you prolly read the script you know that I want one to be able to check a checkbox in able to share his replay. This is how I checked if the replay was shared in the script:

Code: Select all

   /* Getting the time of the level. And if it's shared add a href to it */
   if ( !isset( $_POST[ 'share' ] ) ) {
   $updrectime = getRecInfo( $tmpfilename, t );
   }

   else {
   $updrectime = "<a>" . $rectime . "</a>";
   }
Now for some reason that else variable doesn't work. I was thinking that maybe the problem lies in the database, maybe the string is too long to be written to the database? Now, I don't know much about databases, only enough to just be able to use them with php, so this might be a stupid idea.

Was this what you wanted to know?

EDIT: the else variable doesn't look exactly like that but lauta can't show it.
Team HotHorses, and I'm converting to Icelandian now...
User avatar
skint0r
39mins club
Posts: 768
Joined: 16 Jun 2002, 07:36
Location: Oslo, Norway

Post by skint0r »

"doesn't work", what exactly do you mean by that? It's empty, wrong info or what?
Prestigious member of 14.6x Tutor14 club
User avatar
niN
Kuski
Posts: 2631
Joined: 22 Aug 2005, 12:23
Team: HoHo
Location: Sweden, Gothemburg
Contact:

Post by niN »

skint0r wrote:"doesn't work", what exactly do you mean by that? It's empty, wrong info or what?
The replay file is uploaded and everything but nothing gets written to the database. However, I think I might have found one problem. In my script I write tons of shit to the time if it is shared (I add a url to it) and then write it to the database. So in the database it would look like:

Code: Select all

<a>0:14,55</a>
In my script I have a code that checks if the uploaded rec time is smaller than the excisting one in the database:

Code: Select all


   if ( $rectime < $record[ 'Time' ]  ) {
   mysql_query( "UPDATE ttrecords SET Date='$date' , Time='$updrectime' WHERE Username ='$user' AND Level ='$level'" );
   mysql_query( "INSERT INTO ttall ( Nation, Username, Date, inDate, Time, Level, inLevel ) VALUES( '$nat','$user','$date','$todayDate','$updrectime','$level','$rem_c' )" );

   }
Now you cant check if "0:12,33" is smaller than "<a>0:14,55</a>".

I'll try and fix that right away, do you think this might be the problem?
Team HotHorses, and I'm converting to Icelandian now...
User avatar
skint0r
39mins club
Posts: 768
Joined: 16 Jun 2002, 07:36
Location: Oslo, Norway

Post by skint0r »

Very likely :P
Prestigious member of 14.6x Tutor14 club
User avatar
niN
Kuski
Posts: 2631
Joined: 22 Aug 2005, 12:23
Team: HoHo
Location: Sweden, Gothemburg
Contact:

Post by niN »

No it still doesn't work :(

If you have shared the replay The file gets uploaded but nothing gets written to the database. Here's the shorter version of the code (with the correct date shit :P) If you feel like giving it a look then do so, otherwise I'll think of something else for the sharing system. Thanks anyway!

http://up.k10x.net/jenzqmftbooei/ReplayHandler.php
Team HotHorses, and I'm converting to Icelandian now...
User avatar
skint0r
39mins club
Posts: 768
Joined: 16 Jun 2002, 07:36
Location: Oslo, Norway

Post by skint0r »

It's really too hard to debug scripts just by reading something like this, at least this sort of thing. Just try putting echo statements throughout your script, specially in if-else statements and check if they are triggered or not and if the variables are correct.

If nothing gets added to the database, then you must assume that there's something wrong with the if-else statements with the database insert function in them and that they are not triggered.
Prestigious member of 14.6x Tutor14 club
User avatar
niN
Kuski
Posts: 2631
Joined: 22 Aug 2005, 12:23
Team: HoHo
Location: Sweden, Gothemburg
Contact:

Post by niN »

this is funny! I tryed putting echo:s to test if the if/else:s will get triggered and I found no problem at all :D. Everything works fine except, the script wont write a thing to the database if the checkbox for sharing replays is checked. This is stupid, must be some internal php error ;o

After testing my code by putting echo:s in different places I found that it is this code that the problem lies in:

Code: Select all

   mysql_query( "INSERT INTO ttrecords ( Nation, Username, Date, Time, inTime, Level, inLevel ) VALUES( '$nat','$user','$date','$updrectime','$rectime','$level','$rem_c' )" );
   mysql_query( "INSERT INTO ttall ( Nation, Username, Date, inDate, Time, Level, inLevel ) VALUES( '$nat','$user','$date','$todayDate','$updrectime','$level','$rem_c' )" );
The code that writes the info to the database. I've studied it but I wont find any problems.

That's not the funny part, the funny part is that the code above (writing info into databases) works perfectly fine unless that recsharingbox is checked. \o/.
Team HotHorses, and I'm converting to Icelandian now...
User avatar
skint0r
39mins club
Posts: 768
Joined: 16 Jun 2002, 07:36
Location: Oslo, Norway

Post by skint0r »

What happens if you remove the added html in the else statement for the share rec thing? i.e. just put rec time there?
Prestigious member of 14.6x Tutor14 club
User avatar
skint0r
39mins club
Posts: 768
Joined: 16 Jun 2002, 07:36
Location: Oslo, Norway

Post by skint0r »

I'm guessing it's the apostrophes in the html's fault. If it's the case, then just use addslashes() to the variable before inserting it.
Prestigious member of 14.6x Tutor14 club
User avatar
niN
Kuski
Posts: 2631
Joined: 22 Aug 2005, 12:23
Team: HoHo
Location: Sweden, Gothemburg
Contact:

Post by niN »

skint0r wrote:What happens if you remove the added html in the else statement for the share rec thing? i.e. just put rec time there?
It works =o
Soo it's the added html the problem lies in!
Team HotHorses, and I'm converting to Icelandian now...
User avatar
The_BoneLESS
38mins club
Posts: 4604
Joined: 7 Sep 2003, 00:30
Team: HHIT
Location: Dangerously close to the St-Lawrence River
Contact:

Post by The_BoneLESS »

niN wrote:That's not the funny part, the funny part is that the code above (writing info into databases) works perfectly fine unless that recsharingbox is checked. \o/.
i guess you just narrowed down your problem to one line then...

the bug should be in this line (though i don't see it yet)(and i really dislike how lauta fucks this line when in code) :

Code: Select all

$updrectime = "<a>" . $rectime . "</a>";
you could also make some like (never tried but, it should work... the query would return 1 if it worked) :

Code: Select all

$check = mysql_query( ...your query... );
if($check != 1)
{
    echo "your request is fucked up...";
}
EDIT : Just saw skint's reply... totally forgot about those stupid apostrophies :x
Website || TT:38:05:33 || WC5:15th || HHIT for life || 9th world wide ... BAP is next
User avatar
niN
Kuski
Posts: 2631
Joined: 22 Aug 2005, 12:23
Team: HoHo
Location: Sweden, Gothemburg
Contact:

Post by niN »

skint0r wrote:I'm guessing it's the apostrophes in the html's fault. If it's the case, then just use addslashes() to the variable before inserting it.
Omg that worked! Thanks to both skintor and boneless for helping :) owe you both
Team HotHorses, and I'm converting to Icelandian now...
User avatar
skint0r
39mins club
Posts: 768
Joined: 16 Jun 2002, 07:36
Location: Oslo, Norway

Post by skint0r »

Also an extra tip, you "should" try to use single quotes whenever possible instead of double quotes. The time difference are measly milliseconds, but when you have a lot of them they add up fast.

When you use double quotes ("), PHP always checks the function for variables, so unless you have a variable you need evaluated in a query or function, you should use single quotes. Again, not super important, but it's nice to get used to doing it either way

i.e.: $x = 'fack'; instead of $x = "fack";
echo('test'); instead of echo("test"); etc.

I'm not sure which is faster of these two however:
echo('test variable: ' . $x);
vs.
echo("test variable: $x");

But single quotes is the way to go anyway!
Prestigious member of 14.6x Tutor14 club
User avatar
niN
Kuski
Posts: 2631
Joined: 22 Aug 2005, 12:23
Team: HoHo
Location: Sweden, Gothemburg
Contact:

Post by niN »

Thanks man! I'll fix teh right away :)

EDIT:
Should I change this aswell?

if ($bläh == "loalz")
ereg_replace( "kaBa", "kB", $rem );

into

if ($bläh == 'loalz')
ereg_replace( 'kaBa', 'kB', $rem );

EDIT #2:
Not functions, got it ;)
Team HotHorses, and I'm converting to Icelandian now...
User avatar
skint0r
39mins club
Posts: 768
Joined: 16 Jun 2002, 07:36
Location: Oslo, Norway

Post by skint0r »

Yep, change those as well.

Again, it's an insignificant thing, but it's a good habit to learn. Unless you're so used to using double quotes that it's hard to shake away.
Prestigious member of 14.6x Tutor14 club
User avatar
niN
Kuski
Posts: 2631
Joined: 22 Aug 2005, 12:23
Team: HoHo
Location: Sweden, Gothemburg
Contact:

Post by niN »

okay, I'm on it already :) Actually I need some ez help. Is it possible to rename folders which contains files? I tried this:

Code: Select all

rename("Users/' . $user", "Users/' . $Username");
But it didn't work =o. The folder (Users/$user) kept it's name.
Team HotHorses, and I'm converting to Icelandian now...
User avatar
The_BoneLESS
38mins club
Posts: 4604
Joined: 7 Sep 2003, 00:30
Team: HHIT
Location: Dangerously close to the St-Lawrence River
Contact:

Post by The_BoneLESS »

niN wrote:okay, I'm on it already :) Actually I need some ez help. Is it possible to rename folders which contains files? I tried this:

Code: Select all

rename("Users/' . $user", "Users/' . $Username");
But it didn't work =o. The folder (Users/$user) kept it's name.
I don't get your use of apostrophies...

maybe this could work:

Code: Select all

rename("Users/$user", "Users/$Username");
Website || TT:38:05:33 || WC5:15th || HHIT for life || 9th world wide ... BAP is next
User avatar
niN
Kuski
Posts: 2631
Joined: 22 Aug 2005, 12:23
Team: HoHo
Location: Sweden, Gothemburg
Contact:

Post by niN »

No it didn't work :(. The reason to why I use those apostrophies is because I combine variables with normal text in the target path.
Any other ideas? Remember that the folder isn't empty, duno if it makes a difference.
Team HotHorses, and I'm converting to Icelandian now...
User avatar
The_BoneLESS
38mins club
Posts: 4604
Joined: 7 Sep 2003, 00:30
Team: HHIT
Location: Dangerously close to the St-Lawrence River
Contact:

Post by The_BoneLESS »

I don't think that the folder being filled matters. In windows, you can rename a folder manually even if there are files in it.

In the case that use place your apostrophies right, maybe this could work:

Code: Select all

rename("Users/'" . $user, "Users/'" . $Username);
EDIT : and if it doesn't work, would you mind showing what's in those $user and $Username variables?
Website || TT:38:05:33 || WC5:15th || HHIT for life || 9th world wide ... BAP is next
User avatar
niN
Kuski
Posts: 2631
Joined: 22 Aug 2005, 12:23
Team: HoHo
Location: Sweden, Gothemburg
Contact:

Post by niN »

It didn't work :(

Here are the variables:

Code: Select all

$Username = $_POST[ 'newUsername' ];
$user = $_COOKIE[ 'registered' ];
Team HotHorses, and I'm converting to Icelandian now...
User avatar
The_BoneLESS
38mins club
Posts: 4604
Joined: 7 Sep 2003, 00:30
Team: HHIT
Location: Dangerously close to the St-Lawrence River
Contact:

Post by The_BoneLESS »

To test out your function, try to put some hard coded names (make sure the source directory exists)... for example :

Code: Select all

rename("Users/nin", "Users/katten");
If that doesn't work, you've got a problem with your fonction... (which i would doubt)

Otherwise, i checked your variables and, why would you put apostrophies after the Users/ , i don't see any reasons for that...

Like skint would say, have you tried to echo the content of your 2 variables? Check out if they aren't empty.
Website || TT:38:05:33 || WC5:15th || HHIT for life || 9th world wide ... BAP is next
User avatar
niN
Kuski
Posts: 2631
Joined: 22 Aug 2005, 12:23
Team: HoHo
Location: Sweden, Gothemburg
Contact:

Post by niN »

The_BoneLESS wrote:To test out your function, try to put some hard coded names (make sure the source directory exists)... for example :

Code: Select all

rename("Users/nin", "Users/katten");
If that doesn't work, you've got a problem with your fonction... (which i would doubt)
Thanks man, I did that and you were right, it worked. So now we've located the problem, it lies within the variables OR the way that I write the path. Probably the second.

So how do I write that path correctly?
Team HotHorses, and I'm converting to Icelandian now...
User avatar
niN
Kuski
Posts: 2631
Joined: 22 Aug 2005, 12:23
Team: HoHo
Location: Sweden, Gothemburg
Contact:

Post by niN »

Like you said! This worked now :D
The_BoneLESS wrote: maybe this could work:

Code: Select all

rename("Users/$user", "Users/$Username");
Thanks for helping me man, it works fine now :)
Team HotHorses, and I'm converting to Icelandian now...
User avatar
The_BoneLESS
38mins club
Posts: 4604
Joined: 7 Sep 2003, 00:30
Team: HHIT
Location: Dangerously close to the St-Lawrence River
Contact:

Post by The_BoneLESS »

Well, if the content of your $_POST and $_COOKIE variables is something like "nin" and "kitten", you'd have to write simply :

Code: Select all

rename("Users/$user", "Users/$Username");
Otherwise, show me what you stored in your variables and in your $_POST and $_COOKIE to have a better idea of the problem. Check it out with the echo.

Also check out if you don't overwrite any of your variables...

and when the renaming doesn't work, is there an error message? or nothing?

EDIT : Saw your reply. Glad i could help!
Website || TT:38:05:33 || WC5:15th || HHIT for life || 9th world wide ... BAP is next
User avatar
niN
Kuski
Posts: 2631
Joined: 22 Aug 2005, 12:23
Team: HoHo
Location: Sweden, Gothemburg
Contact:

Post by niN »

I'm using while() to gather info from a database and then I write it all out to my page. In the while( $replay = mysql_fetch_array( $replays ) ){ echo } I write a form with the following input:

Code: Select all

(PHP)...<input>...(PHP)
If the database looked like this:
level:
katba001
katba005
katpi002


You'd expect the input to write the current level right? Like if I choose to press "submit" in my page on the row which had level: "katba005", then the input would store "katba005". And if I clicked submit at the form which were in the same row as level: "katpi002", the input would write "katpi002" as level. However, this doesn't work. All I get (no matter which row I choose to click submit on) is the first level in the database (katba001).

This is extremely hard to explain, but if you didn't get it then I'll show you. Does anyone have a idea of why my input wont store the correct data?

EDIT:
And of course lauta cant read my input... here it is: http://up.k10x.net/pbrysysgfctzm/DELETEME.php
Team HotHorses, and I'm converting to Icelandian now...
User avatar
skint0r
39mins club
Posts: 768
Joined: 16 Jun 2002, 07:36
Location: Oslo, Norway

Post by skint0r »

Don't get the problem at all. Why not show the php code you use to create this form instead? I have no idea what you are talking about with the submit being in the same row bla bla :P

Just check the box that says disable html in this post to show html (I think that's the problem?)
Prestigious member of 14.6x Tutor14 club
Post Reply