[SOLVED] copy-paste problem.....

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
dethron
Forum Contributor
Posts: 370
Joined: Sat Apr 27, 2002 11:39 am
Location: Istanbul

[SOLVED] copy-paste problem.....

Post by dethron »

Hi All;

I want to help people, but if i copy the code in their post, and paste it to my editor the code looks horrible :( It lost all readability.

How do you test others' codes?
Last edited by dethron on Thu Sep 16, 2004 8:15 pm, edited 1 time in total.
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

I generally don't,

If they are asking for help debugging code I may have a look at the code if it is not too large and see if I can see anything. Where it is large I try to give debugging advice.

The main thing I look for is the question itself. If the user states the error/line then I am more likely to find the error. If someone shows a long piece of code and says simply "What is wrong" with this I'll probably ignore them. After all if they cannot be bothered to spend a bit of time to provide enough information for me to help them why should I spend my time ?

If you want to check code, you may want to check your character font and tab/spacing values.
User avatar
dethron
Forum Contributor
Posts: 370
Joined: Sat Apr 27, 2002 11:39 am
Location: Istanbul

Post by dethron »

Yes you are right, but as you can see in many codes it is really hard to understand them.
I hate codes that is written just to do something. The code should contain some styling, some artwork in it. For example ;

Code: Select all

<?php
$res = mysql_query("SELECT * FROM ".$DBprefix."signup WHERE username like '%$searchname%' and fullname like'%$name%' and state like'%$state%' and gender like'$gender%' and userlevel='1' and actnum='0' and '$currentyear'-dobyear >= $lowage and '$currentyear'-dobyear <= '$highage' {$image}");
?>


It is really hard to track this sql statement. It is obviously bad written. I prefer

Code: Select all

<?php
	$tablename = $DBprefix."signup";
	$sqlstatement = "SELECT * FROM $tablename WHERE
					username LIKE '%$searchname%' AND
					fullname LIKE '%$name%' AND
					state LIKE '%$state%' AND
					gender LIKE '$gender%' AND
					userlevel = '1' AND
					actnum = '0' AND
					'$currentyear'-dobyear >= $lowage AND 
					'$currentyear'-dobyear <= '$highage' {$image}
					";
	$runquery = mysql_query($sqlstatement);
?>
Moreover, it is better to seperate the sql and the html, so i rather choose the create query using a class. (I posted a class ex to viewtopic.php?t=25412)

Soooo, anyway :) thnx for your response....
Happy PHP-days to everyone.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

What you can do if copy + paste it into notepad .. then re-copy it from there.. it seems to work fine
User avatar
dethron
Forum Contributor
Posts: 370
Joined: Sat Apr 27, 2002 11:39 am
Location: Istanbul

Post by dethron »

i tried it, but nothing changed :(
anyway, it is not an important matter,
forum looks better now.
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Post by vigge89 »

i can just copy and paste directly into EditPlus 2?
User avatar
dethron
Forum Contributor
Posts: 370
Joined: Sat Apr 27, 2002 11:39 am
Location: Istanbul

Post by dethron »

i download and installed v2.12(76), and it was not worked :( like notepad.
may be the problem stems from my computer, is there anyone who suffers from same promlem?
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Re: copy-paste problem.....

Post by CoderGoblin »

dethron wrote:I want to help people, but if i copy the code in their post, and paste it to my editor the code looks horrible :( It lost all readability.
In what way does it look horrible, strange characters, lack of line breaks or just indentation ?
User avatar
dethron
Forum Contributor
Posts: 370
Joined: Sat Apr 27, 2002 11:39 am
Location: Istanbul

Post by dethron »

i can not see line breaks, and indentation :(
if the code consists of 30 lines, it becomes 3-5 lines.

there is no strange character.
thnx.
Getran
Forum Commoner
Posts: 59
Joined: Wed Aug 11, 2004 7:58 am
Location: UK
Contact:

Post by Getran »

happens to me too, i just use WordPad instead or some other editor like DzSoft PHP Editor, or Html-Kit...
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I've never had any problems copying the code posted.. At least on Windows machines, the receiver of the paste determines how the paste looks.. maybe switching editors would help.. for the record, Visual Studio and TextPad receive the pastes correctly on my system.
User avatar
dethron
Forum Contributor
Posts: 370
Joined: Sat Apr 27, 2002 11:39 am
Location: Istanbul

Post by dethron »

some say notepad ok, but it is not ok for me.
some say ultraedit ok, but it is not ok for me.

most probably yours will not too.
i tried dreamweaver, notepad, homesite, ultraedit; and i give up trying.

and we are not concerning your system, because you are admin, and we are users ;)
"the pastes correctly on my system" => it smells selfishly.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

very few things are different for me on the pages compared to the rest of you. All the posts (ignoring some buttons) are exactly the same.

The new

Code: Select all

tags are set up almost exactly the same as the old ones, with a few feature additions that were needed. The code still appears in a single table cell, by itself.
User avatar
dethron
Forum Contributor
Posts: 370
Joined: Sat Apr 27, 2002 11:39 am
Location: Istanbul

Post by dethron »

thanx for explaining :)
Post Reply