kenrbnsn
Staff Alumni-
Posts
8,234 -
Joined
-
Last visited
Everything posted by kenrbnsn
-
You have to concatenate anything else onto the $message variable if you want more to appear in the email message. Where you have: <?php if (!empty($title1)) { echo '<br/>$title1:'; } if (!empty($title2)) { echo '<br/>$title2:' ; } if (!empty($title3)) { echo '<br/>$title3:'; } if (!empty($title4)) { echo '<br/>$title4:'; } if (!empty($title5)) { echo '<br/>$title5:'; } if (!empty($title6)) { echo '<br/>$title6:'; } if (!empty($title7)) { echo '<br/>$title7:'; } if (!empty($title8)) { echo '<br/>$title8:'; } ?> If you want those strings in the message you have to do something like <?php if (!empty($title1)) { $message .= '<br/>$title1:'; } if (!empty($title2)) { $message .= '<br/>$title2:' ; } if (!empty($title3)) { $message .= '<br/>$title3:'; } if (!empty($title4)) { $message .= '<br/>$title4:'; } if (!empty($title5)) { $message .= '<br/>$title5:'; } if (!empty($title6)) { $message .= '<br/>$title6:'; } if (!empty($title7)) { $message .= '<br/>$title7:'; } if (!empty($title8)) { $message .= '<br/>$title8:'; } ?> And then, after the "// etc..." <?php $message .= "</th> </tr> <tr> <th>Price:</th> <th>$total </th> </tr> <tr> <th>Registrant:</th> <th>$name</th>"; ?> Ken
-
PHP execute linux terminal command (bash Script)
kenrbnsn replied to tim967's topic in PHP Coding Help
Does the user that the webserver is running under have permission to do a sudo? Ken -
Yes there is. You have to terminate the string with a "; or else you get the error you're getting. <?php $message = "<html> <style type='text/css'> #apDiv1 { position:absolute; left:338px; top:278px; width:311px; height:129px; z-index:1; } #apDiv2 { position:absolute; left:50px; top:207px; width:181px; height:149px; z-index:2; } #apDiv2 { text-align: center; } </style> </head> <body><div id='apDiv1'> <table width='408' border='1' cellspacing='2' cellpadding='2'> <tr> <th width='90' scope='col'>Event(s):</th> <th width='298' scope='col'>"; // <----- see the added "; ?> Ken
-
You could do something like this: <?php $tmp = array('tech'=>$tech,'crew'=>$crew,'number'=>$number); foreach ($tmp as $f=>$v) { if ($v == '') { $tmp[$f] = 'Not Assigned'; } } ?> When you want to use the value, you would need to get the value from the array. Ken
-
I tested with: <?php $json_str = '{ "email": "l-wilson-1986@hotmail.co.uk", "titleitalic": "normal", "profileDetails": "#d0deea", "titlefontcolor": "none", "titleoffsettop": 100, "titleoffsetleft": 100, "aboutbackgroundcolour": "transparent", "aboutunderline": "none", "aboutfontfamily": "Arial", "aboutbold": "normal", "aboutitalic": "normal", "aboutfontcolor": "#d0deea", "aboutoffsettop": 325, "aboutoffsetleft": 100, "statusoffsetleft": 450, "statusinfooffsetright": 250, "pictureoffsetleft": 100, "profilebold": "normal", "profileunderline": "none", "profileitalic": "normal", "profilefontcolor": "#fff", "profilefontfamily": "Arial", "profilebackgroundcolour": "#2c3c49" }'; $x = json_decode(($json_str),true); echo '<pre>' . print_r($x,true) . '</pre>'; $json_errors = array( JSON_ERROR_NONE => 'No error has occurred', JSON_ERROR_DEPTH => 'The maximum stack depth has been exceeded', JSON_ERROR_CTRL_CHAR => 'Control character error, possibly incorrectly encoded', JSON_ERROR_SYNTAX => 'Syntax error', ); echo 'Last error : ', $json_errors[json_last_error()], PHP_EOL, PHP_EOL; ?> And it works fine. There has to be something wrong with the incoming string. If you have magic quotes turned on there are probably backslashes escaping the quotes in the string. Use stripslashes on it before passing it to json_decode <?php $myjson = stripslashes($_POST['jsonstring']); ?> Ken
-
Why are you trying to create a directory using a URL: <?php mkdir("http://multi-search.org/BSGN/$secure_folder", 0777); ?> The mkdir function takes a path to the directory in the local filesystem. Ken
-
The variable birthday and telephone are not INSERT INTO
kenrbnsn replied to co.ador's topic in PHP Coding Help
The format for storing the date really has no relation to how you present it to the user. Present it to the user the way they are use to seeing it. Ken -
another code..got a problem...can someone help me again
kenrbnsn replied to cruxaders's topic in PHP Coding Help
This line <?php $sql = "SELECT * FROM `users` WHERE `id`='".username."'"; ?> probably should be <?php $sql = "SELECT * FROM `users` WHERE `id`='$username'"; ?> Ken -
When I run your code, I get: Plus you're not echoing the result. Try: <?php class findName { private $name; public function setName($sname='') { if(!$sname) { $this->name = "There is no name to return."; } else { $this->name=$sname; } } public function getName() { return $this->name; } } $n = new findName(); $n->setName(); echo $n->getName() . "<br>\n"; ?> Ken
-
You're missing the terminating quote and semi-colon at the end of this string: <?php $message = "<html> <style type='text/css'> #apDiv1 { position:absolute; left:338px; top:278px; width:311px; height:129px; z-index:1; } #apDiv2 { position:absolute; left:50px; top:207px; width:181px; height:149px; z-index:2; } #apDiv2 { text-align: center; } </style> </head> <body><div id='apDiv1'> <table width='408' border='1' cellspacing='2' cellpadding='2'> <tr> <th width='90' scope='col'>Event(s):</th> <th width='298' scope='col'> ?> Ken
-
You seem to be posting code sections, not continuous code, since the code you posted has a mixture of HTML and PHP with the starting "<?php" tag. Please post all of the code. Ken
-
If you do a show source on the web page, you will see that the & was changed to &. It's just that the browser is display a "&" for the "&" Ken
-
Sure it works. You can do that with any array. Instead of asking the question and waiting for a reply, it's easy enough to try it in a quick script. Ken
-
Be carefull with empty, since it can return a false positive if the string being checked contains a single zero: <?php $x = '0'; if (empty($x)) echo "$x is empty<br>\n"; else echo "$x is not empty<br>\n"; ?> The above code will print 0 is empty Ken
-
Try: <?php $sites = array_map('trim',file('file.txt')); //read the whole file into an array & trim the newline character from the end of each line foreach ($sites as $link) { echo "<a href='$link'>$link</a><br />"; } ?> Ken
-
What does the content of the file look like? Ken
-
This line <?php mail(isInjected($to), isInjected($subject), isInjected($message), isInjected($headers)); ?> is not going to work, since the function isInjected() returns only a "true" or "false" value and the mail() function is expecting strings as parameters. Do the calls before calling mail() and only do the mail() function if all the returned values are "true". Ken
-
Please show us your code between tags. Ken
-
Please post your current code. Ken
-
You can try reversing the single and double quotes: <?php $isql = oci_parse($conn, "INSERT INTO 'useridA' VALUES ('$userid')"); ?> Ken
-
If you want help on the forum, the quickest way to get it is to post your code here between tags. Ken
-
You have to explain why it's not working. "still isn't working" doesn't tell us very much. PHP errors? MySQL errors? Logic errors? Ken
-
If this is the line <?php $q = "SELECT * FROM pages WHERE subject_id = {$row['id']"; ?> you're missing the terminating "}" after the "]": <?php $q = "SELECT * FROM pages WHERE subject_id = {$row['id']}"; ?> Ken
-
You need a condition on each piece of the WHERE, try: <?php $sql = "SELECT `user_id`, `friend_id` FROM `partners` WHERE `user_id` = '${user_info['uid']}' OR `friend_id` = '${user_info['uid']}'"; ?> Ken
-
Using the "{}" around an array reference within a string delimited by double quotes is fine. With MySQL you don't need to include the connection in the MySQL function call, it is optional. You need to include it in the MySQLi function call. To the OP, please use my code and post the exact message that is displayed on the browser and please don't SHOUT. Ken