RON_ron
-
Posts
370 -
Joined
-
Last visited
Posts posted by RON_ron
-
-
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); ?>
-
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
-
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"].",,,"; }
-
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.
-
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))
-
Worked! Thanks mate!!
-
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);
?>
-
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); ?>
-
That's Awesome!! Thanks AbraCadaver!
-
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"].",,,"; }
-
am I in the wrong place?
-
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);
-
Could someone give me a cross-domain proxy script?
I am trying to post data to mysql databases on two servers.
-
Here's what I want to happen. The mysql date to be in this format %d %M %Y and be in $returnS
-
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);
?>
-
Thanks mates! Before trying these, Just one more thing..... Do I have to give permission to update an MYSQL?
E.g. If I'm on server 1 and using this script to update the mysql on server 1 and server 2.
-
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;
-
Basically I'm asking How can I post data at the same time to 2 mysql databases on 2 different servers?
-
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
-
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."; ?>
-
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.";
-
Great! Thank you MrAdam.
-
how can I pull in only the latest record?
-
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";
date_format
in MySQL Help
Posted
. 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!