alex1985
Members-
Content Count
398 -
Joined
-
Last visited
Everything posted by alex1985
-
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.
-
Guys, if do not know or do not want to do it because it does bother you, please reply something.
-
Well, it does still give me the same message?!
-
Oh, thanks! I think, that will work fine, if I close the PHP code tag properly. I let you know, if-not!
-
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!!!
-
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
-
Thanks, it's clear! I got it.
-
Thanks you guys. I will try to use yours, it seems better for me.
-
Css- Review With Tutorial If u r learning CSS, learn it with me.
alex1985 replied to cncinfotech's topic in Programming
Who know where I can obtain the tutorial "PHP and CSS"?! How to make PHP files like formating the site with CSS?! -
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.
-
So, how do I plug such BB Codes on my site's page?!
-
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.
-
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?!
-
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?!
-
So, is it better to create login system with AJAX support? If yes, please indicate the tutorial.
-
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?!
-
I will check them on the server and clerify my questions!!!What is AJAX?
-
Take a look of this code at: PHP Tutorials. Just explain me the info that relates to 2 of my questions...
-
Could you explain the code: ['cmdusers'] or ['cmdlogin']?! What is the difference between them?
-
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.
-
Thanks. I already so it, how encrypt the password using the MySQL sequence. Tomorrow, I will post the sequence itself.
-
Could you write the whole process how you do it from the beggining?!
-
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.