-
Posts
3,145 -
Joined
-
Last visited
-
Days Won
37
Everything posted by cyberRobot
-
@PFMaBiSmAd - Ah, I see the note now. Thanks for the clarification.
-
I actually don't get any errors, notices, or warnings. <?php error_reporting(E_ALL); ini_set('display_errors', 1); ?> <html> <head> <title>Test Session</title> </head> <body> <?php session_start(); if(isset($_SESSION['test'])) { print '<p>Session var found: ' . $_SESSION['test'] . '</p>'; } else { $_SESSION['test'] = 'hello'; print '<p>Session var now set to ' . $_SESSION['test'] . '</p>'; } ?> </body> </html>
-
For what it's worth, the following code works for me? <html> <head> <title>Test Session</title> </head> <body> <?php session_start(); if(isset($_SESSION['test'])) { print '<p>Session var found: ' . $_SESSION['test'] . '</p>'; } else { $_SESSION['test'] = 'hello'; print '<p>Session var now set to ' . $_SESSION['test'] . '</p>'; } ?> </body> </html> While digging through the PHP manual (http://php.net/manua...ssion-start.php), I didn't see any mention of session_start() needing to appear at the top. Based on the contributor notes, however, there are some comments where session_start() didn't work without it being at the top...so maybe it comes down to server configuration.
-
Depending on what you're looking to do, you could look into grabbing the data with PHP and dumping it into a Javascript variable (or variables). Then when the page loads, that data would be available to Javascript.
-
Is there a reason the validation part can't be added to your process.php script? The script, for example, could do something like validate form fields if the form fields are invalid redirect to form (or display form again) for user to fix the information [*]else display confirmation
-
The following page of the PHP manual may help: http://php.net/manua...es.external.php
-
Php Template Process, If Function, Please Help
cyberRobot replied to work_it_work's topic in PHP Coding Help
I'm glad to hear that -
Php Template Process, If Function, Please Help
cyberRobot replied to work_it_work's topic in PHP Coding Help
That kind of depends on your code. You should be able to do something like: $templateFile = ($_SERVER['PHP_SELF'] == '/index.php') ? 'header.tpl.php' : 'header2.tpl.php'; $template_output .= $template->process($templateFile); -
Php Template Process, If Function, Please Help
cyberRobot replied to work_it_work's topic in PHP Coding Help
As long as your website is set so that visits to "www.site.com" show the index.php file, the code provided should work. -
Php Template Process, If Function, Please Help
cyberRobot replied to work_it_work's topic in PHP Coding Help
You could try something like the following: $templateFile = ($_SERVER['PHP_SELF'] == '/index.php') ? 'header.tpl.php' : 'header2.tpl.php'; -
You could merge the column and value arrays before executing the query with array_merge(). That way, you would only need one implode. $cols = array_merge($cols, $cols_sm); $data = array_merge($data, $data_sm); $query = 'INSERT INTO `imloop` (' . implode(', ', $cols) . ') VALUES (' . implode(', ', $data) . ')'; Also, the values will probably need to be enclosed in quotes (see Reply 9 for an example).
-
What do we need to look at? Is it still having a problem where the image data doesn't contain the full file name (Reply 11)? If so, what does $query look like when it's displayed to the screen?
-
Are you just wondering how to add more checkboxes to the form? You should be able to add them to the while loop: while(list($id,$username,$admin)=mysql_fetch_row($result)){ $checked = ($admin==1) ? 'checked="checked"' : ''; echo '<tr><td>'.$username.'</td><td><input type="checkbox" name="admin[]" value="'.$id.'" '.$checked.'/></td>'; //<-- ADD CODE FOR THE CHECKBOXES HERE echo '</tr>'."\n"; } As a side note, I would recommend that you avoid using PHP_SELF as the <form> tag's action for security reasons. More information can be found here: http://seancoates.com/blogs/xss-woes
-
Did you try using something like var_dump() to see what $codes1 and $codes3 actually contain? http://php.net/manual/en/function.var-dump.php
-
Please Help - Echo Statements During Particular Dates And Times
cyberRobot replied to bgareth's topic in PHP Coding Help
Note: this will assign whatever is between the quotes to $date. Use "==" instead: http://php.net/manual/en/language.operators.comparison.php- 4 replies
-
- if statements
- date function
-
(and 3 more)
Tagged with:
-
What does your code look like?
-
First, I think you should simplify. The $query_part_1 and $query_part_2 could be removed. You could change the following: $i=1; foreach($active_keys as $key) { //...move file code here $query_part_1 .= " image" . $i++ . ","; $query_part_2 .= " '" . basename($uploadFilename[$key]). "',"; } $query_part_1 = preg_replace("/,$/","",$query_part_1); $query_part_2 = preg_replace("/,$/","",$query_part_2); $cols[] = $query_part_1; $data[] = $query_part_2; To: $i = 1; $cols = array(); $data = array(); foreach($active_keys as $key) { //...move file code here $cols[] = "image" . $i++; //<-- note that I removed the comma $data[] = basename($uploadFilename[$key]); //<-- note that I removed the quotes } Then just add a space after the comma in the query: //...array_map code here $query = 'INSERT INTO `imloop` (' . implode(', ', $cols) . ') VALUES ("' . implode('", "', $data) . '")'; //...process query here
-
The code doesn't account for the GET variable being passed, so $page is always "1". Instead of if (empty($page)) { $page = "1"; } Try the following: if(isset($_GET['page'])) { $page = $_GET['page']; } else { $page = "1"; } Side Note: I would recommend avoiding PHP_SELF for href attributes. For more information, see Why PHP_SELF Should Be Avoided When Creating Website Links
-
The problem is probably a result of the <br> tag being added to the image name: $image = "http://www.blah.net/...sforsale/".$row['input_image1'] ."<br>";
-
What does your code look like?
-
The extra comma comes from the following code: $query_part_1 .= " image" . $i++ . ","; This just creates a string of column names. It looks like you tried creating an array of column names so you could use the implode() function, but that just results in an array with a single string. Instead, try the following: <?php $cols = array(); foreach($active_keys as $key) { $cols[] = " image" . $i++; } ?> Note that you'll need to get rid of the following line of code, since it's not needed: $cols[] = $query_part_1;
-
Note that code like the following will give a parse error about an unexpected '}'. <td style='color:black;'><?php {$rowNo}; ?></td> You still need an echo statement and the curly quotes aren't needed. Also, the inline styles could be replaced with a style sheet. <tr><td><?php echo $rowNo; ?></td></tr>
-
Adding quotes around the value attribute's value should get rid of the issue. <input type="text" name="first_name" class="inputs" value="<?php echo $input['firstname']; ?>" /> Also note that the <label> tag isn't really doing anything. You need to add an id attribute to the <input> tag. <input type="text" name="first_name" id="first_name" class="inputs" value="<?php echo $input['firstname']; ?>" /> Now clicking the label should put focus into the first_name field.
-
Could you show more of the code? It would be helpful to see how the PHP code modifies the HTML form.
-
Have you tried adding print statements in various spots in the code to see what's getting executed? For example <?php //...snip if(isset($_POST['name'])) { print 'here - name set'; //...snip } ?> You could also try displaying the variables used throughout the code in various spots to make sure they contain what you expect.