-
Posts
9,409 -
Joined
-
Last visited
-
Days Won
1
Everything posted by MadTechie
-
i Believe that INSERT INTO password (id, password,salt) VALUES('00010','abc','abcde'); fails because the User with that foreign key doesn't exist, is the ID really 00010 ? or 10 ? Try entering the students details and confirm they are in the database, then try the password
-
You may want to remove the 4th parameter from the str_replaces (the ",1" ) Brain is fried.. as its 3am here in the UK!
-
Okay Here is a test file Note that your need to remove the function convert_youtube($code,$code1) at the bottom and change $txt = str_replace($match[0], convert_youtube($match[2],$match[3]), $txt,1); to $txt = str_replace($match[0], $this->convert_youtube($match[2],$match[3]), $txt,1); if you choose to apply this code, have a test and see if it suites <?php $txt = '[quote][youtube]http://youtube.com/watch?v=ABCD[/youtube][/quote] [youtube]http://youtube.com/watch?v=ABCD[/youtube] [quote][youtube]http://youtube.com/watch?v=ABCD[/youtube][/quote] [youtube]http://youtube.com/watch?v=ABCD[/youtube] [quote][youtube]http://youtube.com/watch?v=ABCD[/youtube][/quote] [youtube]http://youtube.com/watch?v=ABCD[/youtube] '; $RegEx = '%(\[quote\].*?)?\[youtube\]http\://(.*?)youtube\.com/watch\?v\=(.*?)\[/youtube\](.*?\[/quote\])?%ie'; if(preg_match_all($RegEx, $txt, $matches,PREG_SET_ORDER)){ foreach($matches as $match){ if(!empty($match[0]) && empty($match[1]) && empty($match[4])){ $txt = str_replace($match[0], convert_youtube($match[2],$match[3]), $txt,1); }else{ $txt = str_replace($match[0], sprintf('%s<a href="http://%syoutube.com/watch?v=%s">LINK</a>%s',$match[1],$match[2],$match[3],$match[4]), $txt,1); } } } echo $txt; function convert_youtube($code,$code1){ return '<embed src="http://'.$code.'youtube.com/v/'.$code1.'" type="application/x-shockwave-flash" wmode="transparent" width="512" height="313" allowfullscreen="true" />'; }
-
Ahh i assume theirs text before and after the link.. I'll revise it
-
Maybe change $txt = preg_replace( "`(?<!\[quote\])\[youtube\]http://(.*?)youtube\.com/watch\?v=(.*?)\[/youtube\](?!\[/quote\])`ie" , "\$this->convert_youtube('\\1','\\2')", $txt ); to $txt = preg_replace( "`\[youtube\]http\://(.*?)youtube\.com/watch\?v\=(.*?)\[/youtube\]`ie" , "\$this->convert_youtube('\\1','\\2')", $txt ); I think that will work
-
Oh got it.. i read it again So Link becomes <embedded>youtube</embedded> But you want Link to become Right ?
-
Huh! Sorry .. can you give an example do you mean, like this You get this But want
-
special character from db, GOOD ... from php, BAD
MadTechie replied to dsdsdsdsd's topic in PHP Coding Help
Most editor don't display the encoding but it is their, If your editing the file in dreamweaver, then your need to tell DW that the file needs to be UTF-8 Edit->preferences->New Document->encoding (set to UTF- then create a new document and copy the contents from the old file to the new one, (if the text is look wrong your need to re-enter the text) here is an example of 2 files. http://madtechiesupport.com/phpfreaks/UTF8/ASCII.php http://madtechiesupport.com/phpfreaks/UTF8/UTF-8.php and the code http://madtechiesupport.com/phpfreaks/UTF8/code.zip Now your see that the UTF-8 file had this $array = array( 'Hello', '¡Hola', 'مرحبا', 'Γεια σας', '您好', ); While the ascii has $array = array( 'Hello', '¡Hola', '?????', 'Ge?a sa?', '??', ); If you open the ascii.php and type any special chars they won't display because the file is ascii encoded, BUT they will work in the UTF-8 file. So the question is does the text display correctly in the file (when in the editor) do you have a sample we can see ? -
okay i have cleaned up the code a little if you use these parameters ?id=123&favorites=456 result ?id=123 result ?favorites=456 result ? result Here is the code <?php session_start(); define('DB_HOST', 'localhost'); define('DB_USER', 'mydbuser'); define('DB_PASSWORD', 'mydbpass'); define('DB_DATABASE', 'mydbname'); $errmsg_arr = array(); $errflag = false; $insert = array(); $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if (!$link) die('Failed to connect to server: ' . mysql_error()); $db = mysql_select_db(DB_DATABASE); if (!$db) die("Unable to select database"); if(empty($_GET['id'])){ $errmsg_arr[] = 'id is missing.'; } if(empty($_GET['favorites'])){ $errmsg_arr[] = 'favorites is missing.'; } $insert = array(); if (isset($_GET['id'])) { $insert[] = 'id = \'' . clean($_GET['id']) . '\''; } if (isset($_GET['favorites'])) { $insert[] = 'favorites = \'' . clean($_GET['favorites']) . '\''; } if(empty($errmsg_arr)) { echo "its working!<br />"; echo implode('<br />', $insert); }else{ $_SESSION['ERRMSG_ARR'] = $errmsg_arr; echo "its failed!<br />"; echo implode('<br />', $errmsg_arr); } function clean($var) { return mysql_real_escape_string(strip_tags($var)); }
-
what your need to do is add a routine to allow lookups by UserName, for example I assume it currently has a SQL statement like this SELECT * FROM Users WHERE userID= $_GET['id'] your need to update it to something like this SELECT * FROM Users WHERE username= $_GET['username'] then add the htaccess RewriteEngine on RewriteRule showmember/([^/]+)\.html$ /?act=$1&username=$2 [L] Now in the showmember.php file, i assume you have if(isset($_GET['id'])){ $query = mysql_query("SELECT * FROM Users WHERE userID=%d",$_GET['id']); } you could update that so it handles both ie if(isset($_GET['id'])){ $query = mysql_query("SELECT * FROM Users WHERE userID=%d",$_GET['id']); }elseif(isset($_GET['username'])){ $query = mysql_query("SELECT * FROM Users WHERE userID=%d",$_GET['id']); }
-
As ODBC is used to connect to a database, I'm not sure what your trying to do! What you are attempting to do isn't that hard, but i guess its what you want the end result to be.. for example once these details have been submitted how do you plan do access them ? why must it be ODBC ? etc --MadTechie
-
Its bad for SEO, BUT required for code But as your going to be using pretty URL's that are good for SEO, so it will cancel out the bad So here is the logic <?php echo "Action ".$_GET['act']; echo "\n<br />"; echo "I am Member ".$_GET['id']; ?> Add .htaccess RewriteEngine on RewriteRule ([^/]+)/([^/]+)\.html$ /?act=$1&id=$2 [L] Now test test links (OLD style) with 2 gets http://www.mysite.com/?act=showmember=&id=davie33 http://www.mysite.com/?act=killuser=&id=davie33 test links (NEW style) with well none! http://www.mysite.com/showmember/davie33.html http://www.mysite.com/killuser/davie33.html
-
special character from db, GOOD ... from php, BAD
MadTechie replied to dsdsdsdsd's topic in PHP Coding Help
IT should work from the PHP variable as well, I am going to assume you believe it doesn't as you have typed it into the code and fails, this is because the PHP file itself is not UTF-8, for example if you read the text from the database then it will go into a PHP variable, and then you should be able to echo it out (assuming you have a UTF-8 char-set). I don't think your missing anything but then again I'm not sure of the question/problem! :-\ -
the URL should be http://www.mysite.com/delete.php?favorites=favorites&id=0 or http://www.mysite.com/delete.php?favorites=whateveritis&id=0
-
If that .htaccess file exists and apache mod_rewrite is on, then both links 1. http://www.mysite.com/showmember/davie33.html 2. http://www.mysite.com/showmember=ABC=davie33 will go to index.php Where as without the .htaccess file only link 2 would work the PHP would just need to use $_GET['showmember'] to get davie33 **Correction!** showmember=ABC=davie33 ??? this that right ? I assume you mean ?act=ABC&id=davie33 Update .htaccess to RewriteRule ([^/]+)/([^/]+)\.html$ /?act=$1&id=$2 [L] thus $_GET['id'] would be davie33 and $_GET['act'] would be showmember
-
try this RewriteEngine on RewriteRule ([^/]+)/([^/]+)\.html$ /act=$1=$2 [L] and this http://www.mysite.com/ABC/davie33.html should become http://www.mysite.com/act=ABC=davie33 OR RewriteEngine on RewriteRule showmember/([^/]+)\.html$ /act=showmember=$1 [L] for sticky showmember
-
Hmm, I hate to state something contrary to your instructor, but that's a very poor 'solution' in my book. You should almost never 'mask' errors. I have to agree totally with mjdamato, here.... bugs the hell out of me! seeing them
-
Is it possible to create a form using only PHP
MadTechie replied to Matt Ridge's topic in PHP Coding Help
You need to update your form attributes echo '<form id="all">'; Needs a method and Action Other than that you can handle it like any other form -
Maybe try increasing the height
-
Lengthening session with htaccess and php_value?
MadTechie replied to Someone2's topic in PHP Coding Help
No Worries, I have just moved and only have a temporary internet connection myself (well at least for a few more days) -
This is just a quick reply as its 5am here and i am about to get some sleep.. however I can't remember exactly but when reading this I remembered an extended class called multi cell details here, that may help..
-
submit form not working with firefox 7 or chrome
MadTechie replied to nomanoma's topic in PHP Coding Help
well your missing </Center> (on both forms) -
is there a way to write a code to detect browser plugins?
MadTechie replied to Hall of Famer's topic in PHP Coding Help
First rule.. never trust user input..if you user can submit it then its untrusted, What it seams you are doing is creating the html that reflects what the users should be able to purchase, so far so good Then they select a pet and the form posts that pets id back to a script to add it to their.. erm basket! (whatever) Logically that's fine BUT what happens if the user passes a pet id of a pet they can't have ? well currently they get that pet.. but why i hear you ask! Well lets look at the logic again "Then they select a pet" So this is your "protection" "the form posts that pets id back to a script to add it to their.. erm basket! (whatever)" Well here is the problem, their is nothing stopping them posting any pet id, So what you need to do is add the same protection to the adding as you did for the displaying.. if you look back on the example i posted, this is the display foreach($items as $id => $item){ echo $item['Name']; if($item['Price'] <= $money){ echo ' <a href="?do=purchase&id='.$id.'">Buy Now</a>'; }else{ echo ' <a href="javascript:alert(\'Need more money\');">need more funds</a>'; } echo "<br />"; } and this was the Purchasing //Purchase if(!empty($_GET['do']) && !empty($_GET['id']) && $_GET['do'] == 'purchase'){ if($items[$_GET['id']]['Price'] <= $money){ //Added IF statement echo "<p>You have purchased the ".$items[$_GET['id']]['Name']."</p>"; } } Now as per the example, i could enter any value and get the "large gun" To stop this i added the same logic used in the display to the purchasing So display had this if($item['Price'] <= $money) i could of written it like this (same thing) if($items[$id]['Price'] <= $money) So for purchasing i added this if($items[$_GET['id']]['Price'] <= $money) so it became //Purchase if(!empty($_GET['do']) && !empty($_GET['id']) && $_GET['do'] == 'purchase'){ if($items[$_GET['id']]['Price'] <= $money){ //Added IF statement echo "<p>You have purchased the ".$items[$_GET['id']]['Name']."</p>"; } } So now the display only has the buy option on items they can buy and once they script is requested to add that item i check they can buy what they have selected to buy.. It would be kinda hard to give you exact detail as i am not sure what the conditions are for adopting the pets, the problem would most likely be in "poundpost.php" but its hard to say!.. really need some more info about what should happen and what is happening, then i'll know what code to see (it will be the display then the process request) --Hope that helps, PS i did create an account to see but i need the eggs at level 5 before i can breed them, so i am not sure where the problem currently is.. -
Lengthening session with htaccess and php_value?
MadTechie replied to Someone2's topic in PHP Coding Help
Does your login have all the same steps as the create_logon function? if their is a problem is probably a header sent before the cookie, try this one (that doesn't check the cookies function check_logon(){ if( isset($_SESSION['HTTP_USER_AGENT']) ) { if ($_SESSION['HTTP_USER_AGENT'] == md5($_SERVER['HTTP_USER_AGENT']) ) { session_regenerate_id(true); //generate new ID and remove the old one return true; } } return false; } of course your still need this line in your login function $_SESSION['HTTP_USER_AGENT'] = md5($_SERVER['HTTP_USER_AGENT']); EDIT: don't worry about asking questions.. (its kinda the reason for this forum ) -
sometimes your need to prefix your account name to the username of the database, E.g. Account: myAcc Database Name: test Database UserName: user Database Password: pass So the details could be mysql_connect("localhost", "user", "pass"); mysql_select_db("test"); or even mysql_connect("localhost", "myAcc_user", "pass"); mysql_select_db("myAcc_test"); it depends on the host