Jump to content

wildteen88

Staff Alumni
  • Posts

    10,480
  • Joined

  • Last visited

    Never

Posts posted by wildteen88

  1. this is also not working correct i get the success  and then die('Δεν έγινε η σύνδεση με την βάση δεδομένων'.mysql_error());

    both times even i put a existing travel_id and even i put a not existing travel_id

    I have not modified your code. I have suggested that use the mysql_affected_rows() function when checking to see if your query has deleted a record from your database.

  2. This code

    if ($_POST[submit]){
      foreach ($_POST[check] as $key => $value) {
           
           $checkup = $_POST['check'][$key];
                 
       
       
    $q =  "DELETE * FROM  pictures WHERE id ='".$row['id']."'";
    $sql = mysql_query($q) or die("Problem with the query: $q<br>" . mysql_error());}
    }

    needs to be

        if (isset($_POST['delete_images']))
        {
            if(is_array($_POST['check']))
            {
                $ids = implode(',', $_POST['check']);
    
                $q =  "DELETE * FROM  pictures WHERE id = IN($ids)";
                $sql = mysql_query($q) or die("Problem with the query: $q<br>" . mysql_error());
    
            }
    }

     

    And name your delete images button

    <input type="submit" name="delete_images" value="delete images" />

  3. This code here is correct

    <?php
    
    $con=mysql_connect("localhost","developer","javalab");
    mysql_query("SET NAMES UTF8");
    if(!$con)
    {
       die('Δεν έγινε η σύνδεση με την βάση δεδομένων'.mysql_error());
    }
    $tID = $_POST["tID"];
    mysql_select_db("cycladestravel", $con);
    $result = mysql_query("delete from `travels` where `travel_id`='$tID' limit 1",$con);
    @mysql_close($conn);
    if(!$result){
    echo 'error';
    }else{
    echo 'success';
    }

    You need to use mysql_affected_rows to check whether the query actually deleted a row from your database.

    This line

    if(!$result){

    Will only check to see if mysql_query did not return false. mysql_query will only return false when there is a problem with the query.

  4. No that code is to be used in a command shell for defining the symlink.

     

    You first need to open a command terminal move to the directory where you want the symlink and then run the command requinix suggested. Next add Options +FollowSymLinks to a .htaccess file in the public/ directory,

  5. I don't understand why you can't define the variables, then include the heredoc.  Which would parse all of the variables that have been defined.

    You can do that. Just make sure the heredoc statement is included after you have defined the variables.

  6. I created a PHP script to do this, and included it in my HTML page in this manner:

    <form action="procSomeForm.php" method="post">
        <?php
              include "genSelectList.php";
        ?>
       <input class="main" type="submit" name="submit[view]" value="View" style="width:70px"/>
    </form>

    Make sure that code is placed within a .php file. PHP code will not run within .html files.

  7. You have place the code coolcam262 suggested in wrong place. The if (mysql_num_rows($sql) > 0){ line should go before the while loop

     

    Change

         while ($row = mysql_fetch_array($sql)){
        echo 'box_num: '.$row['box_number'];
        echo '<br/> dept: '.$row['Department'];
        echo '<br/> company: '.$row['Company'];
        echo '<br/> status: '.$row['status'];
            echo '<br/> location: '.$row['location'];
        echo '<br/> description: '.$row['box_desc'];
             
             if (mysql_num_rows($sql) > 0){
    }
    
    else{
       echo 'No Boxes available please use your back button to select a new box.';
    }
             echo '<br/><br/>';
        } 

     

    To

    if (mysql_num_rows($sql) > 0)
    {   
        while ($row = mysql_fetch_array($sql))
        {
        echo 'box_num: '.$row['box_number'];
        echo '<br/> dept: '.$row['Department'];
        echo '<br/> company: '.$row['Company'];
        echo '<br/> status: '.$row['status'];
            echo '<br/> location: '.$row['location'];
        echo '<br/> description: '.$row['box_desc'];
        }
    }
    else
    {
       echo 'No Boxes available please use your back button to select a new box.';
    }

     

  8. specifically built to clean out empty records.

    If you're validating your data correctly before it is inserted into the database then you shouldn't need to do this.

     

    If you want to make your code a function then do this

    function deleteEmptyRecords($dbname)
    {
    $sql="DELETE FROM ".$dbname." . property WHERE property . id=''";
    mysql_query($sql) or die("<b>A fatal MySQL error occured</b>.\n<br />Query: " . $sql . "<br />\nError: (" . mysql_errno() . ") " . mysql_error());
    
    $sql="DELETE FROM ".$dbname." . agents WHERE agents . ip_source=''";
    mysql_query($sql) or die("<b>A fatal MySQL error occured</b>.\n<br />Query: " . $sql . "<br />\nError: (" . mysql_errno() . ") " . mysql_error());
    
    $sql="DELETE FROM ".$dbname." . settings WHERE settings . prop_id=''";
    mysql_query($sql) or die("<b>A fatal MySQL error occured</b>.\n<br />Query: " . $sql . "<br />\nError: (" . mysql_errno() . ") " . mysql_error());
    }

     

    Call it using

    deleteEmptyRecords($dbname);

     

  9. all i want to do is somehow sort

    Sort by what?

     

    get only the first row

    If you're wanting to get the first record that is closet to KMS 201 Then just use LIMIT 1 rather than LIMIT 0, 30

    $query = 'SELECT * FROM `fares`WHERE `KMS` >=201 LIMIT 1';
    $result = mysql_query($query);

  10. Line 11 should read

    $ms = mysql_pconnect($host, $user, $pass);

    You left of the $ before the 'host'.

     

    You then edit these variables

    $host = "localhost";
    $user = "UserName";
    $pass = "Password";
    $db = "dbName";

    With your database credentials. You can leave $host at it is.

×
×
  • 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.