Jump to content

JonnoTheDev

Staff Alumni
  • Posts

    3,584
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by JonnoTheDev

  1. <?php echo "<td><a onclick=\"reenviar_email('".$row->email."')\">asd</a>"; ?>
  2. MVC pattern http://www.tonymarston.net/php-mysql/model-view-controller.html
  3. Read through your code thoroughly!!!!!!
  4. This is because you have specified 11 database field names but only provided 9 peices of data if(!mysql_query("INSERT INTO events (name, fromslashes, fromdisplay, fromtime, toslashes, todisplay, totime, quickdescription, pagedescription, sameday, status) VALUES ('".$data['eventTitle']."', '".$data['from1']."', '".$data['from2']."', '".$data['fromtime']."', '".$data['to1']."', '".$data['to2']."', '".$data['totime']."', '".$data['quickDesc']."', '".$data['description']."')")) { die(mysql_error()); } It is much easier to use the following sql syntax for insert/update "INSERT INTO events SET name='".$data['eventTitle']."',fromslashes='".$data['from1']."',fromdisplay='".$data['from2']."',fromtime='".$data['fromtime']."',toslashes='".$data['to1']."',todisplay='".$data['to2']."'" // complete the rest yourself
  5. <td><a onclick="reenviar_email('<?php echo $row->email;?>')">asd</a>
  6. You are calling the function incorrecly. It only takes 1 parameter now. // CALL FUNCTION addeventToPending($data); Look at the new code again
  7. And have you called the function using foreach($inputFieldNamesToDb as $dbField => $postField) { $data[$dbField] = $_POST[$postField]; } // CALL FUNCTION addeventToPending($data);
  8. Post your whole code with the function
  9. This is how you should of approached it however I fail to see why you are doing the following: 1. Having subject & body as function parameters but not using them. 2. Inserting the whole email body, subject, against each user as a record. This is not normalised. You should save the email subject, body as 1 record in a table and use a join table to join users who received the email. <?php function messaging_all($subject, $body) { // Get my user $username = $_SESSION['username']; // Setup my date $sent_date = date('U'); // select user data $result = mysql_query("SELECT username, email FROM users WHERE allowed='on' AND !ISNULL(email)") or die(mysql_error()); $data = array(); while($row = mysql_fetch_assoc($result)){ $data[$row['email']] = $row['username']; } // connect to other database, insert records and send emails // open a different handle $handleDb1 = mysql_connect("localhost","user","passwd"); mysql_select_db("discover_messaging",$handleDb1); foreach($data as $email => $user) { mysql_query("INSERT INTO messages (msg_to, msg_from, msg_subject, msg_body, read_flg, sent_date) VALUES ('".mysql_real_escape_string($user)."', '".mysql_real_escape_string($username)."', '".mysql_real_escape_string($subject)."' , '".mysql_real_escape_string($body)."', 'off', '".mysql_real_escape_string($sent_date)."')", $handleDb1) or die(mysql_error()); $email_subject = "[PRIVATE MESSAGE] You have a new message"; $email_body = "Hi, ".$user." You have a new message, Log in to view it."; mail($email,$email_subject,$email_body,"From: Discovery ESU\n"); } mysql_close($handleDb1); } ?>
  10. You could use the following method. However it makes life a lot easier when your form field names have the same name as your database fields. Here I am adding the data in the form fields to the corresponding database fields. <?php function addeventToPending($data) { // clean data foreach($data as $key => $value) { $data[$key] = mysql_real_escape_string($value); } if(!mysql_query("INSERT INTO events (name, fromslashes, fromdisplay, fromtime, toslashes, todisplay, totime, quickdescription, pagedescription, sameday, status) VALUES ('".$data['eventTitle']."', '".$data['from1']."', '".$data['from2']."', '".$data['fromtime']."', '".$data['to1']."', '".$data['to2']."', '".$data['totime']."', '".$data['quickDesc']."', '".$data['description']."')")) { die(mysql_error()); } echo "Your event was put up for approval."; } // usage $inputFieldNamesToDb = array('eventTitle' => 'title', 'from1' => 'datepicker1', 'from2' => 'alternative1', 'fromtime' => 'timestart', 'to1' => 'datepicker1', 'to2' => 'alternative2', 'totime' => 'timefinish', 'quickDesc' => 'Qdescription', 'description' => 'elm1'); foreach($inputFieldNamesToDb as $dbField => $postField) { $data[$dbField] = $_POST[$postField]; } addeventToPending($data); ?>
  11. Search http://www.hotscripts.com If your books don't have examples of building applications / websites then you are reading the wrong ones. Recommendation http://www.amazon.co.uk/Beginning-PHP5-Programmer-Dave-Mercer/dp/0764557831/ref=sr_1_1?ie=UTF8&s=books&qid=1250519414&sr=1-1
  12. It will be a query error. use mysql_error() or die($error = 1); or die(mysql_error()); Also an issue can be switching databases. I would have approached this by building an array of data from the select query on database one. Connect to database 2 and loop / insert the data. You are swithing databases through the loop of a current result set. Bad idea
  13. All these lines have errors. You are not comparing a value. if ($target_w0_die >) { $target_w0_die=$target_w0; } if ($target_w1_die >) { $target_w1_die=$target_w1; } if ($target_w2_die >) { $target_w2_die=$target_w2; } if ($target_w3_die >) { $target_w3_die=$target_w3; } if ($user_w0_die >) { $user_w0_die=$user_w0; } if ($user_w1_die >) { $user_w1_die=$user_w1; } if ($user_w2_die >) { $user_w2_die=$user_w2; } if ($user_w3_die >) { $user_w3_die=$user_w3; } You need a value to evaluate the greater than operator
  14. <?php function addeventToPending($data) { // clean data foreach($data as $key => $value) { $data[$key] = mysql_real_escape_string($value); } if(!mysql_query("INSERT INTO events (name, fromslashes, fromdisplay, fromtime, toslashes, todisplay, totime, quickdescription, pagedescription, sameday, status) VALUES ('".$data['eventTitle']."', '".$data['from1']."', '".$data['from2']."', '".$data['fromtime']."', '".$data['to1']."', '".$data['to2']."', '".$data['totime']."', '".$data['quickDesc']."', '".$data['description']."')")) { die(mysql_error()); } echo "Your event was put up for approval."; } ?>
  15. Problems with this code 1. Passing the username & password through the url is insane $uguess = $_GET['user']; $pguess = $_GET['pass']; 2. The text file looks to be in the same directory as your script as there is no path. If this in in your web root then anyone can view it i.e. http://abc.com/upass.txt $filename = "upass.txt"; Also you are surpressing errors when the file is read. Is the file being read at all? $fp = @fopen($filename, 'r'); 3. Why are you using a cookie for login rather than a session? Also storing passwords in cookies is insane as they are clear text files. Trojans, worms, computer users etc could read this. setcookie('logank9.com',$pguess,time()+(3600*24)); 4. For user redirection you should use the header() function. Not meta refresh header("Location:index.php"); Use sessions as opposed to cookies, use POST not GET for input fields, move the password file outside of the web document root and debug your code i.e. Check the file is being read. Check the username, password are being compared against the data, check a session is set. Echo data to the screen so you can see what is being used.
  16. Use mysql_error() to see the query error <?php function addeventToPending($eventTitle, $from1, $from2, $fromtime, $to1, $to2, $totime, $quickDesc, $description) { $query = "INSERT INTO events (name, fromslashes, fromdisplay, fromtime, toslashes, todisplay, totime, quickdescription, pagedescription, sameday, status) VALUES ($eventTitle, $from1, $from2, $fromtime, $to1, $to2, $totime, $quickDesc, $description)"; if(!mysql_query($query)) { die(mysql_error()); } echo "Your event was put up for approval."; } ?> You would have been better passing in an associative array as a function parameter. As a rule of thumb if you have more than 3 parameters use an array. Also clean your data to prevent sql error. <?php function addeventToPending($data) { // clean data foreach($data as $key => $value) { $data[$key] = mysql_real_escape_string($value); } if(!mysql_query("INSERT INTO events (name, fromslashes, fromdisplay, fromtime, toslashes, todisplay, totime, quickdescription, pagedescription, sameday, status) VALUES (".$data['eventTitle'].", ".$data['from1'].", ".$data['from2'].", ".$data['fromtime'].", ".$data['to1'].", ".$data['to2'].", ".$data['totime'].", ".$data['quickDesc'].", ".$data['description'].")")) { die(mysql_error()); } echo "Your event was put up for approval."; } ?>
  17. http://www.tizag.com/mysqlTutorial/mysqlleftjoin.php
  18. Paypal buy now buttons are fine. However if you require any action on your system when a payment is made. i.e. update database records, etc then you want to look at paypal IPN
  19. Use LEFT JOINS
  20. ok in full screen
  21. $cityandstate = "New York, NY"; if(strpos($cityandstate, ",")) { echo "true"; }
  22. Good idea but you can't see the code in the video, very blurry.
  23. Is there a reason for storing the date in this fashion. Really you should use an INT(10) and use a UNIX timestamp. This value can be converted back to date & time using php's date() function. Timestamp print time();
  24. Note: Any variable enclosed within single quotes (') will be treated as a string. Variables enclosed within double quotes (") will be parsed. However for readability sake it is better to concatonate variables to strings with a period (.) print "My name is ".$name." and I like PHP";
  25. header("Location:profile.php?id=".$_GET['id']);
×
×
  • 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.