Jump to content

GingerRobot

Staff Alumni
  • Posts

    4,082
  • Joined

  • Last visited

Everything posted by GingerRobot

  1. Probably no simple solution to this, but i think what you would have to do is to generate timestamps for each time the event occurs - you can do this since you know the start date, end date, and when it will occur in between. For instance, if i wanted to shedule an event every other day for the next 30 days - then you would have to generate 15 start times and 15 corresponding end times(so, for example, if i my event was 1 hour - each end time would be 1 hour after the start) I think you could achieve the creating of the timestamps through a combination of the date() and strtotime() functions. You could then insert each of these pairs of timestamps into the database. When checking for clashes, you would check the start and end time to see if there is already an event that falls on that time.
  2. I expected what you probably need to do is remove the opening and closing php tags from the code i posted. The reason why i put them in so that the code gets syntax highligting, making it easier to read.
  3. I think what you're after is something like: <?php //$file = file_get_contents('yourfile'); $file = '<?php // variable $var = "asdasd"; // array $array = array("lala", "lalal"); ?>'; echo '<textarea rows=10 cols=30>'.$file.'</textarea>'; $array_to_replace = "array";//the name of the array you are wanting to replace $replace_with = '$'.$array_to_replace.'= array("blabla","blahaha");';//whatever you want to replace with $file = preg_replace('|\$'.$array_to_replace.'(.*?);|s',$replace_with,$file); echo '<textarea rows=10 cols=30>'.$file.'</textarea>'; //write new file with $file; ?> As you can see, i tested it with a normal string - but if you use file_get_contents you can read the file into a string anyway, so just modify that bit. And then you'll have to write back to the file.
  4. Try checking for success with the mail function to start with: <?php if(mail($account['email'],$email_title,$email_content,$headers)){ echo 'mail sent successfuly'; }else{ echo 'email could not be sent'; ?> You'll also need to apply that to the other mail you send - not quite sure why you are sending two emails though. If its being sent, it could be to do with where you are sending it to - you might need to turn off some spam filters. Also, if you're using a free host, then that could be the problem. A lot of them disable the mail function to protect them from people signing up to spam others.
  5. If you google submitting a form on enter you'll find the necessary javascript.
  6. Im not quite sure i understand what you are trying to do. Do you mean that you first want the user to select a network, then to have a list of phones displayed, which they then select from, and then you do something else with both these bits of information? Also, in your javascript you have: url=url+"&ModelID=<?php echo"$ModelID" ?>" Where is $ModelID defined?
  7. You're missing the closing double quote in this part: <p>Thank You</p> Shitstix Team" ; Try: <?php include 'header.php'; $account = mysql_query("SELECT * FROM customers WHERE username='$_SESSION[username]' AND password='$_SESSION[password]'") or die(mysql_error()); $account = mysql_fetch_array($account); $date = date("Y-m-d"); $orders = mysql_query("SELECt * FROM orders WHERE order_date='$date' ORDER BY complete_id DESC LIMIT 1") or die(mysql_error()); $lastorder = mysql_fetch_array($orders); $lastorder = $lastorder[complete_id]; $next_order = $lastorder + 1; mysql_query("UPDATE orders SET cust_id='$account[id]', order_date='$date', complete_id='$next_order', status='payment complete' WHERE id='$_SESSION[order_id]'") or die(mysql_error()); $order_name = date("d").'-'.date("m").'-'.$next_order; $email_title = "Shitstix Order Confirmation"; $email_content = " Dear ".$account['firstname'].", <p>Thank you for your recent order at Shitstix.co.uk. We are emailing you to let you know that we are currently processing your order and will post your order out to you within the next few days. If you have any questions regarding your order, please feel free to email us at clivestix@btinternet.com.</p> <p>Thank You</p> Shitstix Team"//you missed off the " here ; $email = "clivestix@btinternet.com"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: ' . $email."\r\n" . 'Reply-To: '. $email."\r\n"; mail($account['email'],$email_title,$email_content,$headers); /* $prod_array = Array(); $order_products = mysql_query("SELECT * FROM order_log WHERE order_id='$_SESSION[order_id]' ORDER BY product_id") or die(mysql_error()); $numrows = mysql_num_rows($order_products); while($order_product = mysql_fetch_array($order_products)){ if(in_array($order_product[product_id],$prod_array) == FALSE){ $prod_array[] = $order_product[product_id]; $product_count = mysql_query("SELECT * FROM order_log WHERE order_id='$_SESSION[order_id]' AND product_id='$order_product[product_id]'") or die(mysql_error()); $product_count = mysql_num_rows($product_count); $product_det = mysql_query("SELECT * FROM products WHERE id='$order_product[product_id]'") or die(mysql_error()); $product_det = mysql_fetch_array($product_det); $orderlog = $orderlog . $product_count.' - ' .$product_det['name'].' '; } } $email_title = "Shitstix Order"; $email_content = " The following order needs to be processed and posted to: ".$order_name." ".$account['name']." ".$account['surname']." ".$account['addline1']." ".$account['addline2']." ".$account['addline3']." ".$account['addline4']." Order Details: ".$orderlog." "; */ $content = " <div style='font-family: arial; font-size: 14px;'> <div style='width: 100%; border-bottom: 2px solid #000; padding: 10px; text-align: center; font-family: Comic Sans MS;'><h1>Shitstix.co.uk</h1></div> <h2 style='font-size: 16px;'>Shitstix Order: ".$order_name."</h2> <div style='border: 1px solid #000; padding: 5px;'> Customer: ".$account['firstname']." ".$account['surname']." ".$account['addline1']." ".$account['addline2']." ".$account['addline3']." ".$account['postcode']." </div> Dear ".$account[firstname].", <p>Thank you for ordering from Shitstix.co.uk. We have enclosed your order along with this invoice.</p> Best Regards, Shitstix Team <center> <table border=0 cellpadding=0 cellspacing=0 style='width: 100%; font-family: arial; font-size: 11px;'> <tr> <td colspan=2 style='border-bottom: 1px solid #C2C2C1; text-align: left;'>Item</td> <td style='border-bottom: 1px solid #C2C2C1; text-align: left;'>Quantity</td> </tr>"; $total = 0; $price_total = 0; $prod_array = Array(); $groups = mysql_query("SELECT * FROM groups ORDER BY id") or die(mysql_query()); while($group = mysql_fetch_array($groups)){ $content = $content." <tr> <td colspan=3 style='font-weight: bold; text-align: left;'><h2 style='color: #000000;font-size: 14px;'>".$group['name']."</h2></td> </tr>"; $order_products = mysql_query("SELECT * FROM order_log WHERE order_id='$_SESSION[order_id]' AND group_id='$group[id]' ORDER BY product_id") or die(mysql_error()); $numrows = mysql_num_rows($order_products); if($numrows > 0){ while($order_product = mysql_fetch_array($order_products)){ if(in_array($order_product[product_id],$prod_array) == FALSE){ $prod_array[] = $order_product[product_id]; $product_count = mysql_query("SELECT * FROM order_log WHERE order_id='$_SESSION[order_id]' AND product_id='$order_product[product_id]'") or die(mysql_error()); $product_count = mysql_num_rows($product_count); $product_det = mysql_query("SELECT * FROM products WHERE id='$order_product[product_id]'") or die(mysql_error()); $product_det = mysql_fetch_array($product_det); $content = $content ." <tr> <td width=1% style='border-top: 1px solid #e7e7e7; border-bottom: #e7e7e7;'></td> <td style='border-top: 1px solid #e7e7e7; border-bottom: #e7e7e7; text-align: left;'>".$product_det['name']." </td> <td style='border-top: 1px solid #e7e7e7; border-bottom: #e7e7e7; text-align: right;'>".$product_count."</td> </tr>"; $total = $total + $product_count; $price_total = $price_total + ($product_det[price] * $product_count); }else{ $content = $content." <tr> <td colspan=3 style='text-align: center;'>".$group['name']."s</td> </tr>"; } } } } $content = $content . " <tr> <td colspan=2 style='border-top: 1px solid #C2C2C1; text-align: right;' width=90%>Total Items:</td> <td style='border-top: 1px solid #C2C2C1; text-align: right;'> ".$total."</td> </tr> <tr> <td colspan=2 style='text-align: right;'>Subtotal:</td> <td style='text-align: right;'>£ ".number_format($price_total,2)."</td> </tr>"; if($price_total >= 10){ $postage = 0; }else{ $postage = 1; } $price_total = $price_total + $postage; $content = $content." <tr> <td colspan=2 style='text-align: right;'>Postage:</td> <td style='text-align: right;'>£ ".number_format($postage,2)."</td> </tr> <tr> <td colspan=2 style='text-align: right;'>Total:</td> <td style='text-align: right;'>£ ".number_format($price_total,2)."</td> </tr> </table> </center> </div> </body> </html>"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: ' . $account['email']."\r\n" . 'Reply-To: '. $account['email']."\r\n"; mail($email,$email_title,$content,$headers); session_destroy(); ?> <h1>Thank you for your order!</h1> <p>We have received your order and are currently processing it. We will post your order out to you in the next few days. Thank you for visiting Shitstix.</p> <? include 'footer.php'; ?> For future reference, when you post, can you try and use tags(without the spaces). Makes it much easier to read
  8. Well, unless im being blind theres absolutely nothing wrong with that line. Are you sure thats the correct line? Can you post the few lines surrounding it? I would suggest its a missing semi colon from the previous line, but then you'd get unexpected variable.
  9. As far as im aware, there's no prebuilt method of doing this. However, a quick google will find you some functions. This one is from the Zend website: http://www.zend.com/code/codex.php?id=881&single=1
  10. To get the numbers of people that thing a person is each type of rating, you can use count(field) and group by(field). For example: <?php include('test_db_connection.php'); $sql = "SELECT count(`rating`) as `count`, `rating` FROM `ratings` GROUP by `rating` ORDER BY `count` DESC"; $result = mysql_query($sql) or die(mysql_error()); while($row = mysql_fetch_assoc($result)){ echo $row['count'].' member(s) think you are '.$row['rating'].'<br />'; } ?> With my test data, this produces: 3 member(s) think you are clever 2 member(s) think you are ugly 1 member(s) think you are funny
  11. You can do it easily enough in phpMyAdmin. However, the query is: ALTER TABLE `otherpayments` CHANGE `advert_id` `advert_id` INT( 11 ) NOT NULL
  12. You want to get yourself something better to develop your php scripts in. There's a topic here: http://www.phpfreaks.com/forums/index.php/topic,54859.0.html About the editors there are. There are plenty of free ones. Personally, i use php designer 2007. Edit: Beaten to it by thorpe. Sorry - i made a typo in the original query i posted.
  13. No problem Took me a long time to even begin to appreciate what you can do with a query.
  14. You need to remove the opening and closing php tags in the code i posted. The reason why i post them is to show syntax highlighting. Also, in the future, try and identify the line that the error is on - it'll help others help you.
  15. I think you should probably be doing something like: <?php $sql = mysql_query("SELECT `parasitename`,`parasitefrom,`parasitegenre,`parasitedescription`,`parasitetechinfo` FROM `yourtable`") or die(mysql_error()); echo '<p>Parasite list:</p> <TABLE width="100%" height="100%" border="1" cellpadding="2" cellspacing="5"><TR> <TD align="left" valign="top" width="161">Name</TD> <TD align="left" valign="top" width="122">From</TD> <TD align="left" valign="top" width="128">Genre</TD> <TD align="left" valign="top" width="161">Description</TD> <TD align="left" valign="top" width="164">Technical Info</TD> </TR>'; while ($row = mysql_fetch_array($sql)) { echo '<tr><td align="left" valign="top" width="161">' . $row['parasitename'] . '</td>'; echo '<td align="left" valign="top" width="122">' . $row['parasitefrom'] . '</td>'; echo '<td align="left" valign="top" width="128">' . $row['parasitegenre'] . '</td>'; echo '<td align="left" valign="top" width="161">' . $row['parasitedescription'] . '</td>'; echo '<td align="left" valign="top" width="164">' . $row['parasitetechinfo'] . '</td></tr>'; } ?> But as thorpe says, it would be helpful to have a bit more information.
  16. Also, shouldn't this line: $_SESSION[$value] = $row[$value]; Be: $_SESSION[$fields] = $row[$value]; Since it is the field names that i presume you want to use as the keys for the array? e.g. you want userID to be the key, not its value
  17. If ive understood the problem properly, you can achieve this just with your mysql query. I tested this: <?php include('test_db_connection.php'); $cupsize = 3; $weight = 2; $sql = "SELECT `cupsize`,`weight` FROM `phpfreaks` ORDER BY (ABS(cupsize-'$cupsize')+ABS(weight-'$weight'))"; $result = mysql_query($sql) or die(mysql_error()); while($row = mysql_fetch_assoc($result)){ echo 'Cupsize:'.$row['cupsize'].' Weight:'.$row['weight'].'<br />'; } ?> And it seems to work. So, you have a table in your database with fields for cupsize and weight, which contain a number from 1-5. In the query you select cupsize and weight, but its the ordering that gets you what you want. You take the absolute value of the cupsize field minus the value you are after( you use absolute value so all values are positive) and then the absolute value of the weight field mins the weight you want. Add those together. Then order by that. With the 4 pieces of test data i used, i got: Cupsize:3 Weight:2 Cupsize:3 Weight:3 Cupsize:3 Weight:4 Cupsize:1 Weight:5
  18. No problem. Its always the simple things that you spend the most time over
  19. Well, given that the data for the second drop down box is unlikely to change in your example, it would most often be done purely through javascript. The onchange() action would be used for the first drop down, which would call a javascript function to populate the second based on the value of the first. If the data in the second is more dynamic, then a database query would be needed. The principal is the same, except the javascript would call a php file to query the database and return the content for the second, and then the javascript would use the returned data to populate the second (e.g. you would use AJAX)
  20. Well you dont need that foreach, since you're not actually wanting to echo the values. Try something like: <?php $Author = $_POST['bookauthor']; for ($i = 0; $i < $Numofbooks; $i++) { $sqlinsertlogin = "INSERT INTO bookrequest (requestID, loginID, courseID, author) VALUES ('', '".$loginid[0]."', '".$crnforclass[0]."', '".$Author"')"; $insertlogin = mysql_query($sqlinsertlogin); if (!$insertlogin) { $insertloginerr = mysql_error(); echo $insertloginerr; exit(); } } ?>
  21. Well, theres not actually anything wrong with it as such - otherwise we would have an error. However, its not returned the rows you expect. Try echoing the query to see if the right values are being passed into it: <?php $b_query = "SELECT * FROM $block_tbl_name WHERE user_select = '$session_uid' AND user = '$u'"; $b_result = mysql_query($b_query) OR DIE (mysql_error()); $rows = mysql_num_rows($b_result); if($rows > 0){ $b_sql_result = mysql_result($b_result, 0); }else{ echo 'No rows returned. Query was'. $b_query; } ?> Check that make sure its querying the database with the values you are expecting.
  22. chigley: I dont think you tried the right url. It was suppoed to be t3_php.php, looks like you did t_php.php Might explain the rogue valid result - it was invalid when i tried it. flunn: Even once the html is valid, it's still probably going to look a least a little differant in the differant browsers. Dont get me started on the lack of cross browser compatibility/following standards. And im not a web designer. I pity those who are and who must get amazingly annoyed with this once or twice a minute.
  23. Sounds to me like $Author is still a string. Where did you define it? Did you change the form so that it was an array?
  24. You say there are 3 rows in the table, but i dont think any of them are being retrieved. Try this to check: <?php $b_query = "SELECT * FROM $block_tbl_name WHERE user_select = '$session_uid' AND user = '$u'"; $b_result = mysql_query($b_query) OR DIE (mysql_error()); $rows = mysql_num_rows($b_result); if($rows > 0){ $b_sql_result = mysql_result($b_result, 0); }else{ echo 'No rows returned'; } ?>
  25. You'll need to have your insert query inside the while/for loop. <?php for($x=0;$x<=count($yourarray);$x++){ mysql_query("INSERT INTO `yourtable` VALUES ('$somearray[$x]','$anotherarray[$x]')"); } ?> Again, just an example. Not sure where you're at so cant give anything more specific.
×
×
  • 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.