Jump to content

eMonk

Members
  • Posts

    223
  • Joined

  • Last visited

Everything posted by eMonk

  1. Before: include("../includes/connect.php"); $strqry = "SELECT id from model"; $result = $db->query($strqry); $TOTALROWS = $result->num_rows; $NumOfPages = $TOTALROWS / $LIMIT; $LimitValue = $page * $LIMIT – ($LIMIT); After: <html> <body> <div id="pages" align="right">Pages: <?php If ($page == ceil($NumOfPages) && $page != 1) { for($i = 1; $i <= ceil($NumOfPages)-1; $i++) { // Loop through the number of total pages if($i > 0) { // if $i greater than 0 display it as a hyperlink echo "<a href=\"/{$i}\">{$i}</a>"; } } }
  2. Does anyone see an error in the following code? I'm getting an unexpected T_STRING error from it: $LimitValue = $page * $LIMIT – ($LIMIT);
  3. When a user logs in and clicks on the update link they get sent to update.php. On the bottom of this page there is a "Back to Index" link which leads back to the page they were just on (index.php). However all the records in the mysql table is being listed instead if just the users. Any ideas why? I'm using sessions for my members area and echoing it to make sure it's being passed between both pages correctly and it is.
  4. I understand that and it was what I was doing. $query = "INSERT INTO model VALUES ($age, $weight)"; Should have been: $query = "INSERT INTO model VALUES ('$age', '$weight')";
  5. Thanks ManiacDan that worked but it wasn't the source of the problem. In my query I didn't have '' around the $age and $weight variable because I thought number values didn't need them but it makes a syntax error if they are left blank.
  6. Oh I see, thanks for clearing that up ManiacDan! I tried changing these 2 tinyint fields into varchar but get the following error in phpmyadmin: Why is there a syntax error when I'm using phpmyadmin. See anything wrong with this sql syntax?
  7. Good idea Maq, I could just run a separate query when the user fills these 2 fields out but there must be a way to do this in 1 query? All columns in the table are NULL by default. BTW ManiacDan: I can leave all the fields blank just not these 2 for some reason.
  8. I have a mysql table with about 20 columns. The 2 giving me problems are: age tinyint(2) unsigned, weight tinyint(3) unsigned, For some reason these 2 fields have to be entered in when submitting from a HTML form or I get the following error: 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 ' '', '', '', '', '', , '', ................. at line 20 I tried changing these 2 fields to varchar like the rest of the columns but phpmyadmin is giving me an error. Can anyone shed some light on this? I would like the user to be able to leave these 2 fields blank if they want to.
  9. I know but how can I do it so it's not?
  10. $height = trim(htmlentities(mysqli_real_escape_string($db,$_POST['height'],ENT_QUOTES))); Here's the error message I'm getting: Warning: mysqli_real_escape_string() expects exactly 2 parameters, 3 given I just added in the htmlentities and ENT_QUOTES to the line but not sure how to format it. Any ideas?
  11. I'm trying to add 5 days to $today date: <?php $exp_date = "2011-09-11"; $todays_date = date("Y-m-d"); $today = strtotime("+5 days", $todays_date); $expiration_date = strtotime($exp_date); if ($expiration_date > $today) { echo "Valid: Yes"; } else { echo "Valid: No"; } ?> Is +5 days used wrong?
  12. I'm trying to get the grouped_elements to work with Fancybox and tried many different codes but still no luck. Here's what I have now and it's just loading a blank page: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script type="text/javascript" src="/fancybox/jquery.fancybox-1.3.4.pack.js"></script> <script type="text/javascript" src="/fancybox/jquery.mousewheel-3.0.4.pack.js"></script> <link rel="stylesheet" href="/fancybox/jquery.fancybox-1.3.4.css" type="text/css" media="screen" /> <script type="text/javascript"> $(document).ready(function() { $("a.grouped_elements").fancybox(); }); </head> <body> <a class="grouped_elements" rel="group1" href="image_big_1.jpg"><img src="image_small_1.jpg" alt=""/></a> <a class="grouped_elements" rel="group1" href="image_big_2.jpg"><img src="image_small_2.jpg" alt=""/></a> <a class="grouped_elements" rel="group2" href="image_big_3.jpg"><img src="image_small_3.jpg" alt=""/></a> <a class="grouped_elements" rel="group2" href="image_big_4.jpg"><img src="image_small_4.jpg" alt=""/></a> </body> </html> Here's the link to the Fancybox tutorial: http://fancybox.net/howto The image effect I'm trying to produce is the last one at: http://fancybox.net (the one where you can use the mouse scroll wheel)
  13. Here's the second query: <?php include("../includes/connect.php"); $sel=array(); $query="select a.city_id, a.city_name, b.city_display from city a "; $query .="left outer join model_in_city b on a.city_id=b.city_id and b.city_display>0 and b.model_id=" . $id . " "; $query .="order by a.city_name"; $city_result=$db->query($query); if ($city_result) { for($i=1;$i<=4;$i++) { $sel[$i]="City " . $i . ":<select name=select[" . $i . "]>\n"; } while ($cityrow = mysqli_fetch_array($city_result)) { for($i=1;$i<=4;$i++) { $sel[$i].="<option value=" . $cityrow['city_id']; if($cityrow['city_display']==$i) { $sel[$i] .=" selected "; } $sel[$i].=">" . $cityrow['city_name'] . "</option>\n"; } } for($i=1;$i<=4;$i++) { $sel[$i].="</select>"; } } else { echo "no city result mysql error=" . mysql_error() . "<br>\n"; } for($i=1;$i<=4;$i++) { echo $sel[$i] . "<br>\n<br>\n"; } ?> Note: I still have to add in the table tags (tr, td, etc)
  14. The code below works but the second query is being displayed at the very top of the page. It should be inside the html table. What am I doing wrong? <?php include("../includes/connect.php"); $id = $_GET['id']; $query_1 = "SELECT * FROM model WHERE id = '$id' "; if ($result_1 = $db->query($query_1)) { while ($row = $result_1->fetch_assoc()) { $name = $row['name']; ... ?> <html> <body> <form action="updated.php" method="post"> <table width="600" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="95">Name</td> <td><input type="text" name="name" value="<?=$name?>" maxlength="50"></td> </tr> ... <?php include("../includes/connect.php"); $sel=array(); $query="select a.city_id, a.city_name, b.city_display from city a "; $query .="left outer join model_in_city b on a.city_id=b.city_id and b.city_display>0 and b.model_id=" . $id . " "; $query .="order by a.city_name"; ... ?> Note: I left most of the code out so it isn't too lengthy. Hopefully you can see the logic behind it that I'm try to do.
  15. I'm running a mysql select query and just found out both tables have a same column. This is the column both tables have which is city_id: $city_id = $row['city_id']; I tried the following but it didn't work: $city_id = $row['tablename.city_id']; How can I do this?
  16. You can pass variables to new pages using sessions.
  17. Before closing the connection, add in: if ($sql) { echo "Update successful."; }
  18. $sq1 = "DELETE FORM products WHERE id = '$yesdelete' "; mysql_query($sq1); if ($sq1) { echo "Row deleted"; }
  19. Nevermind. I see a comparison in example #1 at: http://ca3.php.net/empty I learned a new function today. Thanks The Little Guy!
  20. Thanks for the info Pikachu2000 and everyone else that commented. Question: What's the difference between (if any): if (isset($email)) and if (empty($email))
  21. Ah, guess I will override it every time a form is updated since the other values are being overwritten as well.
  22. Or maybe just not have the form fetch their email address into the email text field and if they fill this field in then I'll update the members database as well? Then I can use the isset function and let them know only to fill in this textbox if they want to update their email address and display their old one below it.
  23. email will always be not empty. For example, let's say John wants to update his email address. The update form loads john@somewhere.com into the form but then he changes it to johnny@somewhere.com. If this is the case then I'll need to update the members database as well with his new email address. Sure I can always perform this action and override it everytime but I don't think it's necessarily?
  24. Something like this? if $email = $email { perform normal query } else { perform a modified query }
  25. I have an update form where users can update their info. If they update their email address, I want "to do" something. For example: if(isset($email) ) { do something } However the isset function won't work in my case because $email is always NOT NULL so it will always perform this action which won't be necessarily. What function do I use to check if $email was changed?
×
×
  • 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.