ruano84
-
Posts
19 -
Joined
-
Last visited
Never
Posts posted by ruano84
-
-
Thanks, but its the same
-
Hi,
Im writing a php application that manage the townhouses in a resort complex. Every unit has a id, and some of them have a numeric-based id, and others an alphanumeric id.
When i call the select statement with the "order by" "asc" or "des" option, it orders the records like "win98", i mean:
101
102
103
104
10A101
10A102
10A103
110
111
112
, and not like "XP" (sorry by the names, but that's the order behavior)
101
102
103
104
110
111
112
10A101
10A102
10A103
, that i need. There is some way to fix this? i mean, without the need of braking the digits in separate columns.
Thanks for the attention, any help would be appreciated,
Atte.
Alexis Rodriguez
-
Hi, thanks for answer.
In the script i create the table and insert the data, when i select, everything is fine, like a normal table. When i select the same table with the pconnect function (it's supposed to give me a reference of the last one), sometimes output that the table doesn't exists, sometimes it selects but retrieve just the first x rows and sometimes the data is ok.
Thanks again,
Alexis RR -
sorry i write it wrong (cant instead of can), but i modified it already.
-
Hi,
This is a way to do it:
[code]
<?php
$chain="abcde?edcba";
$chr_pos=strpos($chain,"?");
$final_chain=substr($chain,0,$chr_pos);
echo $chain;
?>
[/code]
I Hope it could help you -
Hi, it must be something like this:
[code]
<?php
for($i=0;$i<10;$i++){
$chart=mysql_query('SELECT * FROM vg_charts LEFT JOIN vg_games ON vg_charts.s$i=vg_games.id WHERE type=1 ORDER BY date DESC limit 0, 1');
}
?>
[/code]
...the date procedure seems to be ok -
Hi,
I am having throuble with a temporary table. I can create it, fill it and even select it, but every time i access it, the data is corrupted. This is the code to create it:
(The query is supposed to be ?sec=xx&art=yy&cant=zz)
[code]
<?php
$ref=apache_request_headers();
setcookie("origen",$ref['Referer']);
setcookie("query",$_SERVER['QUERY_STRING']);
session_start();
if(!isset($_SESSION["nombre"])){
session_write_close();
header("location:ingresar.php"); //To the registration page
}else
{
$dbh=mysql_pconnect ("localhost", "interglo_admin") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db("interglo_Users");
$id=session_id();
parse_str($_COOKIE["query"]);
mysql_query("CREATE TEMPORARY TABLE IF NOT EXISTS cart$id (cat char(255),id int, cantidad int)");
mysql_query("INSERT INTO cart$id (cat,id,cantidad) VALUES ('$sec','$art','$cant')");
header("location:".$_COOKIE["origen"]);
}
?>
[/code]
And this is the code for access it:
[code]
<?php
session_start();
if($err==0){
$_SESSION["nombre"]=$row[0]." ".$row[1];
$_SESSION["cedula"]=$row[2];
$_SESSION["fijo"]=$row[3]."-".$row[4];
$_SESSION["cel"]=$row[5]."-".$row[6];
$_SESSION["direccion"]=$row[7];
$_SESSION["email"]=$row[8];
if(isset($_COOKIE["query"])) header("location:add.php?".$_COOKIE["query"]);
}
if($_SERVER['QUERY_STRING']=="sec=v_cart"){
$dbh=mysql_pconnect ("localhost", "interglo_admin") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("interglo_Users");
echo mysql_error();
$res=mysql_query("SELECT * FROM cart$id"); //The shopping cart
echo mysql_error();
$aff=mysql_affected_rows();
echo $id." ".$aff."<br>";
echo mysql_error();
if($aff==0){
?>
Aún no has agregado artículos a tu carro de compras.<br>
<?php
}else{
$dbh1=mysql_connect("localhost","interglo_admin");
mysql_select_db("interglo_productos"); //The products
for($i=0;$i<$aff;$i++){
$fetch=mysql_fetch_row($res);
echo $i." ".$fetch[0]." ".$fetch[1]."<br>";
$res1=mysql_query("SELECT * FROM ".$fetch[0]." WHERE id=".$fetch[1]);
echo mysql_error();
$fetch1=mysql_fetch_row($res1);
echo $fetch1[1]." ".$fetch[2]." ".$fetch[3]."<br>";
}
}
$id=session_id();
[/code]
I hope somebody can help me
Alexis RR -
Hi,
I am having throuble with a temporary table. I cant create it, fill it and even select it, but every time i access it, the data is corrupted. This is the code to create it:
(The query is supposed to be ?sec=xx&art=yy&cant=zz)
[code]
<?php
$ref=apache_request_headers();
setcookie("origen",$ref['Referer']);
setcookie("query",$_SERVER['QUERY_STRING']);
session_start();
if(!isset($_SESSION["nombre"])){
session_write_close();
header("location:ingresar.php"); //To the registration page
}else
{
$dbh=mysql_pconnect ("localhost", "interglo_admin") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db("interglo_Users");
$id=session_id();
parse_str($_COOKIE["query"]);
mysql_query("CREATE TEMPORARY TABLE IF NOT EXISTS cart$id (cat char(255),id int, cantidad int)");
mysql_query("INSERT INTO cart$id (cat,id,cantidad) VALUES ('$sec','$art','$cant')");
header("location:".$_COOKIE["origen"]);
}
?>
[/code]
And this is the code for access it:
[code]
<?php
session_start();
if($err==0){
$_SESSION["nombre"]=$row[0]." ".$row[1];
$_SESSION["cedula"]=$row[2];
$_SESSION["fijo"]=$row[3]."-".$row[4];
$_SESSION["cel"]=$row[5]."-".$row[6];
$_SESSION["direccion"]=$row[7];
$_SESSION["email"]=$row[8];
if(isset($_COOKIE["query"])) header("location:add.php?".$_COOKIE["query"]);
}
if($_SERVER['QUERY_STRING']=="sec=v_cart"){
$dbh=mysql_pconnect ("localhost", "interglo_admin") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("interglo_Users");
echo mysql_error();
$res=mysql_query("SELECT * FROM cart$id"); //The shopping cart
echo mysql_error();
$aff=mysql_affected_rows();
echo $id." ".$aff."<br>";
echo mysql_error();
if($aff==0){
?>
Aún no has agregado artículos a tu carro de compras.<br>
<?php
}else{
$dbh1=mysql_connect("localhost","interglo_admin");
mysql_select_db("interglo_productos"); //The products
for($i=0;$i<$aff;$i++){
$fetch=mysql_fetch_row($res);
echo $i." ".$fetch[0]." ".$fetch[1]."<br>";
$res1=mysql_query("SELECT * FROM ".$fetch[0]." WHERE id=".$fetch[1]);
echo mysql_error();
$fetch1=mysql_fetch_row($res1);
echo $fetch1[1]." ".$fetch[2]." ".$fetch[3]."<br>";
}
}
$id=session_id();
[/code]
I hope somebody can help me
Alexis RR -
Hi, you did forget a ";"
$result = mysql_query(" SELECT * FROM 'user' WHERE username = $appusername AND password = $apppassword ");
if (mysql_num_rows($result) > 0) {
$_SESSION["authenticatedUser"] = $appusername; -
Hi everyone,
I am building a php shopping cart system, and i'm trying to use temporary tables. All i want to know is the "lifetime" of a temporary table, i mean, with a permanent connection (mysql_pconnect), how long it'll last, and what're their limitations.
Thanks,
Alexis RR -
Have you messenger? I think it could be easier to help you in that way. My email messenger is in my profile.
-
I presume that the line:
[i]$query = "INSERT INTO $table VALUES (NULL,'$wish','$link','','','')";[/i] is outside of any function, so the problem could be in the posting.
Try to test if the index.html is posting the values to view.php. Give a name to the submit button, and at the begining of the code, write:
if($[i]buttonname[/i]){ echo 'it is posting'; }else { echo 'it isnt posting'; } -
hi,
Be sure that $_POST['first'] is giving you a value, it doesn't seems to. instead of POST use $_REQUEST['first'], and try again.
Good luck!
-
Hi,
I saw all the code and realize that there was a programming error from me. I was hashing the password 2 times inside a validation process.
Thanks for everything -
Hi,
I dont know exactly what you need , but in the clans.php there must be a form like this:
<form method="post" action="Display.php">
<input type="text" name="ID">
<input type="Submit" name="submit">
</form>
If i'm wrong, why don't you explain yourself a little better?
Alexis RR -
Hi, Thanks for answering,
The md5() function does the same thing. I think it's a problem with MySQL, but i really don't know what's the problem.
Alexis RR -
Hi,
I suggest to write this line of code after each function of mysql:
echo mysql_error();
Bye -
Hi,
I am writing an user/password validator in PHP and MySQL. I am using the function crypt() to encrypt the passwords, store them in a table, and then when the users introduce their password, retrieve the stored one and compare them. This is the code to crypt and insert the password:
$name="a name";
$password=crypt("a password");
$dbh=mysql_connect ("localhost", "user");
mysql_select_db ("DataBase");
mysql_query("INSERT INTO atable (name,password) values ('$name','$password')");
And this one is for retrieve it:
$dbh=mysql_connect ("localhost", "user");
mysql_select_db ("DataBase");
$res=mysql_query("SELECT * FROM usuarios WHERE name='a name' ");
$row=mysql_fetch_row($res);
$password=crypt("a password",$row[1]);
if($password==$row[1]) echo "yes";
if($password!=$row[1]) echo "no";
For some reason, the hash of the 2nd call to the crypt function is not returning the original, so echoes "no". What could be wrong?
Thanks,
Alexis RR
Order By statement not working as spected...
in MySQL Help
Posted
thanks, brother, thats it!!