Jump to content

westman

Members
  • Posts

    600
  • Joined

  • Last visited

Posts posted by westman

  1. Last piece of the puzzle.
    I have coded everything and It works well apart from one aspect "JavaScript in php" the title of this post.

    this is what I have.
     

    $text = strip_tags($text);
    $text = str_replace("`", "\'", $text);
    $text = str_replace("'", "\'", $text);
    $text = str_replace('"', "\'", $text);
    $text = preg_replace("/[\n\r]/","<br />",$text);
    
    $text_div = $text;
    
    $subject_all_show .= '
    <div align="left" style="background-color:#FFF;">
    
    <div class="link_black" style="padding-top:10px; padding-left:5px; float:left;">
    <a href = "javascript:void(0)" onclick = "document.getElementById(\'mail\').style.display=\'block\';document.getElementById(\'fade\').style.display=\'block\';document.getElementById(\'subject\').innerHTML=\''.$subject.'\';document.getElementById(\'mail_text\').innerHTML=\''.$text_div.'\';">subject</a>
    </div>
    <div style="float:right; padding-top:10px; padding-right:5px;">
    date
    </div>
    <div style="clear:both;"></div>
    
    </div>
    <br />
    ';

    This works fine.

    but when I change
    $text_div = $text;
    to
    $text_div .= '
    <div style="clear:both;"></div>
    '.$text.'
    </div>';
    There is a problem.
    How do I fix it as I need to add css to different divs in the while loop. 

     

     

  2. Thank you.
    Then I am going to use 1 php file (main page) to do all the work.
    There will be no page reloading as I am looping everything from the DB. first loop is message subject and inside that loop is a sub-loop to get the messages of all subjects.
    I am sacrificing page load time for not reloading the page.  

  3. Before I go ahead and start coding this I need some advice on functionality.
    I don't know if I should run everything from my main page or use AJAX to call on a second php file.

    So this I what I am programming.
    An inbox page like google. 

    From pic1.PNG you can see my layout.
    Once you click on the subject a div will show with the message history.

    I will be taking all the info from my DB and creating more divs in php to dynamically echo to the popup div.
    The problem...
    JavaScript does not like my content ie ' " and line brakes.
    If I have a second php file using AJAX would it work better?   

    pic1.PNG

  4. the idea is this

    $id1 = '123';
    $id2 = '123';
    $text ='
    <a class="link" href = "javascript:void(0)" onclick = "document.getElementById(\'test.php\').innerHTML=\''.$id1.'\';document.getElementById(\'test.php\').innerHTML=\''.$id2.'\';">Text</a>
    ';

    then test.php will echo back information to the main page.

  5. $string = 'Hello and hi';
    $text ='
    <a class="link" href = "javascript:void(0)" onclick = "document.getElementById(\'text_div\').innerHTML=\''.$string.'\';">Text</a>
    ';

    This is code I am using to print $string in text_div.
    What syntax (characters) can I not pass through this script?

  6. I put mysite/public_html/scripts/cron_day.php in my browser to run the code.
    It worked with no problem.
    I even looked for errors with this code

    error_reporting(E_ALL); 
    ini_set('display_errors', '1');

    There are no errors with the php file.
    The cron job itself is not working.
    Why?

  7. Hi there,
    I made a cron job on godaddy and it worked for the first two days and now it is no longer working.
    Here is my code.

     

    0 10 * * * /usr/local/bin/php -q /home/mysite/public_html/scripts/cron_day.php

     

    Why did it stop working?
    What did I do wrong?

  8. then, would this work?

    $Db1 = "1";
    $Db2 = "2";
    $Dbseen = "yes";
    
    $stmt = $conn->prepare("SELECT id, user, title, date, show_post FROM post WHERE show_post = ? AND seen = ? OR show_post = ? AND seen = ? ORDER BY id DESC");
    $stmt->bind_param("ssss", $Db1, $Dbseen, $Db2, $Dbseen);

    ???

  9. as I would like to use AND and OR together, would this work?

    $Db1 = "1";
    $Db2 = "2";
    $Dbseen = "yes";
    
    $stmt = $conn->prepare("SELECT id, user, title, date, show_post FROM post WHERE show_post = ? AND seen = ? OR show_post = ? AND seen = ? ORDER BY id DESC");
    $stmt->bind_param("sss", $Db1, $Dbseen, $Db2);

     

  10. how do I use "OR" in MySQLi?

    Here is what I have

    $i = 0;
    $Db1 = "1";
    $Db2 = "2";
    $stmt = $conn->prepare("SELECT id, user, title, date, show_post FROM post WHERE show_post = ? ORDER BY id DESC");
    $stmt->bind_param("s", $Db1);
    $stmt->execute();
    $stmt->store_result();
    //if($stmt->num_rows === 0) exit('No rows');
    $stmt->bind_result($idRow, $userRow, $titleRow, $dateRow, $showRow);
    while ($stmt->fetch()) {
    $post_id[] = $idRow;
    $user[] = $userRow;
    $title[] = $titleRow;
    $date[] = $dateRow;
    $post_show[] = $showRow;
    $i++;
    // run a while loop
    }
    $stmt->close();
    $conn->close();

    I would like to use OR to look for
    $Db1 = "1";
    $Db2 = "2";
    in my DB.
    How do I use OR?

     

  11. It will not show me the error message.

    There is more than one of the same email in the data base.

  12. My code is not working, here it is...

    $stmt = $conn->prepare("SELECT id FROM users WHERE email = ?");
    $stmt->bind_param("s", $email);
    $stmt->execute();
    $numRows = $stmt->num_rows;
    $stmt->close();
    if($numRows > 0) {	
    $error = "Your Email is already in use. Please try another.";
    $conn->close();
    }else{
    // all good
    $conn->close();
    }

    any help?

×
×
  • Create New...