Jump to content
xisto Community

alex1985

Members
  • Content Count

    398
  • Joined

  • Last visited

Everything posted by alex1985

  1. Help me out!!! I was trying to correct the mistake all the day, today. I can't still fix it. I'm using the tutorial in the textbook, like step-by-step guide how you make certain things. I'm putting the the experts from the textbook which makes the entire page. Probabli, there are some mistakes or I put them in the wrong order. So, I asking you to take a glance at it, and help me to create one. I will as well to make it tomorrow. Trying is one of the way of learning some certain aspects. Please, let me know as soon as possible. Thanks for you cooperation. There are experts: 1) <?phpelse: // Allow the user to enter a new joke$authors = @mysql_query('SELECT id, name FROM author');if (!$authors) {exit('<p>Unable to obtain author list from the database.</p>');}$cats = @mysql_query('SELECT id, name FROM category');if (!$cats) {exit('<p>Unable to obtain category list from the ' .'database.</p>');}?> 2) <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"><p>Enter the new joke:<br /><textarea name="joketext" rows="5" cols="45"></textarea></p> 3) <p>Author:<select name="aid" size="1"><option selected value="">Select One</option><option value="">---------</option><?phpwhile ($author = mysql_fetch_array($authors)) {$aid = $author['id'];$aname = htmlspecialchars($author['name']);echo "<option value='$aid'>$aname</option>\n";}?></select></p> 4) <p>Place in categories:<br /><?phpwhile ($cat = mysql_fetch_array($cats)) {$cid = $cat['id'];$cname = htmlspecialchars($cat['name']);echo "<label><input type='checkbox' name='cats[]' " ."value='$cid' />$cname</label><br />\n";}?></p> 5) <input type="submit" value="SUBMIT" /></form><?php endif; ?> 6) <?php$dbcnx = @mysql_connect('localhost', 'root', 'mypasswd');if (!$dbcnx) {exit('<p>Unable to connect to the ' .'database server at this time.</p>');}if (!@mysql_select_db('ijdb')) {exit('<p>Unable to locate the joke ' .'database at this time.</p>');}if (isset($_POST['joketext'])):// A new joke has been entered// using the form.$aid = $_POST['aid'];$joketext = $_POST['joketext'];if ($aid == '') {exit('<p>You must choose an author for this joke. Click ' .'"Back" and try again.</p>');}$sql = "INSERT INTO joke SETjoketext='$joketext',jokedate=CURDATE(),authorid='$aid'";if (@mysql_query($sql)) {echo '<p>New joke added</p>';} else {exit('<p>Error adding new joke: ' . mysql_error() . '</p>');}$jid = mysql_insert_id(); 7) if (isset($_POST['cats'])) {$cats = $_POST['cats'];} else {$cats = array();} 8) $i = 0; // First indexwhile ($i < count($cats)) { // While we're not at the end// process $cats[$i]++$i; // Increment to the next index} 9) $i = 0; // First indexwhile (isset($cats[$i])) { // While we're not at the end// process $cats[$i]++$i; // Increment to the next index} 10) for ($i = 0; isset($cats[$i]); ++$i) {// process $cats[$i]} 11) foreach ($cats as $catID) {// Process $catID} 12) $numCats = 0;foreach ($cats as $catID) {$sql = "INSERT IGNORE INTO jokecategorySET jokeid=$jid, categoryid=$catID";$ok = @mysql_query($sql);if ($ok) {$numCats = $numCats + 1;} else {echo "<p>Error inserting joke into category $catID: " .mysql_error() . '</p>';}}?><p>Joke was added to <?php echo $numCats; ?> categories.</p><p><a href="<?php echo $_SERVER['PHP_SELF']; ?>">Add anotherjoke</a></p><p><a href="jokes.php">Return to joke search</a></p> Finished. That the experts are given from the textbook. When I type all of it, it does not work on the server?! So, I think there is a mistake or I'm puttinng in the wrong way in the PHP file. Thanks.
  2. Guys, if do not know or do not want to do it because it does bother you, please reply something.
  3. Well, it does still give me the same message?!
  4. Oh, thanks! I think, that will work fine, if I close the PHP code tag properly. I let you know, if-not!
  5. Oh, I forgot to number the lines. The 68th line is at the end of the code which is: "<?php". Need feedback as soon as possible. Please!!!
  6. Hi, do you know what is the mistake in the following PHP code: It does give me the following message: <?php$dbcnx = @mysql_connect('localhost', 'root', 'mypasswd');if (!$dbcnx) {exit('<p>Unable to connect to the ' .'database server at this time.</p>');}if (!@mysql_select_db('ijdb')) {exit('<p>Unable to locate the joke ' .'database at this time.</p>');}if (isset($_POST['joketext'])):// A new joke has been entered// using the form.$aid = $_POST['aid'];$joketext = $_POST['joketext'];if ($aid == '') {exit('<p>You must choose an author for this joke. Click ' .'"Back" and try again.</p>');}$sql = "INSERT INTO joke SETjoketext='$joketext',jokedate=CURDATE(),authorid='$aid'";if (@mysql_query($sql)) {echo '<p>New joke added</p>';} else {exit('<p>Error adding new joke: ' . mysql_error() . '</p>');}$jid = mysql_insert_id();if (isset($_POST['cats'])) {$cats = $_POST['cats'];} else {$cats = array();}$i = 0; // First indexwhile ($i < count($cats)) { // While we're not at the end// process $cats[$i]++$i; // Increment to the next index}$i = 0; // First indexwhile (isset($cats[$i])) { // While we're not at the end// process $cats[$i]++$i; // Increment to the next index}for ($i = 0; isset($cats[$i]); ++$i) {// process $cats[$i]}foreach ($cats as $catID) {// Process $catID}$numCats = 0;foreach ($cats as $catID) {$sql = "INSERT IGNORE INTO jokecategorySET jokeid=$jid, categoryid=$catID";$ok = @mysql_query($sql);if ($ok) {$numCats = $numCats + 1;} else {echo "<p>Error inserting joke into category $catID: " .mysql_error() . '</p>';}}?><p>Joke was added to <?php echo $numCats; ?> categories.</p><p><a href="<?php echo $_SERVER['PHP_SELF']; ?>">Add anotherjoke</a></p><p><a href="jokes.php">Return to joke search</a></p><?php
  7. Thanks you guys. I will try to use yours, it seems better for me.
  8. Who know where I can obtain the tutorial "PHP and CSS"?! How to make PHP files like formating the site with CSS?!
  9. So, you mean in the table itself, I need create kind of alphabet (A-Z), then create PHP Code as well as Query, to show the songs I got from that letter.
  10. So, how do I plug such BB Codes on my site's page?!
  11. How do people make categories like the ones on the musical portals that look like ABC. The user just click the letter and then he got the list of available songs for this artists, if you know, please, let me know as well.
  12. Well, I just wanna ask you if it's good or appropriate way to encrypt the password. I checked the entry on PHPMyAdmin, and it does really encrypt the password. So, I can do that?!
  13. Can I insert like the BB Code on my site, like the one on forums as well as on portals, just click the icons above the typing field, and it will do automatically?!
  14. So, is it better to create login system with AJAX support? If yes, please indicate the tutorial.
  15. I found one tutorial how to make a complete login system which suggest to use the following SQL syntax to encrypt the password: INSERT INTO login (username,password,email,activated) value ('admin',sha1(concat('yourpasswordhere','0dAfghRqSTgx')),'youremailhere','1'); Is it appropriate or not?!
  16. I will check them on the server and clerify my questions!!!What is AJAX?
  17. Take a look of this code at: PHP Tutorials. Just explain me the info that relates to 2 of my questions...
  18. Could you explain the code: ['cmdusers'] or ['cmdlogin']?! What is the difference between them?
  19. Why do some people create different files of PHP extensions? Like the ones: db_connect.inc.php or db_connect.php?! What is the different between them? In reality, both of them have the same code.
  20. Thanks. I already so it, how encrypt the password using the MySQL sequence. Tomorrow, I will post the sequence itself.
  21. alex1985

    Winrar ??

    Thanks. I will check them out, then post the reply either working or not!
  22. Could you write the whole process how you do it from the beggining?!
  23. Thanks for your previous replies, were really helpful! How do I protect my user passwords in my database. If someone hacked the database, it was really hard for him to get passwords from that database. Please, list all good ways to do that.
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.