Jump to content

RON_ron

Members
  • Posts

    370
  • Joined

  • Last visited

Posts posted by RON_ron

  1. :(. it looks all wired now... Some fields show the message 'undefined'

     

    I don't know if this is important, but in the MYSQL db I'm using the CURRENT_TIMESTAMP to add the date atuomatically in to the timestampz field. Could this have an impact to the code provided because it has got the date & time?

     

    Thanks Guys!

  2. I'm sort of sucked with this. All that I need is to get the date which is in my mysql in this format %d/%m/%Y'.

     

    I'm not getting any data when I use code A. But works perfectly when I use code B (without that date format though). I wonder if there is any error in the syntax?

     

    code A

    $query = "SELECT DATE_FORMAT(timestampz, '%d/%m/%Y') FROM news_homez ORDER BY timestampz DESC";
    $results = mysql_query($query);
    
    $returnS="";
    while($line = mysql_fetch_array($results))
    {
    $returnS.= $line["subjectz"].",,".$line["timestampz"].",,".$line["Newsz"].",,".$line["linksz"].",,,";
    }
    echo $returnS;
    mysql_close($link);
    ?>

     

    code B

    $query = "SELECT * FROM  news_homez ORDER BY timestampz DESC";
    $results = mysql_query($query);
    
    $returnS="";
    while($line = mysql_fetch_array($results))
    {
    $returnS.= $line["subjectz"].",,".$line["timestampz"].",,".$line["Newsz"].",,".$line["linksz"].",,,";
    }
    echo $returnS;
    mysql_close($link);
    ?>

  3. Thanks jayarsee!

     

    But I'm getting the following error.

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /php/test.php on line 9

  4. Doesn't seem to work though.

     

    $query = "SELECT * FROM news_homez DATE_FORMAT(timestamp,'%d/%m/%Y') ORDER BY timestampz DESC";
    $results = mysql_query($query);
    
    $returnS="";
    while($line = mysql_fetch_array($results))
    {
    $returnS.= $line["subjectz"].",,".$line[timestamp].",,".$line["Newsz"].",,".$line["linksz"].",,,";
    }

  5. Thanks. But can someone give me an quick answer... I'm in a desperate hurry!!

     

    I'm trying to pull some data from a mysql and I'm successful in it. But I need the date format changed to DD MM YYYY.

  6. how can I change the date format to DD MM YYYY?

     

    $query = "SELECT * FROM  news_home ORDER BY timestamp DESC";

    $results = mysql_query($query);

     

    $returnS="";

    while($line = mysql_fetch_array($results))

  7. I believe this is the way to achieve it but it doesn't seem to work! Any idea why is that?

     

    $SomeVar = $_POST['finco'];

    $query = "SELECT DATE_FORMAT(timestamp, '%d/%m/%Y') FROM  news_home WHERE code = '".$SomeVar."' ORDER BY timestamp DESC";

    $results = mysql_query($query);

     

    $returnS="";

    while($line = mysql_fetch_array($results))

    {

    $returnS.= $line["subject"].",,".$line["timestamp"].",,".$line["News"].",,".$line["links"].",,,";

    }

    echo $returnS;

    mysql_close($link);

    ?>

  8. I need to change the date format to DD-MM-YYYY. Please help.

     

    $SomeVar = $_POST['finco'];
    $query = "SELECT * FROM  news_home WHERE code = '".$SomeVar."' ORDER BY timestamp DESC";
    $results = mysql_query($query);
    
    $returnS="";
    while($line = mysql_fetch_array($results))
    {
    $returnS.= $line["subject"].",,".$line["timestamp"].",,".$line["News"].",,".$line["links"].",,,";
    }
    echo $returnS;
    mysql_close($link);
    ?>

  9. Thanks. This is my new code. Still I can not find BARBIE DOLLS (all records which is similar to $SomeVar). Any idea whats wrong here?

     

    $SomeVar = $_POST['fincom'];
    $query = "SELECT * FROM news_home WHERE searchwords LIKE '%".$SomeVar."%' ORDER BY timestamp DESC";
    $results = mysql_query($query);
    
    $returnS="";
    while($line= mysql_fetch_array($results))
    {
    $returnS.= $line["subject"].",,".$line["timestamp"].",,".$line["News"].",,".$line["links"].",,,";
    }

  10. I'm trying to pull in data using a particular word from a mysql db (it's like a search facility).

     

    But this code only picks if the db has got the exact same word.

    E.g. if fincom = "DALLS" it pulls the data only when "searchwords" has DALLS. It ignores if "searchwords" has BARBIE DALLS. How can I fix this. I need to pick all records which contains the search word 'fincom' anywhere in  searchwords.

     

    Hope this makes scene.

     

    $SomeVar = $_POST['fincom'];

    $query = "SELECT * FROM  news_home WHERE searchwords = '".$SomeVar."' ORDER BY timestamp DESC";

    $results = mysql_query($query);

  11. Can someone tell me what is the fault with my code?

     

    SELECT date_format(datecolumn,'%d %M %Y') as date FROM news WHERE article_id=$id

     

    $query = "SELECT * FROM  my_db ORDER BY timestamp DESC";

    $results = mysql_query($query);

     

    $returnS="";

    while($line = mysql_fetch_array($results))

    {

    $returnS.= $line["subject"].",,".$line["$id"].",,".$line["article"].",,".$line["link"].",,,";

    }

    echo $returnS;

    mysql_close($link);

    ?>

  12. :shrug: Why doesn't this code update two mysql databases (on two servers)? What am I doing wrong?

     

    //SERVER 1 
    $link = mysql_connect("localhost","usern1","pw1"); 
    mysql_select_db("db_one1"); 
    
    //SERVER 2 
    $link = mysql_connect("xxx.xxx.xx.xxx","usern2","pw2"); 
    mysql_select_db("db_one2"); 
    
    $query = "INSERT INTO db1(subject, search, News, img) VALUES('$hsubject','$key','$news','$img')"; 
    $result = mysql_query($query); 
    
    $query = "INSERT INTO db2(subject, search, News, img) VALUES('$hsubject','$key','$news','$img')"; 
    $result = mysql_query($query); 
    
    $sentOk = "The data has been added to the database."; 
    echo "sentOk=" . $sentOk; 

  13. I've got two different domains (websites). I need to post data to the mysql db on both websites just sitting on one. How can I do it? Do I need to have permission? etc...

     

    E.g. www.a.com  and  www.b.com

    I want to post data to the mysql databases using a program in www.a.com 

  14. try this

     

    <?php
    $link = mysql_connect("localhost","id","thepw");
    mysql_select_db("dbname");
    
    $query = "INSERT INTO db_name (field1, field2, field3, field4) VALUES('$data1','$data2','$data3','$data4')";
    
    $result = mysql_query($query);
    $sentOk = "The data has been added to the database.";
    ?>

  15. How can I put 2 queries using the same php script? (ie. the same values to be sent to database 1 and 2)

     

     

    $query = "INSERT INTO db_1(abc1, abc2, abc3, abc4) VALUES('$a','$b','$c,'$d')";
    $query = "INSERT INTO db_2(abc1, abc2, abc3, abc4) VALUES('$a','$b','$c,'$d')";
    
    $result = mysql_query($query);
    $sentOk = "The data has been added to the database.";

  16. I need to pull all the mysql data by the order of it's date/time . How can I write the code?

     

    I'm using this as a serverside script and I'm not a php person. But i believe the below code will not pull the data. Will it work if I remove the text marked in red?

     

    $query = "SELECT * FROM  sub_db WHERE the_code = '".$abc."'" ORDER BY timestampz ASC";

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