Jump to content

aktell

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Posts posted by aktell

  1. Hi there,

     

     

    I would like to use some Css with this ECHO as I just want to have this msg look like the rest of my page.

    echo "You are being redirected to your original page request!<br>";
    echo "(If your browser doesn't support this, " .
    

    Thanks in advance aktell

  2. Hi there,

     

    I'm getting this warning ??? I just dont know what (user_login.php:11) means either. I have a config.php file included in line 11 ???.

     

    Warning: Cannot modify header information - 
    headers already sent by (output started at /home/../user_login.php:11) 
    in /home/../user_login.php on line 219
    

    This is the code the msg is reffering to.

    if (mysql_num_rows($result) == 1) {
    $_SESSION['user_logged'] = $_POST['members_id'];
    $_SESSION['user_password'] = $_POST['password'];
    header ("Refresh: 5; URL=" . $_POST['redirect'] . "");
    echo "You are being redirected to your original page request!<br>";
    echo "(If your browser doesn't support this, " .
    "<a href=\"" . $_POST['redirect']. "\">click here</a>)"
    } 
    else 
    {
    

     

     

    Thanks in advance aktell

  3. In PHP the session_start(); header must be the first line after the <?php tag. Meaning if it's included on another file it must be the first line.

     

    <?php
    session_start();
    //remove that from that file
    include('auth_userinc.php');
    ?>
    

     

    Hi there,

    Thanks alot, I found that the Session was not included in two pages and the one was as you said I got them working.

    Thanks again aktell

  4. Hi there,

     

    I'm doing code out of a book to learn and I have a small problem !

    My app. is working perfectly well, just as I go through it at some stage there is a msg comming up, and that on several pages which use the session id. I like to mention that the page shows perfectly well, just on top this msg.

     

    Warning: session_start() [function.session-start]: 
    Cannot send session cache limiter - headers already sent 
    (output started at /home/../../../auth_user.inc.php:2)
    in /home/../..//auth_user.inc.php on line 3
    

     

    The session code is below: On a Php page called auth_userinc.php.

    <?
    session_start();
    if ($_SESSION['user_logged'] == "" || $_SESSION['user_password'] == "")
    {
    $redirect = $_SERVER['PHP_SELF'];
    header("Refresh: 5;
    URL=user_login.php?redirect=$redirect");
    echo "You are currently not logged in, we are redirecting
    you, be patient!<br>";
    echo "(If your browser doesn't support this, <a
    href=\"user_login.php?redirect=$redirect\">click
    here</a>)";
    die();
    }
    else {}
    ?>
    

     

    Thanks in advance aktell

  5. That's called an Update. If the record already exists, you update it.

     

    Well, I'm feeling pretty foolish here. Sorry, I ndid not think out of the INSERT.

    $sql = "UPDATE $table_name SET f_name = '$_POST[f_name]', l_name = '$_POST[l_name]', username = '$_POST[username]', password = password('$_POST[password]')
    WHERE member_id = '$_POST[member_id]'";
    

     

    It worked strait away. Thanks alot !!!

  6. Array keys must be strings, like this:

    $_POST['f_name']

     

    What are you trying to do? You run an insert then a select - are you just trying to get the ID of the inserted member? use mysql_insert_id();

     

    Either way the two statements should be seperated.

     

    Hi there,

     

    I'm trying to INSERT certain values as f_name etc. INTO a record which already has a given ID number (member_id)

     

    aktell

  7. Hi there,

     

    The ERROR Msg is always around SELECT:

    (.. right syntax to use near 'SELECT member_id FROM ....)' at line 2)

    <?
    //********** I have the member_id included as the ONLY given value in the DB.
    if ((!$_POST[member_id]) || (!$_POST[f_name]) || (!$_POST[l_name]) || (!$_POST[username]) || (!$_POST[password])) {
    header("Location: show_adduser.htm");
    exit;
    }
    //********** code to connect etc.
    //**********
    //********** My real problem here is HOW to state the query ??? I assume that I have a bracket or comma etc. to much ???.
    $sql = "INSERT INTO $table_name (f_name, l_name, username, password)
    VALUES ('$_POST[f_name]', '$_POST[l_name]', '$_POST[username]', password('$_POST[password]'), SELECT member_id = '$_POST[member_id]' FROM $table_name)";
    //**********
    //********** OR ??
    $sql = "INSERT INTO $table_name (f_name, l_name, username, password)
    VALUES ('$_POST[f_name]', '$_POST[l_name]', '$_POST[username]', password('$_POST[password]'), 
    SELECT member_id FROM $table_name WHERE member_id LIKE member_id = '$_POST[member_id]')";
    ?>
    

     

    Thanks for any help in advance aktell ???

  8. Well this is  wrong:

     

    $artist_fullname } else {

     

    It doesn't make sense. Its not a complete statement.

     

    Just take out '$artist_fullname' and it should be ok.

     

     

    Thanks alot both ways worked. No error problem shown. But there is no print out either as yet, i will give it another try.

    Thanks again

  9. Hi there,

     

    A small problem I hope. I'm trying myself in different items out of books so I can learn more about Php and Mysql, and I came accross four different code snippets One is working and three have the same problem no correct readout.

     

    <?
    if ($artist_fn != "") {
    $artist_fullname = trim("$artist_fn $artist_ln");
    
    //************ error is in here - else - ??? ***************
    
    $artist_fullname } else {
    $artist_fullname = trim("$artist_ln");
    }
    //************************************************
    
    if ($date_acq == "0000-00-00") {
    $date_acq = "[unknown]";
    
    $display_block .= "<P><strong>$title</strong> on $rec_label,
    by $artist_fullname<br>
    $my_notes <em>(acquired:$date_acq, format:$format)</em></P>";
    }
    ?>
    

    Thanks for any help aktell

  10. Hi there,

     

    I’m in need of some real help please.

    Most likely this is nothing mayor for somebody who knows PhP well, unfortunately I’m not one of them yet.

    OK, I’m trying to simply retrieve records from a table in Mysql. Say I have around 60 to 110 rows in a table of different members each with a (FirstName, LastName and Contact) field, and I would like to show them all on a web page.

    As it is the first time I’m trying myself with table in PhP my question is, am I’m doing it right ??? Do I use the markers around the <br>, <div> and other tags in the right way ???

     

    My code I have shown below includes several different code’s which looked to me promising, well if somebody could help here so I can actually retrieve information from a specific table.

     

    Many thanks in advance to the person/s trying to help.

     

    aktell

     

    
    <?php 
    
    echo "<p align=\"center\">"; 
    
    $sort_order = 'ASC'; 
    $order_by = 'FirstName'; 
    $db_tablename = 'memberdetails'; 
    
    $db_host = 'localhost'; 
    $user = 'user'; 
    $password = 'password'; 
    $db_name = 'contactdetails'; 
    
    // Connect to Myqsl. 
    $link = mysql_connect('$db_host', '$user', '$password', '$db_name'); 
        if (!$link) { 
           die('Could not connect to Mysql: ' . mysql_error()); 
    } 
    //************ 
    //      // Check if connection was a success. (Ccould the <div> be use as below. ???) 
    //      if (!$link){ 
    //        echo '<div>Can not connect to database: '.mysql_error().' </div>'; 
    //        die; 
    //      } 
    //************ 
    
    mysql_close($link); 
    
    $result = mysql("$db_name","SELECT FirstName, LastName, Contacts FROM $db_tablename $order_by $sort_order") or die(mysql_error()); 
    
    //************ 
    // Query. 
    //$sql = ("SELECT FirstName, LastName, Contacts FROM $db_tablename $order_by $sort_order"); 
    // 
    // Perform Query. 
    //$result = mysql_query($sql); 
    //   if(!$result) error_message(sql_error()); 
    //************ 
    
    // Set table. 
    echo  ('<TR>');   
    echo  ('<TD vAlign=\"top\" width=\"990\">');  
    echo  ('<TABLE cellSpacing=\"0\" cellPadding=\"6\" width=\"90%\">'); 
    echo  ('<TR>'); 
    echo  ('<TD vAlign=\"top\" width=\"80%\">');  
    echo  ('<p> </p>'); 
    echo  ('<p> </p>'); 
    echo  ('<br>');  
    echo  ('<table width=\"535\" align=\"center\" cellPadding=\"2\" cellSpacing=\"2\">'); 
    echo  ('<tr>'); 
    echo  ('<td>'); 
    // Table header. 
    echo  ('<div align="center"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"4\" color=\"#FFFFFF\">Contact List:</font></div><br>'); 
    echo  ('<br>'); 
    echo  ('<table width=\"500\" border=\"1\" borderColorLight=\"#000000\" cellPadding=\"2\" cellSpacing=\"0\">'); 
    
    // This way. ??? ******************************************************************************************************************** ??? 
    while ($row = mysql_fetch_assoc($result)) { 
    echo  ('<tr bgcolor=\"#CCCCCC\">'); 
    echo  ('<td align=\"center\" width=\"33%\" bgcolor=\"#999999\"> echo $row['FirstName']; </td>'); // Or maybe - echo .$row0[0]. - ??? 
    echo  ('<td align=\"center\" width=\"33%\" bgcolor=\"#999999\"> echo $row['LastName']; </td>');  // Or maybe - echo .$row0[1]. - ??? 
    echo  ('<td align=\"center\" width=\"33%\" bgcolor=\"#999999\"> echo $row['Contacts']; </td>');  // Or maybe - echo .$row0[2]. - ??? 
    echo  ('</tr>'); 
    
    echo  ('<tr bgcolor=\"#CCCCCC\">'); 
    echo  ('<td align=\"center\" width=\"25%\" bgcolor=\"#999999\"> echo $row['FirstName']; </td>'); 
    echo  ('<td align=\"center\" width=\"25%\" bgcolor=\"#999999\"> echo $row['LastName']; </td>'); 
    echo  ('<td align=\"center\" width=\"25%\" bgcolor=\"#999999\"> echo $row['LastName']; </td>'); 
    echo  ('</tr>'); 
    
    // Or this way. ??? **************************************************************************************************************** ??? 
    $query_data = mysql_fetch_array($result); { 
    
    $firstname = $query_data["FirstName"]; // ??? 
    $lastname = $query_data["LastName"]; // ??? 
    $contacts = $query_data["Contacts"]; // ??? 
    
    echo  ('<tr bgcolor=\"#CCCCCC\">'); 
    echo  ('<td align=\"center\" width=\"33%\" bgcolor=\"#999999\"><?php echo $firstname; ?></td>'); // Or maybe - <?php echo $firstname = $query_data["FirstName"]; ?> - ??? 
    echo  ('<td align=\"center\" width=\"33%\" bgcolor=\"#999999\"><?php echo $lastname; ?></td>');  // Or maybe - <?php echo $lastname = $query_data["LastName"]; ?> - ??? 
    echo  ('<td align=\"center\" width=\"33%\" bgcolor=\"#999999\"><?php echo $contacts; ?></td>');  // Or maybe - <?php echo $contacts = $query_data["Contacts"]; ?> - ??? 
    echo  ('</tr>'); 
    
    echo  ('<tr bgcolor=\"#CCCCCC\">'); 
    echo  ('<td align=\"center\" width=\"25%\" bgcolor=\"#999999\"><?php echo $firstname; ?></td>'); 
    echo  ('<td align=\"center\" width=\"25%\" bgcolor=\"#999999\"><?php echo $lastname; ?></td>'); 
    echo  ('<td align=\"center\" width=\"25%\" bgcolor=\"#999999\"><?php echo $lastname; ?></td>'); 
    echo  ('</tr>'); 
    
    echo  ('</table>'); 
    echo  ('</td>'); 
    echo  ('</tr>'); 
    echo  ('</table>'); 
    } 
    } 
    
    mysql_free_result($result); 
    
    ?> 
    
    
    Below some other ideas ! But I would not know how to addapt IF. 
    ********************************************************************************* 
    
    <?php 
    include "./common_db.inc"; 
    $link_id = db_connect(); 
    $result = mysql_list_fields("sample_db", "user", $link_id); 
    
    for($i=0; $i < mysql_num_fields($result); $i++ ) { 
       echo mysql_field_name($result,$i ); 
       echo "(" .  mysql_field_len($result, $i) . ")"; 
       echo " - " . mysql_field_type($result, $i) . "<BR>"; 
       echo " " . mysql_field_flags($result, $i) . "<BR>"; 
    } 
    ********************************************************************************* 
    
    while ($row = mysql_fetch_row($result)) { 
    
    // added code to use the tablename and select all records from that table 
    echo ('Table ' . $row[0] . 'br /><table>'); 
    $sql="select * from " . $row[0]; 
    
    $result2 = mysql_query($sql) or die ('SQL problem selecting from table'); 
    if (mysql_num_rows($result2) >= 1){ 
    echo ('<tr>');  
    
    while ($row2 = mysql_fetch_row($result2)) { 
    for ($i=0; $i<mysql_num_fields($result2), $i ++){ 
    echo ('td>' . $row2[$i] . '</td>'); 
    } 
    } 
    echo ('</tr>');  
    } else { 
    echo ('<tr><td colspan="999">No records for table' . $row[0] . '</td></tr>');  
    } 
    echo ('</table>'); 
    
    mysql_free_result($result2); 
    } 
    ********************************************************************************* 
    
    

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