Jump to content

wizzkid

Members
  • Posts

    39
  • Joined

  • Last visited

    Never

Everything posted by wizzkid

  1. Hello, can you help me on my news article? I would like to be able to add photo on the article. Below is my codes Hope you guys can help me. Thanks!
  2. Also, if you guys could help me on how to add a photo on article, it will be a great help! much better if the photo will be save on the servers folder instead on database. hope you can give me an insight. Thanks!
  3. So far this is the only code I have for now. I still dont have the code for comments. ======= html ======= <?php include_once ('post_news.php'); ?> <form Action="add_news.php" Method="post"> <input name="postdate" type="text" id="postdate"> <input name="title" type="text" id="title"> <textarea name="newstext" cols="60" rows="15" id="newstext"></textarea> <input type="submit" name="submit" value="Submit"> <input type="reset" name="reset" value="Reset"> </form> ============== php - post_news.php ============== <?php ini_set ('display_errors', 1); error_reporting (E_ALL & ~E_NOTICE); if (isset ($_POST['submit'])) { require_once ('inc/dbConfig.php'); // Define the query. $query = "INSERT INTO news (id, postdate, title, newstext) VALUES (0,'{$_POST['postdate']}', '{$_POST['title']}','{$_POST['newstext']}')"; // Execute the query. if (@mysql_query ($query)) { print "<p>Data has been added.</p>"; } else { print "<p>Could add the entry because: <b>" . mysql_error() . "</b>. The query was $query.</p>"; } mysql_close(); } ?> ===== db structure ====== id int(10) unsigned NOT NULL auto_increment, postdate timestamp(14), title varchar(50) NOT NULL, newstext text NOT NULL, PRIMARY KEY (id), KEY postdate (postdate) Thanks a lot for your help guys!
  4. Hello, I am trying create a news article, but I have few category in it. Can you help me to create an "add article form" which has dropdown list of category that I can choose, so when I select "Announcement" it will save the data on my mysql database under announcement table. sample html form below. <form id="form1" name="form1" method="post" action=""> <label> Category : <select name="category" id="category"> <option>--- choose category ---</option> <option>News</option> <option>Announcement</option> <option>Sports</option> </select> </label> <br /> Date: <br /> Title: <label> <input type="text" name="title" id="title" /> </label> <br /> Body: <label> <textarea name="body" id="body" cols="45" rows="5"></textarea> </label> <br /> <label> <input type="submit" name="Submit" id="Submit" value="Submit" /> </label> <br /> <br /> </form> Can you tell me how to create the php code which support the above html. Also, I would like to have a date and time on my article, but I want it automatically get the time and date from the computer of the client, so the user will not put it manually. can you point me to the correct code? Thanks and hope you can help me!
  5. I have manage to create my own script that add news article, however, I would like to add a comment form below the news article. How can I relate the news and the comments? also, when I delete the articles, it should also delete the comments in mysql. Your help is highly appreciated!
  6. Hi! I am wondering if a font type can be uploaded and used on html. Upon designing a webpages, we/I used a specific font/s let say "arial".  and when serve to the inetrnet and somebody tried to access the site, but that user doesnt have the font use, it will automatically use its defualt text right? Is there a way to upload the specific font and put a script on the page to use the uploaded font? Please let me know how to do it Thanks a lot.
  7. Yeah! sorry it was bad.. :) I failed to put the ' ' its working now, Thanks.
  8. Hi I create this script to edit an article on my news section.. But I encounter this error Could update the entry because: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1. The query was UPDATE news SET date='2006-06-27', title='', article='' WHERE int_id=. This is my edit_news.php code [code] <?php ini_set ('display_errors', 1); error_reporting (E_ALL & ~E_NOTICE); require_once ('../include/LeePH/mysql_connect.php'); if (isset ($_POST['submit'])) { // Define the query. $query = "UPDATE news SET date='{$_POST['date']}', title='{$_POST['vc_title']}', article='{$_POST['vc_article']}' WHERE int_id={$_POST['id']}"; $r = mysql_query ($query); // Report on the result. if (mysql_affected_rows() == 1) { print '<p>The blog entry has been updated.</p>'; } else { print "<p>Could update the entry because: <b>" . mysql_error() . "</b>. The query was $query.</p>"; } } else { // Display the entry in a form. // Check for a valid entry ID in the URL. if (is_numeric ($_GET['id']) ) { // Define the query. $query = "SELECT * FROM news WHERE int_id={$_GET['id']}"; if ($r = mysql_query ($query)) { // Run the query. $row = mysql_fetch_array ($r); // Retrieve the information. // Make the form. print '<form action="edit_news.php" method="post"> <p>Entry Date: <input type="text" name="date" size="40" maxsize="100" value="' . $row['date'] . '" /></p> <p>Entry Title: <input type="text" name="title" size="40" maxsize="100" value="' . $row['vc_title'] . '" /></p> <p>Entry Text: <textarea name="article" columns="40" rows="5">' . $row['vc_article'] . '</textarea></p> <input type="hidden" name="int_id" value="' . $_GET['id'] . '" /> <input type="submit" name="submit" value="Update this Entry!" /> </form>'; } else { // Couldn't get the information. print "<p>Could retrieve the entry because: <b>" . mysql_error() . "</b>. The query was $query.</p>"; } } else { // No ID set. print '<p><b>You must have made a mistake in using this page.</b></p>'; } } // End of main IF. mysql_close(); // Close the database connection. ?> [/code] I am using these version of software: OS: Kubuntu 6.06 Dapper mySQL: MySQL 5.0.22-Debian_0ubuntu6.06-log PHP: PHP 5.1.2 Apache:Apache/2.0.55 My Database Structure int_id  - int date - date vc_title - string vc_article - string Thanks hope you can help!
  9. Hey guys, thank you so much for the help! really appreciate it a lot :)
  10. how can i declare session? can you point me where to get docs and how to do it? sorry im newbie :)
  11. Hi Guys, I made a contact form that actually the value to the specified email address. What it does is let the user verify the detail entered and send to the email and have a reciept. My problem lies on the reciept. Here's my pages http://www.leeph.net/pastebin/test/ Everything is working. contacts.php verify.php mailman.php reciept.php note: on verify.php action=mailman.php and redirect = reciept.php What I want to do is display: Thank you NAME, we will respond you at EMAIL. What I did is on reciept.php, i put: [code]<? print "Thank you".$_POST['fname']."<br>;" ?>[/code] I am not sure if its the correct syntax. I used the $_POST['fname'] on verify.php and it worked. Should you need some clarification about this setup. let me know. hoping a response to this matter. Thanks.
  12. Hi Guys, I am currently learning how to use css, on index.hml I add <LINK href="<style.css" type=text/css rel=stylesheet>  the content of my style.css is [code]A:link { FONT-SIZE: 9px; COLOR: #303030; FONT-FAMILY: Arial; TEXT-DECORATION: none } A:visited { FONT-SIZE: 9px; COLOR: #303030; FONT-FAMILY: Arial; TEXT-DECORATION: none } A:hover { FONT-SIZE: 9px; COLOR: #303030; FONT-FAMILY: Arial; TEXT-DECORATION: underline }[/code] It worked well. however, I want to have a multiple link style and color, in index.html i want to create 1. news box, 2. announcement box 3. my menu. on 1.news box, i wanted to make it blue when I hovered the link, 2. announcement, i would like to make it red when hovered.  etc. I believe it can be done using <div> but I dont know how. Can somebody tell me how to do it? :) Also, how to use <fieldset></fieldset>? :) Thanks a lot :)
  13. [!--quoteo(post=387962:date=Jun 26 2006, 03:16 AM:name=hackerkts)--][div class=\'quotetop\']QUOTE(hackerkts @ Jun 26 2006, 03:16 AM) [snapback]387962[/snapback][/div][div class=\'quotemain\'][!--quotec--] Already, hmm sorry I don't think I could help out on time. School open, and my stupid teacher giving me tons of homework. >.< I don't think I really have the time to play lolz. :s If you had any problem feel free to ask others. :D [/quote] Hi Hackerkts, Thank you so much for your help! I was able to secure my pages :) it work using session :) Thanks again!
  14. Hi Hackerkts, Thanks a lot for the help! :) you should not worry about add edit delete, I was able to do so, I am looking right now is how to protect my add edit delete page using authentication. My add edit delete page was working, i just need to have an authentication methid to protect them. As far as live demo site, I still havent upload the files to my server, its still in my local computer. :) once again thanks you :)
  15. [!--quoteo(post=387731:date=Jun 25 2006, 06:49 AM:name=hackerkts)--][div class=\'quotetop\']QUOTE(hackerkts @ Jun 25 2006, 06:49 AM) [snapback]387731[/snapback][/div][div class=\'quotemain\'][!--quotec--] >.<! It couldn't be totally empty, is that the full script in your news.php ? [/quote] which one? which >.<? no its not the full script. what I did was to use include_once($path."mysql_connect.php"); include_once($path."getNews.php"); // <-- content of this is the script, where known as news.php. Now I am looking a way to echo "sorry database empty" if the database is totally empty. otherwise, the script was working :) Also I am looking for script to protect my add_news.php and delete_news.php and edit_news.php, you might have a suggestion for this? I am looking the one with user database so the user could add account to other users which is authorized to add news to the site, however, the simply authenticaion method will do as of yet. Thanks again in advance. :)
  16. [!--quoteo(post=387650:date=Jun 24 2006, 10:43 PM:name=hackerkts)--][div class=\'quotetop\']QUOTE(hackerkts @ Jun 24 2006, 10:43 PM) [snapback]387650[/snapback][/div][div class=\'quotemain\'][!--quotec--] Do you mean when your news is totally empty then it display the words ? Try this, and I have modify abit of your script. [/quote] Yes, Thanks again for the help! :) how about for this code: (with totally empty as well) [code] <?php $news = $_GET['id']; $query = "SELECT * FROM news WHERE int_id = '$news'"; $r = mysql_query($query) or die("Query failed: " . mysql_error()); $row = mysql_fetch_assoc($r); if (!isset($_GET['id']) || $_GET['id'] == 0) {     echo "You didn't select any news.";     } else {         echo "".$row['date']."<br>";         echo "".($row['vc_title'])."<br>";         echo nl2br($row['vc_article']);     } ?> [/code] Thanks a million! :)
  17. Hi Guys, Can you tell me what is the difference betwen echo and print? and their advantage and disadvantages? :) Thanks. :)
  18. [!--quoteo(post=387551:date=Jun 24 2006, 03:29 PM:name=imhere2009)--][div class=\'quotetop\']QUOTE(imhere2009 @ Jun 24 2006, 03:29 PM) [snapback]387551[/snapback][/div][div class=\'quotemain\'][!--quotec--] Hey all guys Im a great fan of phpfreaks, and have been around here for quite some time. Now i have just started to learn php again, after many attempts, though this time im deturmined to do it. the point of this post is simple, how did you all progress when you was learning php, what i mean by that is, i am or have learned about basic variables, and variables variables, and constants, and im just starting to learn loops, etc from a video tutorial, but with php there is so much to take in, how do you keep it all fresh, so when you are learning, how did you do it so you remember things? and how did you go about creating your own programs etc. Any information regarding php and the like, would be much appreciated. Thanks steve [/quote] Hi! glad you have an interest with PHP. First you need this programs Apache(windows or Linux) or IIS (windows) PHP mySQL then I suggest you to get this book "PHP for world wide web - by Larry Ullman" I am a newbie to PHP too :) Good luck!
  19. Now, I am trying to echo something like. "sorry no data has found on the database" of the database is empty. I want to put it on this code [code] <?php ini_set ('display_errors', 1); error_reporting (E_ALL & ~E_NOTICE); $query = 'SELECT * FROM news ORDER BY date DESC'; if ($r = mysql_query ($query)) { // Run the query. while ($row = mysql_fetch_array ($r)) {     echo "<b>Date:</b> ".$row['date']."<br>";     echo "<a href='news.php?id=".$row['int_id']."'><font size = 3>".$row['vc_title']."</font></a><br><br>";     echo "<font size = 2>Reference Number: " .$row['int_id']."</font><br><hr>";     } } else { // Query didn't run.     die ('<p>Could create the table because: <b>' . mysql_error() . "</b>. The query was $query.</p>"); } // End of query IF. mysql_close(); // Close the database connection. ?> [/code] can somebody tell me how? :) thanks
  20. Hi I just fixed the script and it worked.. Here's the working code: [code] <?php $news = $_GET['id']; $query = "SELECT * FROM news WHERE int_id = '$news'"; $r = mysql_query($query) or die("Query failed: " . mysql_error()); $row = mysql_fetch_assoc($r); if (!isset($_GET['id']) || $_GET['id'] == 0) {     echo "You didn't select any news.";     } else {         echo "".$row['date']."<br>";         echo "".($row['vc_title'])."<br>";         echo nl2br($row['vc_article']);     } ?> [/code] Thanks a lot for the hellp guys :)
  21. [!--quoteo(post=387490:date=Jun 24 2006, 11:18 AM:name=hackerkts)--][div class=\'quotetop\']QUOTE(hackerkts @ Jun 24 2006, 11:18 AM) [snapback]387490[/snapback][/div][div class=\'quotemain\'][!--quotec--] Your news.php, you need to make a [b]connection to MySQL[/b]. It would be better if you put the setting in config.php, so next time you wanna connect to MySQL you just require/include that file. As for the error, I'm not very sure about it. Try to set a connect in news.php and see if the error still there. [/quote] Yes, I have included require_once('mysql_connect.php'); i just didnt include it on my post, sorry. on news.php i have: require_once('include/mysql_connect.php'); require_once('include/getnews.php') where getnews.php contains [code] <?php $news = $_GET['int_id']; $query = "SELECT * FROM `news` WHERE int_id ='$news'"; $result = mysql_query($query) or die("Query failed: " . mysql_error()); $row = mysql_fetch_assoc($r); if (!isset($_GET['int_id']) || $_GET['int_id'] == 0) {     echo "You didn't select any news.";     } else {         echo "".$row['date']."<br>";         echo "".$row['vc_title']."<br>";         echo $row['vc_article'];         } ?> [/code] any other suggestion? :)
  22. Still not working for on me :( The link on index.php is [a href=\"http://localhost/php/tnr/news/news.php?id=12\" target=\"_blank\"]http://localhost/php/tnr/news/news.php?id=12[/a] Index.php (works) [code] <?php ini_set ('display_errors', 1); error_reporting (E_ALL & ~E_NOTICE); if(!isset($_GET['more']) || $_GET['more'] == 0)     $query = 'SELECT * FROM `news` ORDER BY date DESC LIMIT 5'; if ($r = mysql_query ($query)) {          while($row = mysql_fetch_assoc($r)) {      echo "".$row['date']."<br>";     echo "<a href='news/news.php?id=".$row['int_id']."'>".$row['vc_title']."</a><br><br>";     }          } else {     die ('<p>Could create the table because: <b>' . mysql_error() . "</b>. The query was $query.</p>"); } mysql_close(); // Close the database connection. ?> [/code] Here's my news/news.php. I encounter error and it doesnt display the query. [code] <?php $news = $_GET['int_id']; $query = "SELECT * FROM `news` WHERE int_id ='$news'"; $result = mysql_query($query) or die("Query failed: " . mysql_error()); $row = mysql_fetch_assoc($r); if (!isset($_GET['int_id']) || $_GET['int_id'] == 0) {     echo "You didn't select any news.";     } else {         echo "".$row['date']."<br>";         echo "".$row['vc_title']."<br>";         echo $row['vc_article'];         } ?> [/code] error i encounter is: an error occurred in script /media/data/projects/WebApps/php/tnr/include/config.inc on line 14: Undefined index: int_idAn error occurred in script /media/data/projects/WebApps/php/tnr/include/config.inc on line 14: Undefined variable: rAn error occurred in script /media/data/projects/WebApps/php/tnr/include/config.inc on line 14: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resourceYou didn't select any news. Here's my config.inc [code] <?php error_reporting (0); // Production level error_reporting (E_ALL); // Development level function my_error_handler ($e_number, $e_message) {     $message = 'An error occurred in script ' . __FILE__ . ' on line ' . __LINE__ . ": $e_message";     echo '<font color="red" size="+1">', $message, '</font>'; // Development (print the error in red) } set_error_handler('my_error_handler'); ?> [/code] My Database is int_id = tinyint(10) vc_title = text vc_article = text date = date Thanks again and again for the help! :)
  23. [!--quoteo(post=387452:date=Jun 24 2006, 09:50 AM:name=hackerkts)--][div class=\'quotetop\']QUOTE(hackerkts @ Jun 24 2006, 09:50 AM) [snapback]387452[/snapback][/div][div class=\'quotemain\'][!--quotec--] No problem, I'm always glad to help out. If you had any problem with it, feel free to reply or drop me a msg in msn. [/quote] Okay,, thanks again :)
  24. Hi hackerkts, Thank you so much for your help! :) I will try this out. hope all get well. :) Really appreacited it a lot :) Regards, Lee
  25. Hi! I tried to put this code to /news/news.php [code] <?php require_once(mysql_connect.php); ini_set ('display_errors', 1); error_reporting (E_ALL & ~E_NOTICE);      if (!isset($_GET['news']) || $_GET['news'] == 0) {     echo "You didn't select any article.";     } else {         $_GET['news'] = $news;         $query = "SELECT * FROM news WHERE int_id ='$news'";         $r = mysql_query($query) or die("Query failed: " . mysql_error());         $row = mysql_fetch_array($r);         echo $row['date'];         echo "<p><h3>".$row['vc_title']."</h3>";         echo "".$row['vc_article']."<br /></p>";       } ?> [/code] but I its just showed my "You didnt select any article" I used this code from index.php [code] <a href=\"news/news.php?id={$row['int_id']}\">{$row['vc_title']}</a> [/code] Any comments? :) thanks and really appreciated your help!
×
×
  • 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.