PHP - White Spaces Matter?
Code: [Select] Address: 351 Hougang Ave 3 (769057) Contact No: 6752 5513 Operating Hours: 8.00am - 9.30pm (Thursday to Tuesday & Public Holidays) Background: Opened to the public on 30 Mar 88 Hi good day, if I paste the above address into one of the mysql field, I found out that I cannot fetch it using php. It give me a blank page. Code: [Select] Address: 351 Hougang Ave 3 (769057) Contact No: 6752 5513 Operating Hours: 8.00am - 9.30pm (Thursday to Tuesday & Public Holidays) Background: Opened to the public on 30 Mar 88 When I sort it together then i can see mysql working, very strange.. Can anyone help? Similar TutorialsHi im having trouble with uploading images with spaces in as they dont show up in the browser. Here is the code: Code: [Select] $image = addslashes($_FILES['image']['name']); $target = "images/"; $target = $target . basename( $_FILES['image']['name']); //Writes the photo to the server if(move_uploaded_file($_FILES['image']['tmp_name'], $target)) { Any help would be appreciated. Guys: What is the way to remove white spaces in front of a form entry ? Should I use regular expression for this ? Thanks. Do I really have to care about the amount of spaces/tabs I have in my program? Is my code good? Example: Code: [Select] class SportListout{ public $start; public $db; private $junk = 'This is junk data. Unable to find it \'s parents. It is recommended that you delete this data.'; function __construct($db){ $this -> db = $db; $this -> setStartingParent(); } function searchListout($sp){ $notif = 'There are no search results that match that criteria.'; if(strlen($sp) > 0){ if(strlen($sp) < 3){ This is my common text format. Is this ok or should I not make spaces in between functions? Parse error: syntax error, unexpected T_LNUMBER, expecting ',' or ';' in /home/aep/public_html/administrator/page/master_psevent_edit.php on line 71 Code: [Select] <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style type="text/css"> <!-- .style1 {color: #FFFFFF} --> </style> </head> <table width="500" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF"> <td> <form action="" method="post" name="" id=""> <table width="600" border="0" align="left" cellpadding="2" cellspacing="2"> <tr > <td valign="top" ><input name="topcheckbox" type="checkbox" class="check" id="topcheckbox" onClick="selectallps();" value="ON"> Select All</td><td></td> <? $id = $_GET[id]; $connection=mysql_connect("$server", "$username", "$password") or die("Could not establish connection"); mysql_select_db($database_name, $connection) or die ("Could not select database"); $query="select DATE_FORMAT(event_datefrom, '%d %b %Y') AS datefrom, DATE_FORMAT(event_dateto, '%d %b %Y') AS dateto, event_venue , ucase(event_name) as eventname from master_event where event_id = '$id' "; $result=mysql_query($query,$connection) or die(mysql_error()); while($row=mysql_fetch_array($result)) { $eventdatefrom =$row['datefrom']; $eventdateto =$row['dateto']; $eventvenue =$row['event_venue']; echo "<strong>"; echo $row['eventname']; echo "</strong>Date : "; echo "$eventdatefrom - $eventdateto"; echo "<br> Venue : $eventvenue <br><br>"; } ?> </tr> <tr><table width="600" frame="box" rules="all" border="3px" align="left" cellpadding="2" cellspacing="2"> <td><strong><a href="javascript:goDelps()">Del</a></strong></td> <td width = "100" valign="top"><strong>Logo</strong></img></td> <td width = "400" ><strong>Type/Company Name</strong></td> </tr> <? $connection=mysql_connect("$server", "$username", "$password") or die("Could not establish connection"); mysql_select_db($database_name, $connection) or die ("Could not select database"); $query="SELECT master_psevent.*, pstype_desc, company_name, logo_filename FROM master_psevent LEFT JOIN master_pstype ON master_psevent.pstype_id = master_pstype.pstype_id LEFT JOIN master_ps ON master_ps.ps_id = master_psevent.ps_id where master_psevent.event_id = '$id' order by pstype_desc, company_name "; $result=mysql_query($query,$connection) or die(mysql_error()); while($row=mysql_fetch_array($result)) { $imagepath = $row['logo_filename']; $pseventid = $row['psevent_id']; $companyname = $row['company_name']; $type = $row['pstype_desc']; ?> <tr> <td valign="top"><input name="<? echo $pseventid; ?>" type="checkbox" class="check"></td><td> //this is line 71--<?echo "<img src=".$logo_dir."/".$imagepath." width="95%" height="95%"></img> "; ?> </td> <td valign="top" ><div align="left"> </div><? echo $type; ?><br><b><? echo $companyname; ?></b></td> </tr> <? } ?> <tr> <td><strong><a href="javascript:goDelps()" style="color:white; text-decoration:none;"><img src='images\delete.jpg'></img></a></strong></td> <td><strong><img src='images\photos.jpg'></img> </strong></td> <td><strong><img src='images\ps.bmp'></img> </strong></td> </tr> </table> </form></td> </tr> <form name = "eventinfor"> <input type='hidden' name='eventid' value=<? echo"$_GET[id]"; ?> > </form> </table> </html> function buildAvatar(array $imgArray = array()) { $img1 = imagecreatefrompng($phpbb_root_path.'images/spacer.png'); foreach($imgArray as $img) { $img2 = imagecreatefrompng($phpbb_root_path.'avatars/equip_img/'.$img); $this->imagecopymerge_alpha($img1, $img2, 0, 0, 0, 0, 210, 300, 100); } imagealphablending($img1, false); imagesavealpha($img1, true); return $img1; } The background of my PNG was transparent, I don't know what I did, but it's now black! I'm thinking it's the image! Not the code, this same code worked before, and I've tried tons of different ways of fixing it. How should I save the image to work correctly? ok so when my code dipsplays i get the spaces i add in the db but when i updae it dispalys this rnrnrn and its all together Code Code: [Select] <?php include "scripts/connect.php"; if(isset($_GET['edit'])){ $newid = $_GET['edit']; $query = mysql_query("SELECT * FROM news WHERE id='$newid' LIMIT 1"); $rows = mysql_fetch_array($query); $newstitle = $rows['title']; $newsby = $rows['by']; $newsbody = $rows['body']; } if(isset($_POST['saveedit'])){ $newid = mysql_real_escape_string($_POST['saveedit']); $newstitle = mysql_real_escape_string($_POST['title']); $newsby = mysql_real_escape_string($_POST['by']); $newsbody = mysql_real_escape_string($_POST['body']); if ($newstitle && $newsby && $newsbody){ $query = mysql_query("UPDATE news SET title='$newstitle', 'by'='$newsby', body='$newsbody' WHERE id='$newid'") or die(mysql_error()); echo "UPDATE SUCCESFULLY!"; }else $msg = "<font color=red>YOU DID NOT FILL ALL OF THEM IN!</font>"; } ?> <form action='enews.php' method='POST'> <table> <tr> <td></td> <td><?php echo "$msg"; ?></td> </tr> <tr> <td>Article Title</td> <td><input type='text' name='title' size='45' value='<?php echo $newstitle; ?>'/></td> </tr> <tr> <td>By:</td> <td><input type='text' name='by' size='30' value='<?php echo $newsby; ?>' /></td> </tr> <tr> <td>Article Body</td> <td><textarea cols='45' rows='25' name='body'><?php echo stripslashes($newsbody); ?></textarea></td> </tr> <tr> <td><input type='hidden' name='saveedit' value='<?php echo $newid; ?>'/></td> <td><input type='submit' name='updatebtn' value='Update' /></td> </tr> </table> </form> </div> echo $first$last; how would i add a space it comes out like this JoeJackson i want it like this Joe Jackson This doesn't work: Code: [Select] <style type="text/css" media="all">@import url(style/'.$skin.'.css);</style> $skin is = "Sky Blue"; If $skin is = "Sky Blue"; this works: Code: [Select] <link rel="stylesheet" type="text/css" href="style/Sky Blue.css"> It's because @IMPORTURL, Is there a php function that wraps a &20 for a space so it works on my $skin? I made a form, like guestbook, and i dont wonna to write in mysql if in comment is just 1 or more spaces, no letters or numbers or chars, just space, how can i fix that? How can I block a text that contains only spaces? Right now I have done if ($body == "") { die("<font color='red'><font size='15'><strong><center>Your post did not contain any text!"); } But that's extremely insufficient, as any user can easily post " " Any ideas? I have a form which has a drop down menu select box, which retrives the makes of cars from a database, which once clicked submit will go to another page post that info. Then a if statment says if the variable that has been posted == a certain word that matches the one in the database then display content. However, my issue is when I have a car make such as "Land Rover" saved in the database as typed it just comes back with the final else statement. In the 1st section I have included the form which is posting the information across and in the second I have the if statement. Any ideas of how to get around / make this work? [ <form method="post" action="details.php" enctype="multipart/form-data"> <table class="search_nav"> <tr> <td> <select name="manufacture" id="manufacture"> <option value=" " selected="selected">Car Manufactures </option> '; $query = "SELECT DISTINCT make FROM cars ORDER BY make ASC"; $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); while ($row = @ mysql_fetch_array($result)) { print ' <option value='.$row["make"].'>'.$row["make"].'</option> '; } print ' </select> </td> </tr> <tr> <td colspan="2"> <input type="image" src="images/go.gif" alt="Go" name="submit" id="submit" value="Submit"/> </td> </tr> </table> </form> ] [ if ($manufactures == "Land Rover") { echo "test"; } ] How do I get directory names to display with spaces. My script sticks them into arrays just fine, but when trying to echo from a checkbox selection, it only displays the first word. How would I fix this? I am trying to use CURL on a site., to send SMS/TXT messages. HERE IS THE CODE Code: [Select] $name = $_POST['name']; $emsg = $_POST['emsg']; $ch = curl_init("https://www.smsfun.com.au/api/login.php?mobile=emma&password=123456&send_to=$name&message=$emsg&send=1"); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($ch); curl_close($ch); Then i use my form like this Code: [Select] <form method="post" action="" value ""> <p align="center"><strong><font color="#0000FF" size="5" face="Courier New, Courier, mono">MOBILE NO<br> <input name="name" type="text"> </font></strong></p> <p align="center"><strong><font color="#0000FF" size="5" face="Courier New, Courier, mono">message</font><font color="#0000FF" size="5" face="Courier New, Courier, mono"><br> <textarea name="emsg" value "$emsg" rows="5" wrap="VIRTUAL"></textarea> </font></strong><br> <input type="submit" name="submit" value="SEND"> </p> </form> This all works fine but if the user needs to put a space after a word i.e "hello this is a test" this wont work only "hellothisisatest" will. Am i missing somtink here? I tryed googleing etc cannot find the answer. Please help Thanks g-netUK I'm looking for a function that will check a string for letters and spaces...boolean preferibly Hi, I am trying to parse a html page, but i get a lot of empty spaces, please any idea how can i remove spaces, here is my text: Code: [Select] this goes here one line here some other line here see there is a lot of space between text, thanks for any help I've got the following code: echo <<<myStringEcho <script src="$myPluginPath/jquery.dummy.js"></script> myStringEcho; The problem is that $myPluginPath already has a / character at the end, so I don't need to put it in above But, I can't just remove it, otherwise I'll get $myPluginPathjquery.dummy.js How can I insert and have no spaces? Thanks OM How can I check if the text entered in a textarea field equals the text I have stored in a mysql table? Code: [Select] $submitted_description = trim(mysqli_real_escape_string($db,$_POST['description'])); $query = "SELECT description FROM pets"; $result = $db->query($query); $row = $result->fetch_assoc(); $sql_description = $row['description']; Here's what they echo: Quote submitted_description: Testing...\r\n\r\n1\r\n\r\n2\r\n\r\n3 sql_description: Testing... 1 2 3 I tried adding the following to get rid of \r\n from $submitted_description but they both still don't equal but echo the same text. Code: [Select] $submitted_description = str_replace(array("\r","\n",'\r','\n'),' ', $submitted_description); They following code only matches when no spaces are entered in the textarea field. Code: [Select] if($submitted_description == $sql_description) { echo "Match!"; } else { echo "Don't Match!"; } How can this be done? I also tried adding nl2br() to both variables but that didn't work either. Hi, the problem that I have goes like this. If i do a regular Select query and display it in a table everything is there but if i am filling a input box of a form to use for modifying the values it does not return the entire value: Exemple with the same value in a table = product_name : Amd Athlon X2 In input field : Amd Here is my code Code: [Select] <? $sql = "SELECT * FROM tbl_product WHERE product_code = '$_POST[productcode]'"; $result = mysql_query($sql); if(!$result){ die("Error running $sql:" . mysql_error()); } ?> <? while($row = mysql_fetch_array($result)) { echo " <form action='functions/moditem.php' method='post'> <input type='hidden' name='productid' value=". $row['product_id'] ."> Product code : <input type='text' name='productcode' value=". $row['product_code'] ." /><br /> Product Name : <input type='text' name='productname' value=". $row['product_name'] ." /><br /> Product Price: <input type='text' name='productprice' value=". $row['product_price'] ." /><br /> <input type='submit' value='Modify' /> </form> "; } Ok so I'm still having problems. This is what I need: I want a function to echo a message if a username does not pass my requirments. - Only letters and / or numbers - Must start with a letter (not a number) - No spaces The current code is not working for me. Please help Code: [Select] }else if (!(eregi('/[A-Za-z0-9-]+',($_POST["username"])))){ echo "<p> </p><p> </p><p> </p><br />Must only contain numbers and letters and cannot exceed 10 characters.<p> </p><p> </p><a href='javascript:javascript:history.go(-1)'>Click here to go back to previous page</a>"; I am using a standard form to mail script and have a few fields that I need to be required to be filled in. This is working fine until someone enters a space character in a required field, which is being let thorugh. How can I stop this? here the code for required fields - I thought the trim function in the below would have taken care of this??? // This is because I originally had it require but too many people // were used to Matt's Formmail.pl which used required instead. if ($required) $require = $required; // handle the required fields if ($require) { // seperate at the commas $require = ereg_replace( " +", "", $require); $required = split(",",$require); for ($i=0;$i<count($required);$i++) { $string = trim($required[$i]); // check if they exsist if((!(${$string})) || (!(${$string}))) { // if the missing_fields_redirect option is on: redirect them if ($missing_fields_redirect) { header ("Location: $missing_fields_redirect"); exit; } $require; $missing_field_list .= "<b><font color=\"#990000\">Missing: $required[$i]</font></b><br>\n"; } } // send error to our mighty error function if ($missing_field_list) print_error($missing_field_list,"missing"); } |