Jump to content

brmcdani

Members
  • Posts

    38
  • Joined

  • Last visited

    Never

Everything posted by brmcdani

  1. I have a simple image array that is being called to rotate images. I need to assign some ahref values to the images. How would I go about this? I would guess add the url to the array. Any ideas would be appreciated here is my code: <?php function randomImage ( $array ) { $total = count($array); $call = rand(0,$total-1); return $array[$call]; } $my_images = array ( "banners/1.jpg", "banners/2.jpg", "banners/3.jpg", "banners/4.jpg", "banners/5.jpg", "banners/6.jpg", ); echo '<img src="'.randomImage($my_images).'"; alt="Random Image" />'; ?>
  2. Thanks for the reply, where does the {remove} go??? On the very bottom? I made the changes and noticed the Remove on the post after.
  3. Thanks I got figured it out as soon as you posted. Here was my solution: $sql="select * from members,photos WHERE members.username=photos.username and YEAR(upldate) = YEAR(CURDATE()) AND MONTH(upldate) = MONTH(CURDATE()) and approved='Y' and active=1 order by photos.upldate";
  4. I am trying to create a mysql statment where the following records are pulled out based on which month it is. The following statment I have will pull out the latest photos and order them by the date. However I want it to pull out records only from the current month. Any ideas will be appreciated. Thanks $sql="select * from members,photos where members.username=photos.username and approved='Y' and active=1 order by photos.upldate";
  5. I am trying to create a login for my webstie but I keep getting the following errors: Warning: session_register() [function.session-register]: Cannot send session cookie - headers already sent by (output started at /home/mcdtech1/public_html/lubbockwebpro.com/checklogin.php:1) in /home/mcdtech1/public_html/lubbockwebpro.com/checklogin.php on line 26 Warning: session_register() [function.session-register]: Cannot send session cache limiter - headers already sent (output started at /home/mcdtech1/public_html/lubbockwebpro.com/checklogin.php:1) in /home/mcdtech1/public_html/lubbockwebpro.com/checklogin.php on line 26 Warning: Cannot modify header information - headers already sent by (output started at /home/mcdtech1/public_html/lubbockwebpro.com/checklogin.php:1) in /home/mcdtech1/public_html/lubbockwebpro.com/checklogin.php on line 28 I have looked at the lines it points out and am still having trouble here is my code: <?php ob_start(); $host="localhost"; // Host name $username="mcdtech1"; // Mysql username $password="l0608448533"; // Mysql password $db_name="mcdtech1_lakeAlanH"; // Database name $tbl_name="users"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // Define $myusername and $mypassword $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; // To protect MySQL injection (more detail about MySQL injection) $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ // Register $myusername, $mypassword and redirect to file "login_success.php" session_register("myusername"); session_register("mypassword"); header("location:login_success.php"); } else { echo "Wrong Username or Password"; } ob_end_flush(); ?> Any help would be appreciated. Thanks
  6. Anybody know of any good tutorials that show how to integrate PHP into a FLASH web site? The PHP will be a login/registration system. Thanks
  7. Iam currently working with a client who wants a members only area that will accomplish allowing for a permanent 10% discount on everything for sale on the site. How would I be able to apply a 10% discount option for the items for sale? Also the site is in FLASH how hard is it to implement PHP into FLASH? I am guessing it wouldn't be too hard. Let me know everyone's thoughts please. Thanks
  8. Great this worked. Thanks for your help happy new year!
  9. Still doesn't work! I dont know what else to try. This has to be done tonight and ready to go for a client tomorrow.
  10. Ok there are no extra spaces anywhere with the starting php line now I have this and am getting a header error message on line 17 which is the beginning of the header line. <?php $name = $_REQUEST['name']; $phone = $_REQUEST['phone']; $email = $_REQUEST['email']; $pref = $_REQUEST['pref']; $type = $_REQUEST['type']; $kind = $_REQUEST['kind']; $message = $_REQUEST['message']; $body = "Name: $name \nPhone Number: $phone \nEmail: $email \nContact Preference: $pref \nJob Type: $type \nInterested In: $kind \nDescription: $message \n\n"; mail("brett.mcdaniel@ttu.edu", "Contact Request", $body); header("Location: thankyou.htm"); ?>
  11. I am getting the following error message: Cannot modify header information - headers already sent by (output started at /home/content/s/a/g/sagates/html/contact.php:1) in /home/content/s/a/g/sagates/html/contact.php on line 17 Here is my code: <?php ob_start(); $name = $_REQUEST['name']; $phone = $_REQUEST['phone']; $email = $_REQUEST['email']; $pref = $_REQUEST['pref']; $type = $_REQUEST['type']; $kind = $_REQUEST['kind']; $message = $_REQUEST['message']; $body = "Name: $name \nPhone Number: $phone \nEmail: $email \nContact Preference: $pref \nJob Type: $type \nInterested In: $kind \nDescription: $message \n\n"; mail( "brett.mcdaniel@ttu.edu", "Contact Request", $body); header("Location: thankyou.htm"); ?> I think I need an ending ob_ statement just not sure which one. Can someone please help me out??? Thanks
  12. Ok I added the ob_start() should there be a a ob_flush() or something like that at the end? It says the error is on the last line of code now? Thanks again
  13. Okay this is really wearing me out! Now I get a Cannot Modify Header error at line 21 One more reply please! <?php $name = $_REQUEST['name'] ; $phone = $_REQUEST['phone'] ; $email = $_REQUEST['email'] ; $pref = $_REQUEST['pref'] ; $type = $_REQUEST['type'] ; $kind = $_REQUEST['kind'] ; $message = $_REQUEST['message']; $body = "Name: $name \nPhone Number: $phone \nEmail: $email \nContact Preference: $pref \nJob Type: $type \nInterested In: $kind \nDescription: $message \n\n"; mail( "brett.mcdaniel@ttu.edu", "Contact Request", $body); header( "Location: thankyou.htm" ); ?>
  14. Great thanks for your help! Now I am getting a parse error and don't get what the deal is on this I checked it over 3-4 times but I am tired! I know it is something simple someone please help! Thanks <?php $name = $_REQUEST['name'] ; $phone = $_REQUEST['phone'] ; $email = $_REQUEST['email'] ; $pref = $_REQUEST['pref'] ; $type = $_REQUEST['type'] ; $kind = $_REQUEST['kind'] ; $message = $_REQUEST['message'] ; $body = "Name: $name \nPhone Number: $phone \nEmail: $email \nContact Preference: $pref \nJob Type: $type \nInterested In: $kind \nDescription: $message \n\n" mail( "brett.mcdaniel@ttu.edu", "Contact Request", $body); header( "Location: thankyou.htm" ); ?>
  15. I am getting the following errors for my mail() code: Warning: mail() expects at most 5 parameters, 9 given in /home/content/s/a/g/sagates/html/contact.php on line 17 Warning: Cannot modify header information - headers already sent by (output started at /home/content/s/a/g/sagates/html/contact.php:17) in /home/content/s/a/g/sagates/html/contact.php on line 18 Here is my code <?php $name = $_REQUEST['name'] ; $phone = $_REQUEST['phone'] ; $email = $_REQUEST['email'] ; $pref = $_REQUEST['pref'] ; $type = $_REQUEST['type'] ; $kind = $_REQUEST['kind'] ; $message = $_REQUEST['message'] ; mail( "laaa4@sss.com", "Contact Request", "Name: $name", "Phone Number: $phone", "Email: $email", "Contact Preference: $pref", "Job Type: $type", "Interested in: $kind", "Description: $message"); header( "Location: thankyou.htm" ); ?> Can someone please help me out please?
  16. I am having trouble getting any files to upload onto my server. I am brand new at this and do not know if there is something you have to enable on my Apache Server or what? Here is my script: <?php $target = "uploads/"; $target = $target . basename( $_FILES['uploaded']['name']) ; $ok=1; //This is our size condition if ($uploaded_size > 350000) { echo "Your file is too large.<br>"; $ok=0; } //This is our limit file type condition if ($uploaded_type =="text/php") { echo "No PHP files<br>"; $ok=0; } //Here we check that $ok was not set to 0 by an error if ($ok==0) { Echo "Sorry your file was not uploaded"; } //If everything is ok we try to upload it else { if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else { echo "Sorry, there was a problem uploading your file."; } } ?>
  17. This is driving me crazy because I know it is so simple. I can't find any sources to help. I am trying to make my text bigger in this table and form. Can someone show me how to edit the text size and style in at least one line in the form and one in the table please? Thanks echo "<table border=\"0\" cellspacing=\"3\" cellpadding=\"3\">\n"; echo "<form method=\"post\" action=\"register.php\">\n"; echo "<tr><td>Username</td><td><input type=\"text\" name=\"username\"></td></tr>\n"; echo "<tr><td>Password</td><td><input type=\"password\" name=\"password\"></td></tr>\n"; echo "<tr><td>Confirm</td><td><input type=\"password\" name=\"passconf\"></td></tr>\n"; echo "<tr><td>E-Mail</td><td><input type=\"text\" name=\"email\"></td></tr>\n"; echo "<tr><td>First Name</td><td><input type=\"text\" name=\"name\"></td></tr>\n"; echo "<tr><td>Last Name</td><td><input type=\"text\" name=\"aim\"></td></tr>\n"; echo "<tr><td>Verification letters</td><td><input type=\"text\" name=\"verification\"></td></tr>\n"; echo "<tr><td colspan=\"2\" align=\"center\"><input type=\"submit\" name=\"submit\" value=\"Register\"></td></tr>\n"; echo "</form></table>\n"; echo "<table border=\"0\" cellspacing=\"3\" cellpadding=\"3\">\n"; echo "<tr><td>Verification letters to be entered into form:</td></tr>\n"; echo "<tr><td>$rand[$keys]</td></tr>\n"; echo "</table>\n";
  18. Ok that worked great, thanks! I was in the middle of looking at that in the manual when I got your post. What would I do if I want to end the registration if it is not in the array? Even if the verification is wrong it still registers the user? Any ideas?
  19. I recently wrote a PHP script to add to my registration page that allows for human verification by pulling random strings out of an array. I am having trouble making my if statement work to where it checks the array before approving the user's registration. Here is what I have so far: $verification = protect($_POST['verification']); if($verification != $rand){ echo "Sorry but the number verification you entered was not correct"; } $rand = array("asfd7", "ghdg3", "kfdr6", "sdas3", "hdsa6", "gdsd9", "ijko5"); $keys = array_rand($rand, 1); echo "Verification letters: "; echo $rand[$keys]; Can someone please point me in the right direction? Thanks
  20. Yeah it says it can "take 1 or more random entries out of an array" I just do not understand why it won't take 1 when I enter in 1
  21. Iam tring to pull a random string out of an array. I have it working but it output's 2 strings and I just want it to output 1. I have tried changing the code up from $keys = array_rand($rand, 2); to $keys = array_rand($rand, 1); but it still won't work. Here is my complete code snippet: $rand = array("asfd", "ghdg", "kfdr", "sdas", "hdsa", "gdsd", "ijko"); $keys = array_rand($rand, 2); echo "Verification letters: "; echo $rand[$keys[0]] . "\n"; echo $rand[$keys[1]] . "\n";
  22. Yep that did the trick. Thanks a lot everyone!
  23. Ok I am making some progress with my problem now. I am getting an sql_error that says "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 '* FROM `alabama_forum_replies` WHERE `id`='3'' at line 1" As far as I can tell my SQL statement is fine, but I am getting frustrated and tired of searching for my mistake. Let me narrow down the code to where the problem is defined by mysql_error. if ($actz == 'deletereply'){ $id2 = mss($_GET['id']); if($id2){ $sql3 = "DELETE * FROM `alabama_forum_replies` WHERE `id`='".$id2."'"; $res3 = mysql_query($sql3) or die(mysql_error()); if(mysql_num_rows == 0){ echo "This topic doesn't exist"; }else { $row = mysql_fetch_assoc($res3); $user_id = $row['uid']; if(user_id == $_SESSION['uid'] || $admin == 1){ if(!$_POST[submit]){ echo "<form method=\"post\" action=\"index.php?act=delete&act2=deletereply&id=".$id2."\>\n"; echo "<table border=\"0\" width=\"100%\" cellspacing=\"3\" cellpadding=\"3\">\n"; echo "<tr><td class=\"forum_header\" align=\"center\"><textarea style=\"width:90%;height:200px\" name=\"deletethis\">".htmlentities($row['message'])."</textarea></td></tr>\n"; echo "<tr><td class=\"forum_header\" align=\"center\"><input type=\"submit\" name=\"submit\" value=\"Delete Comment\"></td></tr>\n"; echo "</table></form>\n"; }else{ } }else{ echo "This is not your reply to edit"; } } } }
  24. My deletereply code is not working. Edit reply is working fine.
×
×
  • 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.