-
Posts
9,409 -
Joined
-
Last visited
-
Days Won
1
Everything posted by MadTechie
-
Erm.. okay is users a class ? where did you get $db = ('users'); from ?
-
Looking at the code I don't know, however try this <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <script type="text/javascript"> function insertAtCaret(obj, text) { if(document.selection) { obj.focus(); var orig = obj.value.replace(/\r\n/g, "\n"); var range = document.selection.createRange(); if(range.parentElement() != obj) { return false; } range.text = text; var actual = tmp = obj.value.replace(/\r\n/g, "\n"); for(var diff = 0; diff < orig.length; diff++) { if(orig.charAt(diff) != actual.charAt(diff)) break; } for(var index = 0, start = 0; tmp.match(text) && (tmp = tmp.replace(text, "")) && index <= diff; index = start + text.length ) { start = actual.indexOf(text, index); } } else if(obj.selectionStart) { var start = obj.selectionStart; var end = obj.selectionEnd; obj.value = obj.value.substr(0, start) + text + obj.value.substr(end, obj.value.length); } if(start != null) { setCaretTo(obj, start + text.length); } else { obj.value += text; } } function setCaretTo(obj, pos) { if(obj.createTextRange) { var range = obj.createTextRange(); range.move('character', pos); range.select(); } else if(obj.selectionStart) { obj.focus(); obj.setSelectionRange(pos, pos); } } </script> </head> <body> <form name="form"> <input type="button" value="Insert text" onclick="insertAtCaret(this.form.text, this.form.string.value)"> <input type="text" name="string"><br /> <textarea name="text" cols="60" rows="10"></textarea> </form> </body> </html>
-
Your echoing the link to the browser! if you need to send it to the browser then your can't really hide it, it looks like your attempting to hide video links, if so then you maybe better off using sessions and a flash loader, and have flash read from a hidden php file that generates a filename from a session
-
$db isn't being set you should have something like $db = new ..blar..
-
[SOLVED] display multiple records from 2 tables
MadTechie replied to reece_1989's topic in MySQL Help
I've clicked solved (bottom left) as i think this is solved but really you should be clicking it -
Well your assume that it was part of the URL used to access the page and not a URL in a database or a document,
-
link to results rather than automatically displaying
MadTechie replied to DanielHardy's topic in PHP Coding Help
I changed the way it builds the text file and also change to display the LAST 5 message <form id="form1" name="form1" method="post" action=""> <label> <div align="center"> <table width="100" border="0"> <tr> <td height="20"><p> <strong><center>Name</strong><br /> <input type="text" name="name" id="name" /> <br /> <br /> <p><strong>Message</strong><br /> <textarea name="message" id="message" cols="16" rows="6"></textarea> </p> <p> <input type="submit" name="button" id="button" value="Submit" /> <input type="reset" name="button2" id="button2" value="Reset" /> </p></td> </tr> </table> </div></label> </form> <?php $guestbook = "messages.txt"; if (isset($_POST['button'])) { if (!empty($_POST['name']) && !empty($_POST['message'])) { $badSearch = array("@", "."); $goodSearch = array(" @ ", " . "); $string .= "<b>" . $_POST['name'] . " "; $string .= str_replace($badSearch, $goodSearch, $_POST['email']) . "</b>"; $string .= "<font color=#2766c5>" . $_POST['message'] . "</font><hr>\n"; $file = fopen($guestbook, "a"); fwrite($file, nl2br(strip_tags($string, "<b><hr><font>"))); fclose($file); echo '<script>alert("Your comment has been added ")</script>'; } else { echo '<script>alert("Please fill out the whole form")</script>'; } } $full = false; //condition for testing 5 lines if($full) { $readfile = fopen($guestbook, "r"); echo @fread($readfile, filesize($guestbook)); fclose($readfile); }else{ $lines = file($guestbook); $lastline = count($lines); for($n=$lastline-5;$n<=$lastline;$n++) { echo $lines[$n]; } } ?> -
link to results rather than automatically displaying
MadTechie replied to DanielHardy's topic in PHP Coding Help
can you change $full = false; to $full = true; just to check EDIT: also a example of the messages.txt would be useful (in code tags) -
link to results rather than automatically displaying
MadTechie replied to DanielHardy's topic in PHP Coding Help
No luck? so didn't work.. did anything display ? did you get an error ? -
While I'll like to say your welcome.. I'm not 100% sure your code will work correctly, does the prefix's still hold their values ? you could setup all the parameters again and pass them back but i fine it easier in the long run to just strip out the keys i want to replace and set new ones for example update on change <SELECT name="sortname" onchange="Sort(document.sortby.sortname.options[document.sortby.sortname.selectedIndex].value)"> add JS <script language="javascript"> function Sort(sort) { var url = window.location.href; url = url.replace(/&?column_name=[^&]*&?/g, ""); window.location=url+'&column_name='+sort; } </script> I think I'll move this to the javascript section
-
link to results rather than automatically displaying
MadTechie replied to DanielHardy's topic in PHP Coding Help
okay this is the part that displays the entries $readfile = fopen($guestbook, "r"); echo @fread($readfile, filesize($guestbook)); fclose($readfile); try something like this $full = false; //condition for testing 5 lines if($full) { $readfile = fopen($guestbook, "r"); echo @fread($readfile, filesize($guestbook)); fclose($readfile); }else{ $lines = file($guestbook); foreach ($n=0;$n<=5;$n++) { echo $lines[$n]; } } -
good feeling when you fix something like that can you click the topic solved button (bottom left)
-
[SOLVED] Inserting many values using a loop
MadTechie replied to littlevisuals's topic in PHP Coding Help
Well technically I forgot but i never test my code here, and your welcome -
here's a quick example to get you started <FORM name="sortby"> <SELECT name="sortname" onchange="window.location='?column_name='+document.sortby.sortname.options[document.sortby.sortname.selectedIndex].value"> <OPTION <?php echo ($_GET['column_name'] == 'name')?"SELECTED":""; ?> value="name">name <OPTION <?php echo ($_GET['column_name'] == 'other')?"SELECTED":""; ?> value="other">other <OPTION <?php echo ($_GET['column_name'] == 'price')?"SELECTED":""; ?> value="price">price </SELECT> </FORM>
-
[SOLVED] Inserting many values using a loop
MadTechie replied to littlevisuals's topic in PHP Coding Help
your missing a semi-colon $results = mysql_query($query); //<--here -
[SOLVED] Inserting many values using a loop
MadTechie replied to littlevisuals's topic in PHP Coding Help
your need to change the html so the checkbox becomes an array change the name value like name="cat_id[]" then of course $_POST['cat_id']; will also be an array, so you can loop that, for example foreach($_POST['cat_id'] as $cat_ID) { $query = "INSERT INTO image_catlu (cat_ID, image_ID) VALUES ('$cat_ID', '$image_ID')"; $results = mysql_query($query) } however i have no idea where $image_ID is coming from or what your attempting to do here $sql = "SELECT id,cat FROM catorgories ORDER by id ASC"; "SELECT id,id FROM gallery"; -
You can't via PHP, that's HTML and JS create as drop down (HTML) then onchange, change the address location to include ?column_name=X or use ajax (but the same idea) you can adapt any redirect via drop down script
-
Welcome, this problem can be common hence the reason I pointed to the link, i think its better to learn then just giving the solution. Light a man a fire your keep him warm for a night, light a man on fire your keep him for for the rest of his life!
-
Yes I know, Hence!
-
very close but ? mean optional so php? means ph or php and . means any so member(any character)ph and $ also has special meaning at then end, it means last So we need to escape ? and . also [0-9] can be shorted to \d so to sum up, try <?php preg_match('/member\.php\?u=(\d+)$/', $url, $mem_id); ?> EDIT; this mean ends with number and before that has member.php?u=
-
see what error you get $SQL = "select count(*) from mail where to='$username'"; $mail = mysql_query($SQL) or die(mysql_error().$SQL); $inbox = mysql_result($mail, 0) echo("View Inbox ($inbox)<br/>"); remember TO check for reserved words, these can be resolved via back ticks (`) but its better to change the field name EDIT: MySQL 5.1 section 8.3. Reserved Words
-
it seam you have one already via ?column_name=price
-
Read the manual mysql_result mysql_result($mail, 0)
-
I'm confused, do you want to allow duplicate names or not ? this class a duplicate as having the same first AND last name only
-
Well you marked this as solved, so i assume you found the problem!