Jump to content

ruano84

Members
  • Posts

    19
  • Joined

  • Last visited

    Never

Posts posted by ruano84

  1. 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

  2. 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
  3. 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&uacute;n no has agregado art&iacute;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
  4. 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&uacute;n no has agregado art&iacute;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
  5. 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
  6. 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'; }
  7. 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
  8. 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
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.