Staredit Network > Forums > Technology & Computers > Topic: PHP Ongoing Assistance
PHP Ongoing Assistance
Mar 9 2008, 4:20 pm
By: InsolubleFluff
Pages: < 1 2 3 4 56 >
 

Mar 15 2008, 1:22 am AfterLifeLochie Post #41



Quote
body
{
background-image: url('/images/background2.jpg');
background-position: top left
}
center
{
background-image: url('/images/background.jpg');
background-position: top left
background-repeat: repeat-x
}
Try this:

Quote from Script
<HTML>
<HEAD>
<STYLE>
body
{
background-image: url('/images/background2.jpg');
background-position: top left
}
</STYLE>
<STYLE>
center
{
background-image: url('/images/background.jpg');
background-position: top left
background-repeat: repeat-x
}
</STYLE>
</HEAD>
<BODY>
[{[{Your Content}]}]
</BODY>
<HTML>




None.

Mar 15 2008, 2:04 am Forsaken Archer Post #42



Registered globals: http://us3.php.net/register_globals (notice the notice: removed from php6 cuz it sucks ;o )
From my memory: All global variables ($_GET, $_POST, $_COOKIE) get written as a normal variable as well. So in the url ($_GET['variable']) also gets loaded as $variable. The security hazard here is that anyone can write values for any uninitialized variable. My main concern is that variables would be all... shady like... getting overwritten if not used carefully.

Magic quotes: http://us3.php.net/manual/en/security.magicquotes.php (also removed from php6)

Shocko, without really looking at your code, I can tell your first problem is, again, invalid CSS. You forgot some semi-colons which would make all your other CSS unreadable.
Edit: After looking at it, keep in mind that your body tag and center tag, if nothing is in between, would be at the same height level and would lay on top of each other, blocking the image of one possibly.

body
{
background-image: url('/images/background2.jpg');
background-position: top left;
}
center
{
background-image: url('/images/background.jpg');
background-position: top left;
background-repeat: repeat-x;
}

AfterLifeLochie: Why put styles in two seperate style blocks?

Post has been edited 1 time(s), last time on Mar 15 2008, 2:09 am by isolatedpurity.



None.

Mar 15 2008, 2:28 am AfterLifeLochie Post #43



Quote
AfterLifeLochie: Why put styles in two seperate style blocks?
When HTML/PHP/HTTP processes <STYLE>, you can use one image, put it across the top, then, re-open the style, and, print the 2nd image for the rest of the page. When done properly, it does work.



None.

Mar 15 2008, 5:33 am (U)Bolt_Head Post #44



Quote from isolatedpurity
Registered globals: http://us3.php.net/register_globals (notice the notice: removed from php6 cuz it sucks ;o )
From my memory: All global variables ($_GET, $_POST, $_COOKIE) get written as a normal variable as well. So in the url ($_GET['variable']) also gets loaded as $variable. The security hazard here is that anyone can write values for any uninitialized variable. My main concern is that variables would be all... shady like... getting overwritten if not used carefully.

Magic quotes: http://us3.php.net/manual/en/security.magicquotes.php (also removed from php6)

Thanks, Ironic I was just getting used to the idea of not initiating variables, So its not like C++ or Java where I would say
int x = 4;
but instead to define an integer I would just say
$x = 4;

So if I insure that I define all the variables before i use any comparison then I'm all set?



None.

Mar 15 2008, 6:50 am InsolubleFluff Post #45



Thank you, you fixed it for the most part.
However. The <center> tag's background image has a right and left margin of a few pixels as well as one at the top. How do I fix this?



None.

Mar 15 2008, 8:47 am (U)Bolt_Head Post #46



Quote from Shocko
Thank you, you fixed it for the most part.
However. The <center> tag's background image has a right and left margin of a few pixels as well as one at the top. How do I fix this?

I think what your looking for is your margin dimensions
add this to your <body> tag on your page
MARGINWIDTH="0" MARGINHEIGHT="0 LEFTMARGIN="0" TOPMARGIN="0"

... Thats what I do anyways.



None.

Mar 15 2008, 2:50 pm InsolubleFluff Post #47



That was it, thank you so much :)



None.

Mar 15 2008, 3:00 pm Forsaken Archer Post #48



or in css :) add margin: 0px; to your body tag

AfterLifeLochie: you have no idea what you are talking about.

Post has been edited 1 time(s), last time on Mar 15 2008, 3:09 pm by isolatedpurity.



None.

Mar 15 2008, 4:02 pm InsolubleFluff Post #49



lolz0rz IP flamed!
im gonna try the margin thing in a minute, i figured you could do it with CSS but I wanted to just do it right the first time lol.



None.

Mar 15 2008, 4:14 pm InsolubleFluff Post #50



Ermm so I did this stuff and IE is my browser and it worked beautifully. However in firefox, some of my images are not appearing, the links are offset and yeah... any ideas as to what's going on here?



None.

Mar 16 2008, 4:10 am InsolubleFluff Post #51



My friend had problems with MYSQL an I said i'd post this up:

Quote
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNSIGNED NOT NULL AUTO_INCREMENT, PRIMARY KEY (`username`)) ENGINE = MyISAM' at line 1

Any idea as to what he may have done wrong?

Quote
JuNioR says:
in phpmyadmin
im making a field called username
with the type VARCHAR
Null = not null
Attributes = UNSIGNED
Extra = auto_increment
and its the primary key
i have no idea wut Null, attributes are for...




None.

Mar 16 2008, 1:07 pm Forsaken Archer Post #52



varchar can not be unsigned or have auto_increment as it's not an number...
Null is a choice of what to have the default value as. Null is basically "nothing". It can be used in instances where you don't want the default to be an empty string for texts or a 0 for numbers. Though I'm not 100% sure you can have text/varchar as null. I think text you can not, varchar you can.

Instead of randomly assigning attributes to a column, why not look them up first and understand the differences in column types and attributes. It makes a lot more sense then popping shit in and then asking why it doesn't work.



None.

Mar 16 2008, 2:43 pm Fierce Post #53



Also, a way to do it is by making another field called id and set it to integer, use auto_increment and then set it as the primary key (I'm taking this as if you were to create a login system or something)



None.

Mar 17 2008, 2:48 am InsolubleFluff Post #54



Don't know what I'm doing wrong, but in mysql I have a 3 fields called username, password, and email. This page is called register.php. The code is:

Quote
<?php
$username = $_POST['name'];
$password = $_POST['pass'];

if(!$con)
{
echo "Registering is disabled right now, please check back later.";
}
else
{
echo "<form action='register.php' method='post'> <br />
Username: <input type='text' value='Username' name='user' id='user' />
Password: <input type='password' value='password' name='pass' id='pass' />
<input type='submit' value='Register' /></form>";
}

if($username=="") || ($password=="")
{
echo "Username or password is empty!";
}
else
{
mysql_select_db("mydb");

mysql_query("INSERT INTO users(username, password)
VALUES ('$username', '$password')");

mysql_close($con);
}

?>
$con is a variable from connect.php to connect to mysql db. The problem I'm having is when I load the page, it says "Username and password is empty". When I hit register, it says the same thing. So I took the "($username=="") || ($password=="")" part out and another problem had arisen. When I press register, it inserts blank fields in the database. Why is that?

username = Varchar(10) not null
password = Varchar(10) not null

Thank You for your help! :}



None.

Mar 17 2008, 3:12 am Fierce Post #55



Quote
<?php
$username = $_POST['name'];
$password = sha1($_POST['pass']);

if(!$con)
{
echo "Registering is disabled right now, please check back later.";
}
else
{
if(!$_POST['register'])
{
echo "<form action='register.php' method='post'> <br />
Username: <input type='text' value='Username' name='user' id='user' />
Password: <input type='password' value='password' name='pass' id='pass' />
<input type='submit' value='Register' name='register'/></form>";
}
else
{
if(!$username) || (!$password)
{
echo "Username or password is empty!";
}
else
{
mysql_select_db("mydb");

mysql_query("INSERT INTO users(username, password)
VALUES ('$username', '$password')");

mysql_close($con);
}
}

?>
Fixed and I included sha1 encryption.

Hey and you might want to do a check to see if the username already exists. Use:
Quote
<?php
$check1 = mysql_query("SELECT * FROM `users` WHERE `username` = '$username'");
if(mysql_num_rows( $check1 )==1)
{
echo ('Username already exists.');
}
else
{
// continue...
}
?>




None.

Mar 17 2008, 4:10 am NexY Post #56



Thanks, but can I ask you some simple questions as to what you did?

1. What kind of encryption is sha1? I was going to use md5.
2. How come php doesn't understand "(something=="")". You have removed the quotes all together.
3.
Quote
if(!$_POST['register'])
{
echo "<form action='register.php' method='post'> <br />
Username: <input type='text' value='Username' name='user' id='user' />
Password: <input type='password' value='password' name='pass' id='pass' />
<input type='submit' value='Register' name='register'/></form>";
Noticed you put $_POST['register']. How does that read the submit button? What I mean is, from the code you entered, I read "if post[register] is not true" then do the form, which makes no sense to me D:!
4. You included an else after that quote I just entered, wouldn't that mean if that form is true show the error. So what I'm thinking is, if they already filled it out?

Also I haven't gotten to SELECT and WHERE in my learning yet, but thank you for mentioning that.

Bear with me, I'm such a noob. :-(



None.

Mar 17 2008, 6:34 am Forsaken Archer Post #57



1. sha1() from 30 seconds of research is basically like md5(). They both generate hashes of strings. Neither is really encryption (and you really don't need real encryption).
2. $something="" and !$something is basically the same thing (though, with !$something, a user possibly can't have an name as simply 0. !$something just looks neater.
3. All input values are read. Having name="register" makes $_POST['register'] equal to the value of that input, which is "Register". I use this all the time in instances where I have more than one submit button (such as post preview).
4. He did it right, it's not as easy to see because of the no indents (something I need to fix ;o). I think he forgot a bracket at the end though. Triple } before ?> instead of only two.



None.

Mar 17 2008, 7:11 am NexY Post #58



Thanks for the clarification! :)



None.

Mar 17 2008, 8:59 am AfterLifeLochie Post #59



Errrrgh!! You didn't open a connection to your MySQL server.
Do this:
1. Define MySQL Data:
Quote from Code
/**
* Database Constants - these constants are required
* in order for there to be a successful connection
* to the MySQL database. Make sure the information is
* correct.
*/
<?php
$dbhost = 'YOUR HOST ADDR';
$dbuser = 'YOUR USERNAME';
$dbpass = 'USERNAMES PASSWORD'';
$dbname = 'DATABSE TO USE';
2. Connect:
Quote from Code
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
mysql_select_db($dbname);
?>

Try that!



None.

Mar 17 2008, 10:29 am Fierce Post #60



Hey IP you should create a PHP code box :P I didn't notice there was supposed to be another bracket lol.

AfterLifeLochie, I'm sure already has that setup because he has many lines saying if(!$con) and mysql_close($con).

If you need any more help NexY, I created a somewhat advanced tutorial but you should be able to understand it. If not, ask here.
click



None.

Options
Pages: < 1 2 3 4 56 >
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[06:36 pm]
RIVE -- Nah, I'm still on Orange Box.
[04:36 pm]
Oh_Man -- anyone play Outside the Box yet? it was a fun time
[12:52 pm]
Vrael -- if you're gonna link that shit at least link some quality shit: https://www.youtube.com/watch?v=uUV3KvnvT-w
[11:17 am]
Zycorax -- :wob:
[2024-4-27. : 9:38 pm]
NudeRaider -- Ultraviolet
Ultraviolet shouted: NudeRaider sing it brother
trust me, you don't wanna hear that. I defer that to the pros.
[2024-4-27. : 7:56 pm]
Ultraviolet -- NudeRaider
NudeRaider shouted: "War nie wirklich weg" 🎵
sing it brother
[2024-4-27. : 6:24 pm]
NudeRaider -- "War nie wirklich weg" 🎵
[2024-4-27. : 3:33 pm]
O)FaRTy1billion[MM] -- o sen is back
[2024-4-27. : 1:53 am]
Ultraviolet -- :lol:
[2024-4-26. : 6:51 pm]
Vrael -- It is, and I could definitely use a company with a commitment to flexibility, quality, and customer satisfaction to provide effective solutions to dampness and humidity in my urban environment.
Please log in to shout.


Members Online: Oh_Man, jjf28, RIVE