Jump to content

wildteen88

Staff Alumni
  • Posts

    10,480
  • Joined

  • Last visited

    Never

Everything posted by wildteen88

  1. This is what is happing: PHP is replacing [br] in to <br> correctly and returning the new value back into user_input but as PHP gets to the end of the arrays it'll remove the following symbols < and > This is why you get br instead of <br>. What you should so is replace all symbols first then convert your bbcodes into html using regex rather than str_replace. <?php if(isset($_POST['newprofile'])) { $profile = $_POST['newprofile']; // remove bad symbols using str_replace first $new_pro = str_replace(array('<', '/>', '>'), '', $profile); // now we'll convert the bbcodes using regex: $bbcodes = array( '|\[b\](.*)\[/b\]|is', '|\[i\](.*)\[/i\]|is', '|\[u\](.*)\[/u\]|is', '|\[img=([a-z]+?://){1}(.+?)\]|is', '|\[url\](.*?)\[/url\]|is', '|\[hr\]|is' ); $html = array( '<b>\\1</b>', '<i>\\1</i>', '<u>\\1</u>', '<img src="\\1\\2" />', '<a href="\\1" target="_blank" title="">\\1</a>', '<hr />' ); $new_pro = preg_replace($bbcodes, $html, $new_pro); echo nl2br($new_pro); } ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <textarea name="newprofile" cols="80" rows="10"><?php echo @$_POST['newprofile']; ?></textarea><br /> <input type="submit" value="submit" /> </form>
  2. Umm... Intresting. This the secound time this has happened. Download the attached file instead, rename to test.php [attachment deleted by admin]
  3. If you are working with tables. Turn table borders on so you can see the boundaries for the cells. Also it may help if we can get to see the actuall HTML source code fro that page. Its kinda hard to tell why it's doing that.
  4. $entries = array(); while ($entry=pg_fetch_row($result)) { // ad entry to entries array $entries[] = $entry; //do stuff } echo '<prr>' . print_r($entries, true) . '</pre>';
  5. Not sure but I think you can. What you'll want to do is install them on different ports/sockets, such as 3306 and 3307 then when you connect to one of the databases you'd supply the port/socket for the server in mysql_connect eg: $server1 = mysql_connect('localhost:3306', 'root'); // server 1 runs on port 3306 (default installation port) $server2 = mysql_connect('localhost:3307', 'root'); // server 1 runs on port 3307 The number after the : defines the port number.
  6. Just to make sure its not the script a fault, run the following: <?php echo "Detecting Mysql: "; if(extension_loaded('mysql')) { echo "MySQL Extension loaded<br />\n<br />\n"; } else { die('MySQL Extension no loaded wont be able to continue'); } echo "Defining MySQL credentials...<br />\n"; $db_host = 'localhost'; // define your username, password and database here $db_user = 'USERNAME'; $db_pass = 'PASSWORD'; $db_base = 'DATABASE'; echo "Connecting to mysql...<br />\n"; $conn = @mysql_connect($db_host, $db_user, $db_pass) or die('Connection failed!<br />' . mysql_error()); mysql_select_db($db_base) or die('Unabble to select database<br />' . mysql_error()); echo "Connection successful!<br /><br />\nDefining SQL query: "; $query = 'SELECT * FROM counter_tbl WHERE id=1'; echo "($query)<br />\nRunning query...<br />\n"; $result = mysql_query($query) or die("SQL Query Error:<br />\n" . mysql_error()); echo "Query ran successfully<br />\n"; if(mysql_num_rows($result) == 1) { echo "Getting counter column<br />\n"; $row = mysql_fetch_assoc($result); $count = $row['counter'] + 1; echo "Counter retrived, incremented by 1<br />\nDefining query to update counter...<br />\n"; $query = "UPDATE counter_tbl SET counter='$count' WHERE id=1"; echo "Running query ($query)<br />\n"; mysql_query($query) or die("SQL Query Error:<br />\n" . mysql_error()); echo "Query ran successfully<br />\n"; } ?> Post any output you get here. From the output you get you should be able to debug why your script isn't working.
  7. The script you linked to uses php to crop the image, but uses flash to provide a interface so the user can select where to crop the image to. You wont be able to prove an interface, like the flash interface, with just PHP alone.
  8. You are supposed to define a valid doctype at the top of every page. Without the doctype the browser will go into quirks mode, the doctype tells the browser what version of html you are using and works in standards mode.
  9. Auto margins work fine with IE. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>IE auto margins</title> </head> <style type="text/css"> body { font-family: "Trebuchet MS", Verdana, Arial; font-size: 18px; background-color: #F1F1F1; } #container { width: 780px; margin: 20px auto; /* auto margins */ } #header, #content { border: 2px solid #E1E1E1; padding: 20px; margin-bottom: 30px; background-color: #FFF; } #header h1 { color: #333; text-align: center; margin: 0; } #content code { margin: 5px 30px; width: 90%; display: block; font-size: 14px; } </style> <body> <div id="container"> <div id="header"> <h1>IE Auto margins</h1> </div> <div id="content"> <p>Auto margins work fine within IE!</p> <p>I find auto margins work fine within IE when you use valid DOCTYPE, like the following:</p> <code><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"></code> <p>And that you provide a width to the element you wish to center</p> <code>#container { width: 780px; margin: 20px auto; /* auto margins */}</code> <p>Both of the above is the minimun requirement for auto margins</p> <p>AFAIK this works for IE6 and IE7 not sure about other versions.</p> </div> </div> </body> </html>
  10. You havn't closed the cell on the following line, you're putting in two blank table cells. This is what is breaking your table. <td width="150" rowspan="2" valign="top"><td> It should be: <td width="150" rowspan="2" valign="top"></td>
  11. YOu shoud use isset rather than empty: <?php if(isset($_POST['userName']) && !empty($_POST['userName'])) { $userName = $_POST['userName']; print "<h3>Hi there, $userName!</h3>"; } else { ?> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> Please enter your name : <input type="text" name="userName"><br /> <input type="submit" value="Post Username"> </form> <?php } ?>
  12. Rather than use the browsers back button create a link to go back to the listings. When you press the back button IE will try to resubmit any data you just sent to the page.
  13. Best of using an array of newline chars and removing them: $note_modified = str_replace(array("\r\n", "\r", "\n"), "", $note);
  14. In your pics table do you have an entry for '1' in the num column. If you don't then add an entry for 1 to the database which points to an image you want to display in replacement of <include picture# 1>
  15. I have edited the script I have referred to to resize the image uploaded. <?php if(isset($_POST['Submit'])) { // define the max width and height of uploaded images $max_width = 600; $max_height = 600; // define folder in which the images get uploaded to $upload_dir = './pics/'; // get uploaded image data from form $file_name = $_FILES['image']['name']; $file_tmp = $_FILES['image']['tmp_name']; $file_size = $_FILES['image']['size']; $file_type = $_FILES['image']['type']; // get info about uploaded image list($width, $height, $type, $attr) = getimagesize($file_tmp); // set the full upload path for where to upload the image to. $img_path = $upload_dir . $file_name; // check to see if the uploaded image is bigger tha max width an height // if it is we'll crop the image if($width > $max_width && $height > $max_height) { // image is too big so we'll crop it // get the aspect ratio of the image // we do this so we can keep the aspect ratio when the image gets cropped. $aspect_ratio = $height / $width; $new_width = $max_height / $aspect_ratio; // create a blank canvas for the size of the image // this is what the image will get cropped to $img_rs = imagecreatetruecolor($new_width, $max_height); // setup a image resource to the uploaded file $img = imageCreateFromJPEG($file_tmp); // crop the image imagecopyresampled($img_rs, $img, 0, 0, 0, 0, $new_width, $max_height, ImageSX($img), ImageSY($img)); // create the image ImageJPEG($img_rs, $img_path); // destroy the temporary image imagedestroy($img_rs); } else { // uploaded image is under the max width and hieght // we'll just upload it straight away move_uploaded_file($file_tmp, $img_path); } // display the image echo "<h1>Upload Image:</h1>\n\n<img src=\"$img_path\">"; } else { echo '<form method="POST" action="' . $_SERVER['PHP_SELF'] . '" enctype="multipart/form-data"> <input type="file" name="image"><p> <input type="Submit" name="Submit" value="Submit"> </form>'; } ?> That will resize the image if the width and height is greater than 600px. You can change this if you want by editing the following two variables: $max_width = 600; $max_height = 600;
  16. Looks like your code gets corrupt when you upload it to your site and is causing that error. Make sure when you save the PHP file the file encoding is set to ANSI. Most Text editors should save in this format. Other encodings such as UTF-8 can cause problems. Download the attached file edit it and then upload. [attachment deleted by admin]
  17. attach testing.php here. There is something there that PHP doesn't like.
  18. I'm using my own database. I'm not using yours. I have a havea table setup like so just to test my script +------+--------------+ | num | pic | +------+--------------+ | 1 | 4log.png | | 3 | Picture 4.png | +-------+-------------+ The images show because I am using your websites url. my source code
  19. Which is line3? Seems like a strange error when there is nothing wrong with the syntax. The result of the script will be this.
  20. What was yours? Just change localhost, root and test to your database values. Prehaps you have deleted a quote somewhere and is causing the error.
  21. You getting that error with the code I provided above? Strange... I get no errors at all!
  22. Take a look at the script in the post. Should do what you want/near to what you want. The script can be easily adapted if you don't want multiple sizes.
  23. Yes that should work fine. However this line: if(array_key_exists('check_if_submitted', $_POST)){ Should be: if(isset($_POST['switchit'])) { <?php if(isset($_POST['switchit'])) { /* Process form. */ switch($_POST['switchit']) { case 'Add': echo 'Add button pressed'; break; case 'Edit': echo 'Edit button pressed'; break; case 'Delete': echo 'Delete button pressed'; break; } } else { ?> <form method="post" name="cats" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <input type="submit" name="switchit" value="Add"> <input type="submit" name="switchit" value="Edit"> <input type="submit" name="switchit" value="Delete"> </form> <?php } ?>
  24. wrap $prodid_query with in quotes: $result = mysql_query("select * from products_tbl WHERE prod_id = '$prodid_query' LIMIT 0, 30 ") or die(mysql_error()); MySQL will treat the value of $prodid_query as a column name and not a string.
  25. The only way you can host more than one site of off one apache setup is virtual hosts. There is no other option. You cannot not define multiple documentRoots without virtual hosts. How have you got Apache setup at the moment.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.