JAY6390
Members-
Posts
825 -
Joined
-
Last visited
Everything posted by JAY6390
-
Are you wanting all letters to have the same character after them? or each one different?
-
function replace_chars($text) { echo '<pre>'.print_r($text, true).'</pre>'; return str_repeat('*', strlen($text[0])); } $text = 'this is a #test'; $result = preg_replace_callback('/(?<!#|[a-z])[a-z]+/i', 'replace_chars', $text); echo $result;
-
In your .htaccess file put RewriteEngine on RewriteCond %{HTTP_HOST} ^1\.1\.1\.1$ RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [R=301,L]
-
Not sure, I've not created a thread myself
-
set the field to auto increment http://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html
-
You can just add it to the die statement, or do the error handling the traditional way of $result = mysqli_query($dbc,$query); if(!$result) { echo "MySQL Error:" . mysqli_error($dbc); die('We are sorry, your email could not be sent at this time. Please try again in a few minutes'); }
-
Thats because you run the echo line BEFORE the query is run (ie before mysqli_query(...))
-
mysqli_error($dbc)
-
You're welcome
-
%s is used with the sprintf() to replace areas with variables. It's just a neater way of putting variables into a string. %s will be replaces with the $_GET['id'] variable
-
Excellent, no problem
-
Hi rondog Try this code $query = "SELECT bins.user_id FROM bins LEFT JOIN clips ON clips.bin_id = bins.id WHERE clips.id = '%s'"; $result = mysql_query(sprintf($query, mysql_real_escape_string($_GET['id']))); if (!$result) { die(mysql_error()); } $user_id = mysql_fetch_array($userQuery); if ($_SESSION['userid'] != $user_id['user_id']) { echo "you dont have access to that clip"; } else { echo "show them clip stuff"; } Also be sure that you use session_start(); at the top of your script, or the session wont be active
-
have a counter in a session, that has the current page number. If the user is trying to access page 4 and the counter is already page 4 then the user has refreshed the page. You can similarly do this to check that they aren't going back in the process as well (you will need to disable the page caching as well)
-
$query = "SELECT bin_id FROM clips WHERE clips.id = '".mysql_real_escape_string($_GET['id'])."' LEFT JOIN bins WHERE bins.id = clips.bin_id"; $result = mysql_query($query); if(!$result) { //No results found code here }else{ $data = mysql_fetch_assoc($result); $user_id = $data['user_id']; Untested, but something like that should get you started
-
http://en.wikipedia.org/wiki/Access_control_list
-
Create a login script, use sessions to remember the person that is logged in and use access control to [dis]allow people access to the profiles
-
Two options. Either via the DOM http://www.jaygilford.com/php/php-dom-get-all-pagelinks/ or using regex http://www.jaygilford.com/php/common-questions/how-to-get-all-links-from-a-web-page/
-
In that case, use something like pastebin.org and post the link
-
Very close Mike
-
Try with {$currency_iso_GBP} as just GBP
-
echo '<table><tr>'; foreach($answers as $value){ if (in_array($value, $wrong)){ $class = "wrong"; } else { $class = "correct"; } echo "<td class=\"$class\">$value</td>"; } echo '</tr></table>';
-
I don't think it's actually possible to do this unless you have the values within a node
-
Use MySQL's built in date formatter //build query $query = "SELECT DATE_FORMAT(`date_entered`, '%D %M %Y) as `formatted_date` FROM table WHERE field1='xxx' AND field2='yyy'"; $result = mysql_query($query); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo $row['formatted_date']; } EDIT: Cags beat me to it
-
Extract some data from a variable and put it in another
JAY6390 replied to primefalcon's topic in PHP Coding Help
eek eregi! Yeah regular expressions are great -
Extract some data from a variable and put it in another
JAY6390 replied to primefalcon's topic in PHP Coding Help
ah oops, total screw up on my part, it is still too early to think Try this $variable = "a bunch of stuff that [rofl]that isn't here[/rofl]or is it?"; preg_match('%\[rofl\](.*?)\[/rofl\]%i', $variable, $out); $variable = str_replace($out[0], '', $variable); $variable2 = $out[1]; echo $variable.'<br />'.$variable2;