Jump to content

delphi123

Members
  • Posts

    94
  • Joined

  • Last visited

    Never

Everything posted by delphi123

  1. oh damn, just realised I'm connected to the dev database, not the one I though I was - so there are no articles newer than a week! Feel free to all hit the 'pound the idiot forum poster' button! (hey that'd be a great feature to these forums ;o) )
  2. I've also tried setting the date through php, but that's doing the same thing: $query="SELECT * FROM jos_content WHERE publish_up <= '".date("Y-m-d",mktime(0,0,0,date("n"),date("j")-7,date("Y")))."' ORDER BY jos_content.publish_up DESC"; echo "<h3>This query returns:</h3>"; echo $query; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); echo "<h3>Query Returns:</h3><table>"; $i=0; while ($i < $num) { $title=mysql_result($result,$i,"title"); $publish_up=mysql_result($result,$i,"publish_up"); echo "<tr><td>$title</td> <td>$publish_up</td></tr>"; $i++; } Very strange... Here's the first line of the two columns: $title = Artbeats: royalty-free stock footage / varchar $publish_up = 2009-10-14 18:12:56 /datetime
  3. Hi Mchl, Yeah had tried it with DATE_ADD originally, but it's still doing the same thing... So I've now got: SELECT jos_content.title, jos_content.introtext, jos_content.id, jos_content.publish_up, jos_content.hits, jos_content.catid, jos_content.sectionid, jos_content.state FROM jos_content WHERE DATE_ADD(now(),interval -7 day) > jos_content.publish_up ORDER BY jos_content.publish_up DESC
  4. Any ideas what's wrong with this? SELECT jos_content.title, jos_content.introtext, jos_content.id, jos_content.publish_up, jos_content.hits, jos_content.catid, jos_content.sectionid, jos_content.state FROM jos_content WHERE jos_content.publish_up + interval 7 day < now() ORDER BY jos_content.publish_up DESC I'm trying to get articles published in the last week, but it's either returning everything or nothing depending which way I put the greater/less than in the WHERE statement (have tried both)...
  5. great stuff, thanks!
  6. Hi folks, Am really struggling with this one, I've got a single table (out of my control unfortunately) which has data stored in it, two fields I need are site url and site description, these are identified by their ids of 18 and 19 respectively as you can see in this screenshot: Now I'm trying to join these values as new columns to another table, but it's just not working I can get one working fine, just not both, can anyone help? SELECT urldb.data_txt, descdb.data_txt, jos_sobi2_item.title FROM jos_sobi2_fields_data AS urldb ON urldb.fieldid = 18 Inner Join jos_sobi2_fields_data AS descdb ON descdb.itemid = urldb.itemid AND urldb.fieldid = 19 Inner Join jos_sobi2_item ON urldb.itemid = jos_sobi2_item.itemid
  7. <doh!> Sorry - asp slipping back in! Thanks very much!
  8. Hi folks, have got this code: $id=mysql_result($result,0,"itemid"); $title=mysql_result($result,0,"title"); $thumbnail=mysql_result($result,0,"data_txt"); $publish_up=mysql_result($result,0,"publish_up"); $hits=mysql_result($result,0,"hits"); echo $title; ?> <h2> <a href="#"> <?php $title; ?> </a> </h2> This is a simplified version, but the second use of $title doesn't work at all, just returns blank, whereas the first does? Is there some rule about variables being lost across <?php ?> tags or something?
  9. heh, well that's the point I thought the 'I' in IDE was for integrated! I'm looking for an application environment that pulls it all together to save me jumping from one to another (besides phpmyadmin's pretty clunky compared to a rich client)
  10. Hi folks, Have come from a Visual Studio background and I'm trying to find a php IDE that let's me manage my database. The best I've found is eclipse, but that doesn't appear to let me insert, delete, change primary keys etc in my db - only view or edit data. Can anyone point me in the right direction? This seems like a relatively simple feature, but I can't find anything!
  11. Hi all, I'm needing to create a script that will search through all directories on my site and list all files with timestamps more recent than x days. (I'm wanting to use it as a way of monitoring files that are added to check that the site is secure) Can anyone give me a few pointers as to useful functions or whether this is possible in php?
  12. that's strange - so I'd normally have a form on a page that sends the data in post to a 'processing' page which then bounces the user back to the original page. Would you normally use the header option for this? (or is there some other method entirely in php?)
  13. When I'm coding asp/.net I frequently want to redirect users after I've run some code - eg for a news posting system I'd have a form send to an asp page that'd insert to the database and then redirect them back where they were. Can anyone tell me what the command is for php? Have dug around, but most redirects seem to be limited to 301-style execution (ie at top of the page before code)
  14. :-[ :-[ :-[ :-[ :-[ :-[ Oh dear! How stupid am I, forgot that I'd made a specific field selection in my sql request in the include file (soit was only grabbing those specific columns, rather than *). All works lovely now and I'm no longer pulling my hair - but apologies for wasting your time with such a stupid mistake! Your debugging idea to dump the database records is a great one though and I'll be sure to use it in future! Thanks very much for your amazingly quick and patient help!
  15. that's what's strange - it definitely does - I'm viewing the values in phpmyadmin!?
  16. hmm that still returns the same errors - the text fields come through fine but id and status cause the errors
  17. Hi folks, On the code below it's all working great, except certain columns stored in the db return an error, eg: Notice: Undefined index: id in C:\wamp\www\news\index.php on line 23 The only wild guess I can make is that these appear to be related to integers and/or these columns not have collation set? Can anyone help me fix this? while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "<tr><td valign='top'><a href='{$row['id']}'>{$row['title']}</a><br>" . "<span style='font-size:10px'>{$row['text']}</span></td>" . "<td valign='top'>{$row['status']}</td>" . "</tr>"; }
  18. great explanations folks! Thanks very much!
  19. great help folks! Thanks very much - could I ask what do the { } brackets do exactly? Having come from asp it's all fairly familiar, so had tried the sql statement with quotes around the values, but it spat an error - didn't realise I needed to also curly bracket them - have seen the curly brackets being used elsewhere so would be great to have an explanation!
  20. Hi, I'm creating an incredibly simple script to insert values into a database as a test to get used to php, however I'm baffled as to why the following script doesn't work - it all seems fine and I get no errors, except the title, description and link text are inserted blank into the database. On submit new table rows are created, just nothing comes through! Any ideas? news.php <?php $username = "root"; $password = ""; $hostname = "localhost"; //connection to the database $dbhandle = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); //select a database to work with $selected = mysql_select_db("newsmanagement",$dbhandle) or die("Could not select database"); //execute the SQL query and return records $result = mysql_query("SELECT * FROM articles"); //fetch tha data from the database echo "<ul>"; while ( $row = mysql_fetch_array($result)) { echo "<li><a href='article.php?id=".$row{'newsid'}."'>".$row{'title'}."</a></li>"; } echo "</ul>"; //close the connection mysql_close($dbhandle); ?> <form action="news_insert.php" method="post" enctype="text/plain"> <table> <tr> <td>News Title: </td><td><input type="text" name="title"></td> </tr> <tr> <td>News Description: </td><td><input type="text" name="description"></td> </tr> <tr> <td>News Link: </td><td><input type="text" name="link"></td> </tr> </table> <input type="submit" value="Submit news"> </form> news_insert.php <?php $username = "root"; $password = ""; $hostname = "localhost"; //connection to the database $con = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); mysql_select_db("newsmanagement", $con); $sql="INSERT INTO articles ( title, description, link ) VALUES ( '$_POST[title]', '$_POST[description]', '$_POST[link]' )"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 record added"; mysql_close($con) ?>
  21. ah, navicat seems much less stone age! Thanks for the tip!
  22. Hi - I've come from asp and .net development where there's a really nice excel-like interface for building, editing and creating tables in SQL. Can anyone point me towards software that works in a similar fashion for mySQL? It just seems incredibly slow developing with a clunky web interface and the only alternative I've seen is going back to black-screens and console!
  23. Hi folks, need some brains around this - am needing to produce a script which will make a list of any visit to my site that finds a deadlink. Was thinking I could use the .htaccess to display a custom 404 message which adds a line to a database - but can anyone tell me how to get the url of the page they were trying to visit? (or if there's a smarter way of doing this let me know! Haven't got access to the server logs unfortunately!)
×
×
  • 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.