Jump to content

wildteen88

Staff Alumni
  • Posts

    10,480
  • Joined

  • Last visited

    Never

Everything posted by wildteen88

  1. You'll need to set the id field to a primary key too, before setting it to auto_increment.
  2. You'll have to modify your code so it returns whatever content is based on the field rep-rangers is stored in rather than the id.
  3. After reading that article all urls are stored in the database for a particular item, I believe there is a new and an old uri stored. $request holds the current uri. You then use $request in a query to see if the requested uri is an old style uri. If it is an old style uri it'll redirect the user to the new uri for that particular item.
  4. Shouldn't do as I'm not using any MySQL5 functionality. Post the full error here. I did have a slight typo in the delete queries. Originally the queries where: DELETE * FROM ... rest of query ... The corrected queries are now DELETE FROM ... rest of query ... However just noticed something about your id field from the screenshot you posted. The extra column for the id row should be set to auto_increment.
  5. Have a look at my post in this thread for an idea
  6. mysql and mysqli are php extensions. They have nothing to do with MySQL itself. mysqli stands for mysql improved. mysqli is recommended to use with PHP5 and MySQL5. Check out php.net for the differences between the mysql and mysqli extensions. As for what storage engine to use, I generally use the default storage engine that MySQL is configured with.
  7. Run the installer with administrator privileges. Ensure that nothing is running on port 3306 (this is the default port MySQL runs on).
  8. I had this issue after removing xampp before. I just cleared by browsers cache and that done the trick for me.
  9. You should be able to decipher the OS a user is using by the string returned by the $_SERVER['HTTP_USER_AGENT'] variable.
  10. You sure? I just tested all the queries in my updated code and no errors occurred.
  11. Use: RewriteRule ^mysite\.com/([0-9]+)$ profile/profile.php?id=$1
  12. No errors in that either! Are you sure the error is comming from that file? Can you post the full error message here.
  13. Do you mean you want to implement tags? and then when you submit the form it converts the image tag to an html image tag? if so search google for bbcode tutorials.
  14. There are no errors in that code you posted.
  15. Change the following line in the printNews function: $sticky = ($news['sticky'] == 'y') ? 'STICKY: ' : null; to: $sticky = ($news['sticky'] == 'y') ? 'STICKY: ' : ''; I don't know why you're getting a space for non-sticky news. As both lines above are the same. Argh. Recopy the code from my last post. Had a few SQL errors which I corrected. You must of copied the code before I updated it.
  16. The path of the script is still going to display in the address bar once the form has been submitted.
  17. Do you have a field in your news table which holds an auto_increment key? Substitute id with that field in the following query: $query1 = "SELECT * FROM news ORDER BY id, sticky ASC"; Recoded admin part: NOTE it is untested. <?php require 'config.php'; // Make a MySQL Connection mysql_connect("$path", "$username", "$password") or die(mysql_error()); mysql_select_db("$database") or die(mysql_error()); if(isset($_POST['postnews'])) { $title = mysql_real_escape_string($_POST['title']); $news = mysql_real_escape_string($_POST['news']); // check thate status of the sticky radio button $sticky = (isset($_POST['sticky']) && $_POST['sticky'] == 'y') ? 'y' : 'n'; // Insert the news $query = mysql_query("INSERT INTO news (title, news, sticky) VALUES ('$title', '$news', '$sticky')") or die(mysql_error()); echo "<meta http-equiv='refresh' content='1'> News posted!"; } elseif(isset($_POST['delete'])) { // delete all non-sticky news if(isset($_POST['delete']['r'])) { $qry = 'DELETE FROM news WHERE sticky=\'n\''; $msg = 'All <b>non-stickied</b> news deleted!'; } // delete all stickied news if(isset($_POST['delete']['s'])) { $qry = 'DELETE FROM news WHERE sticky=\'y\''; $msg = 'All <b>stickied</b> news deleted!'; } // delete all news else { $qry = 'TRUNCATE TABLE news'; $msg = 'All news deleted!'; } // Delete it all! mysql_query($qry)or die(mysql_error()); echo "<meta http-equiv='refresh' content='1'> $msg"; } else { ?> <title>Add/Delete Recent News</title> <a href="../">Click Here to go home.</a> <form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post"> <p>Title:<br> <input type="text" name="title" /></p> <p>Text:<br> <textarea rows="10" cols="50" name="news"></textarea></p> <p>Sticky: <input type="radio" name="sticky" value="y" /> YES | <input type="radio" name="sticky" value="n" /> NO</p> <input type="submit" name="postnews" value="Post News"> </form> </form> <br><br> <h4>Options:</h4> <form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post"> <input type="submit" name="delete" value="Delete All News"> <input type="submit" name="delete[r]" value="Delete Non-Sticky News"> <input type="submit" name="delete[s]" value="Delete Sticky News"> </form> <u>Current features:</u> <br> <i>Quick Post News <br> Delete all regular news with one click <br> Delete all stickied news with one click <br> Option to title your news <br> "Sticky" News <br> Neatly displays all posted news in order from sticky to regular</i> <br><br><br> <u>Coming soon:</u> <br> <i>Ability to edit news <br> Ability to make stickied news regular and vise versa</i> <?php } ?>
  18. If you did not set a password when mysql was installed then you don't need to provide the password in the mysql_connect function. If you wish to set a password for the root account you can do so by MySQL Administrator (download from mysql.com) or you can use phpMyAdmin if you have it setup.
  19. This: oreach ($sku as $key => $value) echo $_POST['product'.$key + 1].'=>'.$productInfo[$value]['filename'].'<br />'; Should be: oreach ($sku as $key => $value) echo $_POST['product'.($key + 1)].'=>'.$productInfo[$value]['filename'].'<br />'; Whenever doing any form of arithmetic within strings always wrap it in parenthesis.
  20. Login to phpmyadmin, select your database then your news table. Make sure the Structure tab is selected. Find where it says Add [1] field(s) (note [1] is a text box). At the end of that line select Go. In the Field box type sticky Choose ENUM from the Type menu. Enter 'y','n' in the Length/Values field Select null from the Null menu Enter n in the Default field Select Save button. You should have a new column called sticky in your news table. When you browse to the Browse tab you should see all current news stored in your news table will have a sticky column with the letter n present in that column. To skicky a news entry select a row and edit it, change the sticky field to the letter y Now use the following code for displaying your news: <?php mysql_connect("***", "***", "***") or die(mysql_error()); mysql_select_db("***") or die(mysql_error()); $query1 = "SELECT * FROM news ORDER BY id, sticky ASC"; $result1 = mysql_query($query1) or die(mysql_error()); function printNews($result) { if ( mysql_num_rows($result) < 1 ) { echo "<h1>No news!</h1>"; } else { echo "<table>\n"; while($news = mysql_fetch_assoc($result)) { $sticky = ($news['sticky'] == 'y') ? 'STICKY: ' : null; echo <<<HTML <tr> <th>{$sticky}<u>{$news['title']}</u></th> </tr> <tr> <td>{$news['news']}</td> </tr> HTML; } echo "\n</table><br />"; } } printNews($result1); // none sticky news ?> EDIT: I posted the old code by mistake. New code above ^^
  21. Copy the code from Code view rather than Design view.
  22. Go to phpmyadmin and select the Privileges link. Next in the table under the User Overview heading look fo the following row: root localhost No ALL PRIVILEGES Yes To the right of that row click the Edit Privilages icon (small head with a pencil) Now Scroll down and find the Change password sub heading and ensure the Password radio button is selected. Now enter a password in the fields provided. Once you have set the password select the Go button. phpMyAdmin may prompt for your username/password again after you have made the changes.
  23. Are you sure MySQL is running? Under WAMP's control panel select Start All Services
  24. No it wont. All you need to do is just add a new field in your news table call this sticky. Set this new field to an ENUM type with possible values of Y and N sticky ENUM('y','n') NULL DEFAULT 'n' What ever news feeds you want to be stickied just set the sticky field to y. Then to retrieve stickied news from your news table just run the following query: SELECT * FROM news WHERE sticky='y' For non-stickied news run: SELECT * FROM news WHERE sticky='n' It seem pointless having two tables for news. Change: function printNews($result) { if ( mysql_num_rows($result) < 1 ) { echo "<h1>No news!</h1>"; } else { echo "<table>\n"; while($news = mysql_fetch_assoc($result)) { echo <<<HTML <tr> <td><h2><u>{$news['title']}</u></h2></td> </tr> <tr> <td>{$news['news']}</td> </tr> HTML; } echo "\n</table><br />"; } } printNews($result1); to: function printNews($result, $sn=false) { if ( mysql_num_rows($result) < 1 ) { echo "<h1>No news!</h1>"; } else { $sticky = ($sn) ? 'STICKY: ' : null; echo "<table>\n"; while($news = mysql_fetch_assoc($result)) { echo <<<HTML <tr> <th>{$sticky}<u>{$news['title']}</u></th> </tr> <tr> <td>{$news['news']}</td> </tr> HTML; } echo "\n</table><br />"; } } printNews($result1, true); // sticky news
  25. Try: <?php mysql_connect("***", "***", "***") or die(mysql_error()); mysql_select_db("***") or die(mysql_error()); $query1 = "SELECT * FROM stickynews"; $query2 = "SELECT * FROM news"; $result1 = mysql_query($query1) or die(mysql_error()); $result2 = mysql_query($query2) or die(mysql_error()); function printNews($result) { if ( mysql_num_rows($result) < 1 ) { echo "<h1>No news!</h1>"; } else { echo "<table>\n"; while($news = mysql_fetch_assoc($result)) { echo <<<HTML <tr> <td><h2><u>{$news['title']}</u></h2></td> </tr> <tr> <td>{$news['news']}</td> </tr> HTML; } echo "\n</table><br />"; } } printNews($result1); printNews($result2); ?> However a better suggestion would be to merge your news and stickynews tables into one seeing as though they are both basically the same.
×
×
  • 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.