MySQL and php problem
Moderator: General Moderators
MySQL and php problem
Hello, I really need help, I was all day trying to figure it out about a php code not working and, now that I finaly know where is the error, I have no idea why is happening!!, please help.
well I am using an mysql_query($mysql_sentence) to insert a value on a table, the thing worked, but when I saw in phpmyadmin, there were to columns instead of one, the first one with the value I wanted and the second one empty. aftyer serching where the error was, it wasn't at all in the php code, it was on the <style> code before I even started all the php code. here I post all that is making the error, becouse when I take thisaout of my code everything works just fine. I have no idea what has this to do with the php or mysql code, but somehow is messing the thing up.
<!--
BODY
{
scrollbar-base-color: 386898;
scrollbar-arrow-color: FFFFFF;
FONT-FAMILY: Verdana, Arial, Helvetica;
font-size: 12px;
background-color: #204080;
background-image: url("");
}
A:link
{
TEXT-DECORATION: none;
color: 00ff00;
}
A:visited { TEXT-DECORATION: none; color: 00ff00 }
A:active { TEXT-DECORATION: none; color: 00ff00 }
A:hover { TEXT-DECORATION: none; color: red}
.texto
{
color: #444444;
font-family: Verdana, Arial, Helvetica;
font-size: 12px;
}
.tabla_boton
{
background-color: #386898;
color: #ffffff;
border-bottom: #223F5A 1px outset;
border-left: #528BC0 1px outset;
border-right: #223F5A 1px outset;
border-top: #528BC0 1px outset;
font-family: verdana, tahoma, arial;
font-size: 12px;
height: 20px;
font-weight: bold;
cursor: pointer;
}
//-->
I will aprecciate any help
well I am using an mysql_query($mysql_sentence) to insert a value on a table, the thing worked, but when I saw in phpmyadmin, there were to columns instead of one, the first one with the value I wanted and the second one empty. aftyer serching where the error was, it wasn't at all in the php code, it was on the <style> code before I even started all the php code. here I post all that is making the error, becouse when I take thisaout of my code everything works just fine. I have no idea what has this to do with the php or mysql code, but somehow is messing the thing up.
<!--
BODY
{
scrollbar-base-color: 386898;
scrollbar-arrow-color: FFFFFF;
FONT-FAMILY: Verdana, Arial, Helvetica;
font-size: 12px;
background-color: #204080;
background-image: url("");
}
A:link
{
TEXT-DECORATION: none;
color: 00ff00;
}
A:visited { TEXT-DECORATION: none; color: 00ff00 }
A:active { TEXT-DECORATION: none; color: 00ff00 }
A:hover { TEXT-DECORATION: none; color: red}
.texto
{
color: #444444;
font-family: Verdana, Arial, Helvetica;
font-size: 12px;
}
.tabla_boton
{
background-color: #386898;
color: #ffffff;
border-bottom: #223F5A 1px outset;
border-left: #528BC0 1px outset;
border-right: #223F5A 1px outset;
border-top: #528BC0 1px outset;
font-family: verdana, tahoma, arial;
font-size: 12px;
height: 20px;
font-weight: bold;
cursor: pointer;
}
//-->
I will aprecciate any help
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Hi me again,
to bluenote or anyone willing to help please go to this site,
http://akarelov.myserver.org/~medievo/web/
and you will se a copy of all the code in .txt format.
the program start with juego1.php (that in that site is called juego1.txt)
well, hope you help me I will thank for any help!!
to bluenote or anyone willing to help please go to this site,
http://akarelov.myserver.org/~medievo/web/
and you will se a copy of all the code in .txt format.
the program start with juego1.php (that in that site is called juego1.txt)
well, hope you help me I will thank for any help!!
Hi KarSec,
i have visited the page, but instead of seeing the textfile i got a login screen. Please post the script which has not worked in combination with your style sheets here.
Normally, style sheets can only mess up the browser output but not disturb the PHP scripting action. If you got two db entries by one insert action, and one of them is empty, it sounds more like that the insert query is somehow executed twice - the second time without the vars from your form or whatever.
Have you got any redirect - feutures in your script or can anyone hit the back button?
To control if the insert query works really without errors, you could add
to your script.
Greez,
- bluenote
i have visited the page, but instead of seeing the textfile i got a login screen. Please post the script which has not worked in combination with your style sheets here.
Normally, style sheets can only mess up the browser output but not disturb the PHP scripting action. If you got two db entries by one insert action, and one of them is empty, it sounds more like that the insert query is somehow executed twice - the second time without the vars from your form or whatever.
Have you got any redirect - feutures in your script or can anyone hit the back button?
To control if the insert query works really without errors, you could add
Code: Select all
<?php
= mysql_query($uquery) or die(mysql_error());
?>Greez,
- bluenote
Hi,
i worked out how to get yout files...
If i am right, this one is the form which sends the vars to the insert query (registrarse.txt):
And this one IS the insert query (registrarse2.txt):
Assuming that your db connection (Host, Username, Pass etc.) is working, what is insert_query 1 and what is insert_query 2?
Just try and replace the whole thing
with this:
Should work.
Greez,
- bluenote
i worked out how to get yout files...
If i am right, this one is the form which sends the vars to the insert query (registrarse.txt):
Code: Select all
<?php
<form method="POST" action="registrarse2.php">
Nickname: <input type="text" name="nick"><br>
Password: <input type="password" name="pass"><br>
<input type="submit" value="REGISTRAR">
</form>
?>Code: Select all
<?php
$nick = $_POST['nick'];
$pass = $_POST['pass'];
//asigna y las agrega a mysql
mysql_connect($SERVIDOR, $USER_ADMIN, $PASS_ADMIN);
// Abrimos la Base de datos de usuarios
mysql_select_db($BD_USUARIOS);
echo $BD_USUARIOS;
// le damos el nick y el pass
$sr = "INSERT INTO usuarios ( nickname , password ) VALUES ('$nick', '$pass')";
// Subimos los valores a la Base de datos "usuarios"
mysql_query("INSERT INTO usuarios ( nickname , password ) VALUES ('$nick', '$pass')");
?>Just try and replace the whole thing
Code: Select all
<?php
$sr = "INSERT INTO usuarios ( nickname , password ) VALUES ('$nick', '$pass')";
// Subimos los valores a la Base de datos "usuarios"
mysql_query("INSERT INTO usuarios ( nickname , password ) VALUES ('$nick', '$pass')");
?>Code: Select all
<?php
$query = "INSERT into usuarios (nickname, password)";
$query = $query."VALUES('$nick', '$pass')";
$erg = mysql_query($query) or die(mysql_error());
?>Greez,
- bluenote
Hi, fist of all thank for helping me so much.
this code:
whas actually a mistake, at first it was like this:
but then I changed it to see if it would work with the code before, well it didn't with both, your code is actually similar to this one, and it didn't worked either. i really have no idea what is wrong.
try to work the program by yourself and you will see that the code actually works, but some how it makes it 2 times instead of one, and the second value on the table will be empty!.
thanks a lot.
PD: why couldn't you enter to the site at first??
this code:
Code: Select all
<?php
$sr = "INSERT INTO usuarios ( nickname , password ) VALUES ('$nick', '$pass')";
// Subimos los valores a la Base de datos "usuarios"
mysql_query("INSERT INTO usuarios ( nickname , password ) VALUES ('$nick', '$pass')");
?>Code: Select all
<?php
$sr = "INSERT INTO usuarios ( nickname , password ) VALUES ('$nick', '$pass')";
// Subimos los valores a la Base de datos "usuarios"
mysql_query($sr);
?>try to work the program by yourself and you will see that the code actually works, but some how it makes it 2 times instead of one, and the second value on the table will be empty!.
thanks a lot.
PD: why couldn't you enter to the site at first??