Winstons
-
Posts
52 -
Joined
-
Last visited
Never
Posts posted by Winstons
-
-
Why empty firs body of 'if' ???
if (isset($_POST['escape']) || (isset($_POST['suicide']))) { // Why here is nothing wrote ??? } else { if(empty($_POST['agree'])){ echo "You need to check the box"; }else{ mysql_query("DELETE FROM `users` WHERE `id`= ".(int)($_SESSION['user_id']); } }
-
asurfaceinbetween
Show all code from your php file.
-
You must write as
if(isset($_POST['escape']) || isset($_POST['suicide'])){ // Do something } else { // Else do something }
-
Try write it outside of the 'input' element
<?php echo '<pre>' . print_r($qty, true) . '</pre>'; ?>
What will on screen ?
-
That code is saying, if there is no cookie, then set one?
Yes.
The code was for example
-
melloorr
Your code is incorrect.
Below, my code, it is correct
error_reporting(E_ALL); if(isset($_COOKIE)) { if (isset($_COOKIE['Key_my_site']) && $_COOKIE['Key_my_site'] == $cookiedbid) echo "Your cookie is okay."; elseif (isset($_COOKIE['Key_my_site']) && $_COOKIE['Key_my_site'] !== $cookiedbid) { header("refresh:5;url=index.php" ); echo "You have been logged out because your cookie has been compromised"; setcookie(Key_my_site, 0, $past); } else echo "Your cookie is no longer there."; }
-
(if there was originally no cookie, then i do not get these errors, as the variable is only defined if the cookie is present)
For this, you must do this
if(!isset($_COOKIE['name'])) set_cookie('name', 'value'); else // Do something with existing COOKIE
-
Thank you. It worked perfectly
But you must understand, that hiding errors, also untreated variables is very very bad !
-
At the beginning of php file, write
error_reporting(0);
Or just write '@' before a variable
For example
@$var; // Or @$_COOKIE['name'];
-
Hmm...
Try replace it
<input type="text" name="qty<?php echo $id; ?>" value="<?php echo print_r($qty); ?>" size="3" maxlength="3" class="view_basket_qty" />
To this
<input type="text" name="qty<?php echo $id; ?>" value="<?php echo '<pre>' . print_r($qty, true) . '</pre>'; ?>" size="3" maxlength="3" class="view_basket_qty" />
What you see on the screen ?
-
This is wrong
<?php echo print_r($qty) ?>
You must write just
<?php print_r($qty); ?>
Or this
<?php echo print_r($qty, true); ?>
Last two examples is same.
-
Try it
<?php echo nl2br(bbcode($results['post'])); ?>
-
Tell me, what shows to You
print_r($qtv); // Or print_r($rows);
And where or what, outputs to screen the 'array' ?
-
Write in body of 'foreach'
print_r($qtv);
And if You wrote
while ($rows = mysql_fetch_array($result)) {extract($row);
?>
You must replace extract($row); to extract($rows);
-
Try replace it
$contents[$item] = (isset($contents[$item])) ? $contents[$item] + 1 : 1;
To that
$contents[] = (isset($contents[$item])) ? $contents[$item] + 1 : 1;
-
Do you mean it ?
$basket = $_SESSION['basket']; if ($basket) { $data = preg_split("#[s,]#", $basket); $data = array_chunk($data, 2); foreach($data as $key => $val) echo 'ID ' . $val[0] . '; Size: ' . $val[1] . '<br/>'; }
-
$str = '1s1,12s2,16s3,28s1'; $data = preg_split("#[s,]#", $str); $data = array_chunk($data, 2); foreach($data as $key => $val) echo 'ID ' . $val[0] . '; Size: ' . $val[1] . '<br/>';
-
Try it
$str = '1s1,12s2,16s3,28s1'; $data = preg_split("#[s,]#", $str); $data = array_chunk($data, 2); echo '<pre>'.(print_r($data, 1)).'</pre>';
After, you'll get multi-array, with elements id and size
-
son.of.the.morning
Show your code.
SergeiSS
Hello from phpforum.ru by Winston
-
www.goog isn't a complete url
www - is correct domain name
goog - goog, too, fits the pattern.
therefore believes it is right RegExp.
If you you want correct url get, you must to enumerate a list of domains
Try it
$str = ' www.google.com http://google.com https://google.com http://www.google.com https://www.google.com google.co.uk www.google.co.uk http://google.co.uk https://google.co.uk http://www.google.co.uk https://www.google.co.uk www.goo go.ru google.lol '; preg_match_all("#(?:https?://)?(?:www\.)?[-a-z\d]{2,9}\.(?(1)[-a-z\d]{2,5}|(?:co|com|uk|us|ru|org|net))(\.[-a-z\d]{2,4})?#is", $str, $match); echo '<pre>'.(print_r($match, 1)).'</pre>';
-
thanks. how would one use that if ? : statement in this context
The ternary operator ?
Do you mean it ?
$num = '07654'; $check = substr($num, 0, 2); echo $check == '07' ? 'OK' : 'BAD';
-
Try that
$num = '07654'; $check = substr($num, 0, 2); if($check == '07') echo 'OK'; else echo 'BAD';
-
Use the test by 'if'.
If all is OK, do redirect
-
Try set
date_default_timezone_set('Europe/London');
At beginning your php file.
Proper way of using OR with two if commands
in PHP Coding Help
Posted
Shadowing
Why it is empty ?