-
Posts
22 -
Joined
-
Last visited
Never
Everything posted by manmanman
-
SID (or session ID) is the hash for assigning session variables, i.e. $_SESSION['foo']
-
The timed project, A few questions about various things
manmanman replied to Ninjakreborn's topic in PHP Coding Help
Try using Smarty. -
[quote author=Barand link=topic=110293.msg445631#msg445631 date=1159826644] NO. You don't want to store the br tags in the database Read the FAQ. [/quote] Which FAQ? MySQL or PHP?
-
If I were you, I would ask pixel2life.com. They have ASP and PHP help.
-
Wouldn't you nl2br before submitting it to the database?
-
Try this: [code] <?php if ($_GET['a']="edit") { $result = mysql_query("SELECT * FROM blog WHERE id = '$x'") or die(mysql_error()); $row = mysql_fetch_array($sql); ?> <form method="post" action="?a=edit2&d=<?php echo $x;?>"> <input type="text" value="<?php echo $row['title'];?>" name="title" /> <textarea name="content" rows="20" cols="60"><?php echo $row['content'];?></textarea> <input type="submit" name="submit" value="Submit" /> <?php } elseif ($_GET['a']="edit2") { $x=$_GET['x']; $title=$_POST['title']; $content=$_POST['content']; mysql_query("UPDATE blog SET title='$title' WHERE id = $x"); mysql_query("UPDATE blog SET content='$content' WHERE id = $x"); } ?> [/code]
-
I'm not too sure, but you would probably insert something into the code which replaced new lines with [code]<br />[/code].
-
[quote author=alpine link=topic=110291.msg445609#msg445609 date=1159824761] [quote author=manmanman link=topic=110291.msg445607#msg445607 date=1159824321] Or, this works: [code] $sql = mysql_query("SELECT * FROM blog"); $result = mysql_fetch_array($sql); $x = $result['id']; [/code] [/quote] No - it won't work to list all entries, you will only get the first row on that one! [/quote] Wouldn't you just stick it into the while statement with a delete link, e.g.: [code] <?php $result = mysql_query("SELECT * FROM blog ORDER BY date DESC") or die(mysql_error()); while($row=mysql_fetch_array($result)) { $sql = mysql_query("SELECT * FROM blog"); $result = mysql_fetch_array($sql); $x = $result['id']; echo "<div id=\"blog\">\n" ."<h1>{$row['title']}</h1>\n" ."<p>{$row['content']}</p><br/>\n" ."<h2>Edit Entry | <a href='?a=delete&d=$x'>Delete Entry</a></h2>\n" ."</div>\n"; } ?> [/code] Works for me ;D
-
You could always stick mkPortal ([url=http://www.mkportal.it]http://www.mkportal.it[/url]) over SMF ([url=http://www.simplemachines.org]http://www.simplemachines.org[/url]) or phpBB ([url=http://www.phpbb.com]http://www.phpbb.com[/url]).
-
Or, this works: [code] $sql = mysql_query("SELECT * FROM blog"); $result = mysql_fetch_array($sql); $x = $result['id']; [/code]
-
[quote author=zanus link=topic=110288.msg445591#msg445591 date=1159822713] this should do it [code]if(ereg("[^A-Za-z0-9_-]+", $var)[/code] been out of practice of regex for a while [quote] Ok, reviewing this code, you have missing curly brackets. [/quote] notice his IF statements only have one statement... When your IF statements only do one thing...you don't need curly braces [/quote] I'm a bit forgetful sometimes...
-
Try this; it works on my server: [code] <?php $test = array("Test","Test_11","Test.11","TEST","test","()Test"); foreach ($test as $var){ echo $var." - "; if(!preg_match("/^[A-Za-z0-9_]+$/", $var)) { echo "Doesn't validate"; } else { echo "Does validate"; } echo "<br>"; } ?> [/code] One using regex: [code] <?php $test = array("Test","Test_11","Test.11","TEST","test","()Test"); foreach ($test as $var){ echo $var." - "; if(ereg("[^A-Za-z0-9_-]+", $var)) { echo "Doesn't validate"; } else { echo "Does validate"; } echo "<br>"; } ?> [/code]
-
[quote author=Brentley_11 link=topic=110288.msg445580#msg445580 date=1159821415] Is there a chance that I have php configured wrong? I just tested what you said and it didn't work. [code]$test = array("Test","Test_11","Test.11","TEST","test","()Test"); foreach ($test as $var){ echo $var." - "; if(!ereg("[A-Za-z0-9_-]*",$var)) echo "Doesn't validate"; else echo "Does validate"; echo "<br>"; }[/code] This was the output: [code]Test - Does validate Test_11 - Does validate Test.11 - Does validate TEST - Does validate test - Does validate ()Test - Does validate[/code] The third and last one shouldn't validate. [/quote] Ok, reviewing this code, you have missing curly brackets. Also, doing what alpnie did, removing the [b]-[/b], your code should be like this: [code]<?php $test = array("Test","Test_11","Test.11","TEST","test","()Test"); foreach ($test as $var){ echo $var." - "; if(!ereg("[_A-Za-z0-9]*",$var)) { echo "Doesn't validate"; } else { echo "Does validate"; } echo "<br>"; } ?>[/code]
-
[quote author=zanus link=topic=110288.msg445576#msg445576 date=1159820889] [code] if(!ereg("[A-Za-z0-9_-]*",$_POST['yourVar])) echo "Your POST var doesn't validate"; [/code] [/quote] Hmm... There is a missing quote on the end of yourVar, and also missing curly brackets. Also, I think you should use die() instead of echo. [code] <?php if(!ereg("[A-Za-z0-9_-]*",$_POST['yourVar'])) { die("Your POST var doesn't validate"); } ?> [/code]
-
strip_tags(SID) returns a blank. If I change the session name, then it works for a while, then goes kersplatty. Any idea why this is happening? No warnings or errors appear.
-
Does die automatically terminate mySQL connections? Also, how can I run operations, such as delete unactivated users 48 hours after registration, without using a cron job?
-
I just realised something: [code=php:0]while($result = mysql_fetch_array($result)) { echo "<table border='1'>"; echo "<tr>"; echo "<th>Character Name:</th> <td>".$result['name'] . "</td></tr>"; echo "<th>HP:</th> <td>".$result['mp'] . " </td></tr>"; echo "<th>MP:</th> <td>" . $result['mp'] . " </td></tr>"; echo "<th>EXP:</th> <td>" . $result['exp'] . " </td></tr>"; echo "<th>SP:</th> <td>" . $result['sp'] . " </td></tr>"; echo "</table>"; }[/code] was my original code. I realised this: [code=php:0]while($result = mysql_fetch_array($result)) {[/code] I changed it to: [code=php:0]while($get_result = mysql_fetch_array($result)) {[/code] And now it works.
-
Still the same :(
-
I have another slight hitch: This code only returns one result. I clearly have two entries, but it only returns one.
-
Yay! It works!
-
Does anyone know why this code: [code] echo "<table>" while($result = mysql_fetch_array($sql)) { echo "<tr>"; echo "<th>Character Name:</th> <td>".$result['name'] . "</td></tr>"; echo "<th>HP:</th> <td>".$result['mp'] . " </td></tr>"; echo "<th>MP:</th> <td>" . $result['mp'] . " </td></tr>"; echo "<th>EXP:</th> <td>" . $result['exp'] . " </td></tr>"; echo "<th>SP:</th> <td>" . $result['sp'] . " </td></tr>"; } echo "</table>" [/code] returns a blank? If I remove the while, it works, but I want it executed multiple times if possible. How would I resolve this?