
lemmin
Members-
Posts
1,904 -
Joined
-
Last visited
-
Days Won
2
Everything posted by lemmin
-
Did you try window.opener? I would recommend just created an overlay for the login instead of a new window.
-
I don't see a syntax error there. Can you post more code from around it and note which is line 31?
-
If I understand you correctly, you want to go direct the user to the popup for input, then close the popup and continue navigation. The popup window's DOM object should contain a parent attribute that references the original window that opened it. You could use that object to refresh the original page, navigate elsewhere, or whatever you want to do.
-
date() accepts an integer in the form of a timestamp as the second parameter. You are probably passing it a string: "2012-09-12 14:00:00." Try using strtotime(): date('F d, Y h:i:s a', strtotime($row->news_article_posting_date)) http://us2.php.net/manual/en/function.date.php http://us2.php.net/manual/en/function.strtotime.php
-
Checkbox checked (associated tables) - editing with PHP mySQL
lemmin replied to lasha's topic in PHP Coding Help
$res is a mysql resource, not an array. As you can see by your output, you are now only printing the categories that are associated with the specified user id. I was basing that query on the fact that you had another query returning JUST the list of categories. If you want to include the unassociated categories, you would want to use a LEFT JOIN. Let's stay simple and just use two queries. Let's consider the two sets of information you need; the full list of categories and the list of associated categories. Since the former is bigger, we want to iterate through those. First let's get the latter: $sql = "SELECT cat_id FROM info, info_cats WHERE info.id = info_cats.info_id AND id='$id'"; $res = mysql_query($sql) or die(mysql_error()); $user_cats = array(); while ($id = mysql_fetch_row($res)) { $user_cats[] = $id[0]; } $user_cats now contains all the cat_id's that are associated with the user specified. (I took out the Category table from the query because we get that information below.) Now let's take your original loop and add the logic to it: $sql = "SELECT cat_id, cat_name FROM category"; $res = mysql_query($sql) or die(mysql_error()); $checkboxes = ''; while (list($id, $cat) = mysql_fetch_row($res)) { if (in_array($id, $user_cats)) $checked = ' checked="checked"'; else $checked = ''; $checkboxes .= "<input type='checkbox' name='category[]' value='$id' /> $cat<br />"; } That should get you your desired output. -
session_regenerate_id - what if bad guy regenerates first ?
lemmin replied to scanreg's topic in Application Design
By default, the old session id is still available, so not unless the delete flag is specified. There is a lot more information in the comments on this function's page: http://php.net/manual/en/function.session-regenerate-id.php -
You should be able to use window.open to accomplish that.
-
Jesirose is right, this code is a mess! I suggest doing some cleanup before continuing. Try using mysql_fetch_assoc: while ($row = mysql_fetch_assoc($result_id)) { foreach ($row as $cell) echo "<td><a href=\"../ui/edit_customer.php&id=".$row['id']."\">$cell</a></td>"; }
-
Checkbox checked (associated tables) - editing with PHP mySQL
lemmin replied to lasha's topic in PHP Coding Help
Here is an example query that should return all of the information you are looking for at once. SELECT cat_name, cat_id, name, id, sur FROM info, info_cats, Category WHERE info.id = info_cats.info_id AND Category.cat_id = info_cats.cat_id Try running that query and outputting the results as arrays to see what you are working with: while ($row = mysql_fetch_assoc($result)) print_r($row); -
I don't think that logic is correct. The actual matching of zipcodes should be taken care of in your SQL query. When you query for a specific zipcode in a list of zipcodes, the number of results (0 or 1) will indicate whether or not it matches. Like I said before, I don't think your query is working as you expect.
-
Checkbox checked (associated tables) - editing with PHP mySQL
lemmin replied to lasha's topic in PHP Coding Help
Yes, that would be the wrong array. You mentioned previously that you are using a JOIN query to associate your categories table. Could you post that code with any iteration through the result? -
Your MySQL code looks like it should function the same as the array code. You really should be more specific, though. "Not giving the same result," doesn't give us much to work with. Luckily, I think I see the problem. Your field name is the same as your database name. I'm guessing MySQL is having trouble discerning the two. try like this: "SELECT zipcodes.zipcodes FROM zipcodes WHERE zipcodes = '$stzip'" You really should change the field name, though. Just "zipcode" makes sense.
-
Checkbox checked (associated tables) - editing with PHP mySQL
lemmin replied to lasha's topic in PHP Coding Help
In my example, $usercats is an array that you would populate with the relevant categories. I think you might be passing it a mysql resource. If you are still looping through that resource above, you can use that loop to build the $usercats array. Post your updated code if you need more help. -
Checkbox checked (associated tables) - editing with PHP mySQL
lemmin replied to lasha's topic in PHP Coding Help
After creating an array containing the user's categories you can check the boxes like so: while (list($id, $cat) = mysql_fetch_row($res)) { if (in_array($cat, $usercats)) $checked = ' checked="checked"'; else $checked = ''; $checkboxes .= "<input type='checkbox' name='category[]' value='$id'$checked /> $cat<br />"; } -
I think that was his intention; disapprove the input if it contains any character OTHER than what is in the regex. Where are you calling this function? You have to call it onsubmit or sooner.
-
You changed the regex object function from test() to form(), which doesn't exist. It should be like this: if (/[^0-9a-zA-Z\s]/gi.test(inputtext.value))
-
That doesn't sound normal at all! It is because your href (which is never followed because of the return false) is set to that string. It has no use! I recommend doing the logic before the output since you have multiple checks: <?php $image = 'uploads/'.$row_products['product_id'].'a.jpg'; if (file_exists($image)) $link = 'Javascript:MM_openBrWindow(\''.$image.'\',\'\',\'width=600,height=450\');'; else { $link = 'Javascript://'; $image = 'image/no_photo.gif'; } ?> <a href="<?php echo $link; ?>"><img src="<?php echo $image; ?> width="132" height="99"/></a> The border attribute of img is deprecated. You should set that in your style sheet. P.S. What are you doing still using Macromedia libraries!?
-
a-b should be a-z You probably don't need A-Z since you have the case-insensitive modifier. Or maybe you don't need the case-insensitive modifier. That took a surprising amount of staring to catch!
-
need help ? else please take a look : thank you
lemmin replied to cybernet's topic in PHP Coding Help
I recommend cleaning up the logic in this, but this should work in your implementation: foreach( array('lastname','firstname','email', 'message', 'phone') as $x ) { if (!isset($_POST[$x])) { $submitted = false; break; } ${$x} = $_POST[$x]; $submitted = true; } if ($submitted) { if ( empty($lastname) || empty($firstname) || empty($message) || empty($email) || empty($phone)) $status = $lang['error']; else { $status = $lang['success']; mail($to, $subject, $body, $headers); } $yes_p = "<p style='color:red'>".$status."<br /></p>"; echo $yes_p; } There is a difference between a $_POST variable being empty and set. If a form is submitted with nothing entered, those indices are still created, but are, in fact, empty(). You want to check for the existence of the indices before checking what value they hold, as I roughly accomplished above. If you know the indices exist, you know the form was submitted and you can check for validation. If the form wasn't submitted, it won't even go through the validation logic, as it shouldn't. -
Does the new server have outside network access? Try to ping sub.basecamphq.com on your server.
-
need help ? else please take a look : thank you
lemmin replied to cybernet's topic in PHP Coding Help
foreach( array('lastname','firstname','email', 'message', 'phone') as $x ) { ${$x} = $_POST[ $x ]; } This loop is setting variable variables the names of which correspond to those in the array. This loop also assumes that the POST array contains all five of those string names as indices. Those are the $email and $message variable blow. if ( !isset($_POST[ $x ]) || empty($message) || empty($email) ) $status = $lang['error']; else { $status = $lang['success']; mail($to, $subject, $body, $headers); } This if statement will always evaluate to true since $x isn't defined (in the code you've shown). The scope of the closest $x ended in the foreach loop above it. I'm actually not sure what this is supposed to accomplish. At first I assumed you wanted this inside the foreach loop, but I'm guessing you don't want to send an email for EVERY input that is set. My guess is that you want to check required fields. Assuming they are ALL required fields, you can change the code to the following: if ( empty($lastname) || empty($firstname) || empty($message) || empty($email) || empty($phone)) $status = $lang['error']; else { $status = $lang['success']; mail($to, $subject, $body, $headers); } As for your ternary statement, you are always going to get the value of $no_p for $show_status. This is because isset($status) will ALWAYS be true since it is set in both conditions of your if-else statement (assuming $lang['error'] and $lang['success'] exist). Since you want it to print something either way, you don't even need that logic. This: $no_p = ''; $yes_p = "<p style='color:red'>".$status."<br /></p>"; $show_status = (isset($status)) ? $no_p : $yes_p; Could just be this: $yes_p = "<p style='color:red'>".$status."<br /></p>"; echo $yes_p; Or however you might be outputting it. As for returning NULL if the form wasn't submitted, as scootstah said, you don't have any logic for that. With your current logic, it will give the error message if it wasn't submitted. You can check for specific post values if you wanted to change that. -
It is hard to give you any feedback without more info about this third-party library. Is this CodeIgniter? Have you tried posting on the CodeIgniter forums?
-
Without an action attribute set in your form tag, the default value of GET will be used. You are using the $_POST variable in your PHP, though. Adding "action='POST'" or using the $_GET variable should populate your $category variable.
-
Possibly maximum number of connections?
-
You need an operator between the return value of strtotime and your offset variable. The reason it works when you manually type that out is because the negative symbol is being parsed as the operator. Try this: <? $timeDiff = $_SESSION['DirectExaminerCompanyTimeZone'] * 3600; echo date('n-d-Y @ g:i a', strtotime($row['OrderTicketStatusDateTime']) + $timeDiff); ?>