Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Characters Breaking My Query


Im using encrypted data to store cc info. The PHP code encrypts and sends the result to the database. the problem is that the encrypted string contains lots of characters that will break my sql query. I can do a replace but there are lots of characters.

for example, a character will look like this:

g%$^'GDF$%^//"@#$%/||''$#"/|#dfsa.

how can I put this information in a different format... and then retrieve the data to decrypt the string?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Breaking Up The Query String Dynamicly?
using $Get_string = $_SERVER['QUERY_STRING']; to receive a query string such as
month=may&$day=15&year=2006

so that $Get_string = "month=may&$day=15&year=2006"

can I separate the values and turn them into variables? (like a normally would with a url get)

$month = "may"
$day= "15" etc

it would be great to just do $_GET on the url but I'm sending the string as a variable to another script... so i can't just go the easy route.

Special Characters In Mysql Query With PHP
I´m using a php-mysql Search engine script called "DGS-Search" and I have a problem with latin characters. For example a query with letter "ä" won´t give any results.

When I do the query in Mysql command line, it works fine.

I tried to debug the script printing the query to screen and the characters in the query were ok but when the script searches the table nothing is found.

So how can I get PHP understand that the letter is really "ö" or "ä" or some else special character.

Breaking Strings?
I have a string (actually 100's of these, but lets take one):

$string ="TI: Some journal title AU: SomeAuthor,-S; Smith,-A; Jones,-B SO: SomeSource. 2002 Jan 9; 287(2): 188; discussion 189-90 JN: Some Journal Title";

This needs to be turned into an array:

$entry = array(
'Some Item Title',
'SomeAuthor,-S; Smith,-A; Jones,-B',
'SomeSource. 2002 Jan 9; 287(2): 188; discussion 189-90',
'Some Journal Title');

As you can see, each array item should be defined by what comes after either/all of the following: 'TI:' 'AU:' 'SO:' 'JN:'

So, I need to be able to create a pattern that can look through the string and return everything in between TI: and AU:, then AU: and SO, etc.

for example:

eregi(???, $string, $entry);

I'm fairly new to this and can't seem to figure out the regex I need for the pattern. Is this even the way to go about it?

Breaking Out Of An Iframe
I cannot figure this one out. My script is being displayed in an iframe (a wiki page) and I have one option won't give me the correct results unless the page is displayed in either

a) new tab in NS browser
b) new browser instance.

The option in question is used to print forms, and I use the browser Print Preview for the page setup. It's all pretty useless if I have the page and iframe content in my preview.

I thought using header() would do the trick.

Breaking A Page Down.
What is the best solution to break down a php page into certain section using MySql, For example i'm looking at designing a page that reffers to a MySQL database that contains the html code for the navigation. So that in future if the navigation changes I'll only need to changed the html code in the database and all the pages will be sorted. I'm also looking at doing the same for the information on the footer of the page, with teh contact details.

Breaking Out Of Quotes
I know I can use stuff like in front of " so that it can't break out of a "" and start doing bad things, but it seems there are other situations where, E.G., if the string is hex for " then it has the same effect, and stuff like that, and it gets tricky escaping it all, so I'm wandering, is there some kind of option I can enable or extension I can install that just simply prevents objects/variables/arrays from breaking out of single/double quotes and also for mysql queries?

And also for html so E.G. echo"<img src='$asdf'>"; can't be exploited to do other things? I don't care if it isn't free as long as it works good and isn't to expensive..

Breaking Up Querys
I have a page that updates a table every workday. (these are standard updates, like if someone has moved, or has a different phone number or something.)  It is too big of a query to run the entire table all at once, so it is split out. 

The split is grouped by the first letter of a first name field.  Right now it is broken up into 5 parts, and each part has a group of letters (i.e. "a" to "d" is one group, "e" to "k" is the next, and so on.  As you can see, these do not have an even number of letters, but that is because some letters have a lot more entries, and need to be in smaller groups.) 

The reason it is split out into 5 groups is that I can run one group on each workday (Monday through Friday), and I can have the PHP check what day of the week it is.  (I use a case statement, the first case is for Monday, the second is for Tuesday, etc.) Code:

Breaking A Loop.
I have one going through rows of a sql database until it matches some data with user input. I need to put a break command in there but can't seem to find out how to achieve this.

Breaking Rows
I am using a while statement to pull results from my database. Now if I have like 40 results how would I make it break into rows.

So instead of;

result result result result result result result result result result result result result result result result result result

I want;

result result result result result
result result result result result
result result result result result
result result result result result

XML Parser Breaking Up URLs
I'm having a problem parsing an xml file in which one of an elements character data is a url which contains multiple "&" characters. For some reason the parser breaks up the data into multiple pieces. For instance, when I call this function(abbreviated):

function characterDataHandler ($parser, $data)
{
global $element;
global $url;
if ($element == "URL") {
$url = $data;
echo "url=".$url."<br>";
}
}

I get some output like this:


url=http://www.somewebsite.com/index.jsp?s=af

url=&

url=filter=1

url=&

url=show=all


Do urls with querystrings have to be handled differently then regular character data?

For Loops Breaking At A Certain Multiple
Can someone help me out with writing a script that will make will loop 500 times, but at every 4th multiple, it will insert a peice of code?

I tried all day to get this, and so far, nothing has worked.

Not Breaking Loop In Function
I get this error: <b>Fatal error</b>: Cannot break/continue 1 levels in <b>file.php</b> on line <b>128</b><br>

This happens when I call a function. In the function there is a break; This is cause the break is in a function and not in the loop. But it gets called inside the loop. Is there a fix for this?

E-Mail Not Breaking Lines
I'm sending an e-mail via a contact form, but somehow the lines aren't breaking in the text, it always looks like this:

lorem ipsum

dolor

sit

amet

lorem


Which is of course not readable at all. What am I doing wrong here? I'm using a few security checks and such for cleaning the field up; $text = trim($text);
...
$text = stripslashes(strip_tags($text));
...
$text = mysql_real_escape_string($text);
.....

#and then the part where it's included in the message:
$message .= "Nachricht: {$text} ";

Can any of those be causing the display problem?

Script Breaking On Mysql_result
I was trying to figure out why one of my scripts was failing and by using an "or die" statement for the SQL narrowed it down to this bit of code:

$md5 = md5_file("swf/" . basename($jpg_link));
$dupe = mysql_result(mysql_query("select count(gId) from games where gSwfFile='$md5.swf"), 0);
if(!empty($dupe))
{
continue;
}

This is giving the following error - "Warning: mysql_result(): supplied argument is not a valid MySQL result resource"

The thing is, I've checked that SQL query by running other values in place of $md5 through it and it appears to be fine. 

select count(gId) from games where gSwfFile='Flat War july 30th 2007.swf';
Any ideas?

Header Function - Breaking Out Of A Frame
I can create a plain htm link and have the new page break out of frames. a href='page.html' target='_top' Can this be done with a Header redirect in php?

Breaking Backwards Compatibility - Good Or Bad?
If you have any PHP scripts which will not work in the current releases
due to breaks in backwards compatibility then take a look at
http://www.tonymarston.net/php-mysq...everything.html and see if
you agree with my opinion or not.

Breaking Survey Into Seperate Parts?
I have a very long survey form with 4 different sections. Is there anyway with php to split this form into 4 popup windows so the person can click on the section they wish to fill out and when they are done, go back to the host survey form and continue on? I know there must be a way to do it, i'm just at a loss as to how i would pass the variables off? Cookies perhaps?

Breaking Up A Comma Seperated List
i have a list seperated by commas: 1. 3. 5. 7. 9 actually is a varible

$members ="1, 3, 5, 7, 9"; what would be the best way to break that up to insert the values into a table in a loop.

Breaking Up Text For Multiple Pages
I was recently put in charge of heading up my company's website, and
while I have a lot of experience on the design side of things, I'm
still very new to the programming side. When I started, the website had
just gotten a revision, but the site was an utter mess, so I've been
trying to fix it up. As I've gone along, I've learned some aspects of
PHP, but my knowledge is still very limited.

Here is the problem I'm trying to fix. A backend is used to enter
information into our MySQL database, and then a page template pulls it
out to make the page. For our reviews, the PHP coding currently breaks
up the review's text so that it can be places across multiple pages.
The problem is, the way the text breaking was set up, the end of one
page and the beginning of the next are totally chaotic, with breaks
often coming mid-sentence.

Here is what I'd love: other coding automatically puts an HTML break at
the end of paragraphs, and then another in the space between one
paragraph and the next. I'd love to have the code search for when those
double breaks come up, and then break up the text after, say, every
sixth pair of HTML breaks. I'd also like the option to break the text
myself by putting in some sort of text code in the original text. At
this point, though, anything that can make the breaks more elegant
would be a huge improvement.

I really appreciate any help anybody can give me in this one. Please
remember that I know very little of PHP, and I'm not much of a
programmer anyhow, so things that you may take for granted that people
would understand about PHP, I might not know.

I tried to pull out what I thought was the current coding for the text
break. Here it is. I'd also like to get rid of the part1/part2 factor.
Before, they had the text breaking to help in fitting into the layout
around an image, but I've fixed that so I no longer need the break. So,
that portion no longer needs to be a factor.

if ($page == ""){
$page = 1;
}
$no_letters = strlen($Game_Full_Story);
$times = ($no_letters / 3800) +1;
$Game_Full_Story = wordwrap($Game_Full_Story,3800,"*#^");
$Game_Full_Story = explode ("*#^", $Game_Full_Story);
$pages = array();
for ($i=0; $i<$times ; $i++){
$part[$i] = $Game_Full_Story[$i];
if ($i != 0){
array_push($pages, $i);
}
}
$page = $page-1;
$story = $part[$page];
if (strlen($story) < 460){
$parts1 = $story;
}else{
$story = wordwrap($story,460,"*#^");
$story = explode ("*#^", $story);
$parts1 = $story[0];
$count = count($story);
$parts2="";
for ($i=1; $i<$count; $i++){
$parts2 .=$story[$i];
$parts2 .=" ";
}
}

Breaking Up A String Into Individual Words
I have a text box that I will use to search a database. I would like
to use it so that it will not use a whole string (ie. 'red striped
top') but instead break it up into individual words (ie. 'red',
'striped', 'top') and maybe put it into and array. I will then use the
words in the array to search the database.

How do I break a string up this way?

Also, is this the most common way of creating a means of searching a
database?

Breaking The BACK Button (Refresh Problem)
I have a php page which serves up multiple pages based on how the user
interacts with it - there are links on the first page that will reload (from
the same php file) a new page with form fields and submit buttons, and when
a user posts from that new page (or cancels), then the same php file is
again loaded, detecting how the user responded and generating the
appropriate html for whatever should be none next. All very typical.

What I want to know is, is there a way so that once a user has posted from
some submit button from one page (we'll say he Cancel's from a page that had
a form Cancel button so he returns to the original non-form default page
generated from the php file), can it be made so if the user then "refreshes"
the new page (hits the Refresh or Reload browser button) he does NOT get the
browser's "The page cannot be refreshed without resending the information.
Click Retry to send the information again, or click Cancel to return to the
page that you were trying to view." dialog? In other words, what I'd like is
a way to have the browser think that there was no posting done (even though
there was) once I've generated this certain 'home' page with my php code, so
that user ReLoad's of the page won't get this warning.

This is probably related also to problems I've had with "breaking the BACK
button" on sequences of php pages: if the user BACK's up to a page that was
generated by a post, it may not even be possible to regenerate the original
page.

Return Data Breaking Input Field
My return data is: (I have nothing to do with how the og person choose to input this)

<font color="#800080">CASE</font>

and I am setting the value of a input text form field equal to that return

$input      = "<input type="text" name="queOpt". $i ."" value="". $this->_queArr[$i] ."" />";

im lost on how to fix this. addslashes doesnt make sense  - maybe it is the double quote thing

Shrink Many Characters To Few Characters
I am using this code to shrink URL to a desired number of characters Code:

REGEX: Can't Seem To Replace LIMIT Clause In Query Using Preg_replace ($pattern, $replacement, $query)
Want to replace the limit clause in a query, but can't get it right.
What's wrong with this:

$pattern = "(.*)limit (.*)";
$replacement = '$1'
$replacement .= "LIMIT $limit";
$replacement .= '$2'
$query = preg_replace ($pattern, $replacement, $query);

PHP Update Query Mysql: Query Succussful?
I can't seem to successfully test an update query. Below is a piece of code that updates a statistics table. If row today doesn;t exist, a new day must be created. But this doesn't work...

thank you for your reply.

$today= date("Y-m-d");

$qq="update totals_r set hits_r=(hits_r+1), lang_$lang=(lang_$lang+1), cat_$cat=(cat_$cat+1), rating_$rating=(rating_$rating+1), bussite_$bussite=(bussite_$bussite+1) where date='$today'";

$result_6 = mysql_query ("$qq");

if (!$result_6){ /// IF !ROW_TODAY ==> CREATE NEW DAY

$qq_2="insert into totals_r (hits_r, lang_$lang, cat_$cat, rating_$rating, bussite_$bussite, date) values(&#391;',&#391;',&#391;',&#391;',&#391;','$today')";

$result_6_2 = mysql_query ("$qq_2");

if (!$result_6_2){
$err_msg_sql_6= mysql_error();
$err_loc_6="$PHP_SELF"." // Query6: update totals_r";
}
}

Speeding Up Query/code (query Within Result Set)
I'm looking for ideas on how to speed up this script. Basically it finds all the zip codes in a zipcode table, then looks for all the records in another table with those zip codes.

Right now it finds all the zips then within that WHILE, it looks for a record in another table with that zip: PHP Code:

Using Query Result To Do Another Query In Loop
I have 2 tables, one called users2 and one called books. Books has a field called UserId, which is the ID of the user that added the book to the database.

My problem, is that i need to take this ID from the book table, and use it to get some information from the user table. Here is my code to get the ID from the book table: Code:

Empty Query, Query Fail
i am doing a user authentication but my problem is that when i type in user name and password it is Code:

Replace Special Characters By Non-special Characters
i'm looking for a way to replace special characters with characters
without accents, cedilles, etc.

Four Characters In PHP
These four characters " ' and null in PHP makes me very confused. Can some give me explain these with simple examples or give me poiniter to some simple tutorial which explains the difference with examples.

Cut Characters...
Is there a PHP command, similer to trim, that just cuts characters off if a limit has been reached?

Need Help With Special Characters
A simple form that asks a player Nick, a Quake 3 Nick

Where:

^1 = Red
^4= Blue, etc.

Through ^1 to ^8 you get the colors.

For example: ^4<LGG>^2Ozzman Will display: <LGG>Ozzman

The problem is that special characters causes errors or I can't echo the variables correctly. < and > is a TAG for PHP so it disapear when I echo the $nick var.

And what about the ^ or other special characters?

How Can I do this?

Trimming Characters.
I want to trim the 1st 4 characters of this string and thereafter trim the 1st 3 characters of the result (of 1st trim) and then again trim the result of the 2nd trim so that I retain the 1st 2 characters only of the 2nd trim.

eg:

string = abcf00101XL

1st trim =(abcf) : result= 00101XL

2nd trim =(001) : result = 01XL

3rd trim =(XL) : result = 01

The final result I need is = 01

I hope the example I've given is clear.

Please note that there could also be strings of like abcf00101s.

Selecting Only Some Of Characters In Value
I would like to only select some characters returned from a query.

So for example:

I have a value that equals "DevShed", I want to set another variable to equal only a portion of that value like "Shed".

How do I skip some characters to only show in this case the last 4 characters?

$value="DevShed";

<some code here to turn the above variable into>

$newValue="Shed";

Special Characters
I'm writting a news management script and I have run into a problem. When some submits a news artical it sometime contain special characters that might now show up on all browsers. Is there a way to makeit check for the characters and switch them to html that can be read by browsers. Is there a way to do this and name it as like, filter.inc then just tell the program to just use this inc file before sending the content to the database. I want to be able to use the special character to html lib for other programs.

Hex Characters In Forms
How does php and mysql handle hex characters. Like when a form is submited.

Do i need to use a specific function, or all characters are the same?

Chinese Characters
I need to store chinese characters and Pinyins in a mysql database
and then read them from php and using the GD library and
imagettftext() function to create an image based on a chinese ttf font
of the chinese characters.

I have tried setting the encoding in the database as UTF-8 and BIG5
but the characters display (both in MYSQL and when displayed via PHP)...

Counting Characters
Just a silly little problem i'm not entirely sure how to tackle. I'm wanting to search through a string for a certain character and then count the number of times it appears (or return false if it doesn't locate the character).

Extra Characters
I'm trying to create a csv file to download. The file that is being created has three extraneous characters at the end. I experimented with several different versions of
to make sure it wasn't something there. No matter what combination I use, I still get the 3 extra return characters. Is there something that PHP adds to a file?

Here's the code that creates the variable: PHP code:

Lmit Characters
I have a MySQL DB with a text field that includes both text and HTML
tags. When I invoke that field in a page, I only see the text (not the
HTML tags, of course). I only want to chow the first 50 characters of
that field, but If use the substr function the result shows my the
HTML tags, because the HTML tags could be in the middle of the substr
limit, I mean:

$text=This is a <B>test</Bthat I want to show

If I use a substr ($text, 18), I receive:

"This is a <B>test<"

I need to avoid the HTML tags and show only the text. I need only to
receive:

"This is a test tha" --18 characters

So...I need only the substring of the result of the field already
formated

Displaying Characters
I have a form which accepts text entries. As part of these entries, people can enter anything they like. I can then store these to the mySQL database no problem. The issue comes in when I go to display the entries.

Lets say for instance someone enters "<HELLO>" as the text in a field. When I go to display this data later on, it causes problems because of the "<" character (thinking it's html).

Question: How can I display the data that I have stored without having this problem occur, and without changing the data which is stored (i.e. I want to preserve the original input, just want to display it correctly and without causing html problems.

Translating Characters
I'd like to translate these characters:

Ç -> c
ø -> o

etc/etc.

Which function do I use to do this? I know that strtr is used, but I don't know how I would go about doing this.

I'm hoping someone can point me in the right direction.

Escaping Characters
Does anyone know of a way of either escaping or removing characters such as ' or " from a php string? The reason i need this is because i'm writing a search engine for php/mysql, and when you enter something like: it's all over

in the search box it throws the mysql database right off and comes back with an error.

Getting Rid Of Escape Characters.
i am sending the contents of an html text area with the name "message" using the mail functions like.

mail($email, $subject, $message, "From: someone@somewhere.com
Reply-To: someone@somewhere.com
X-Mailer: PHP/" . phpversion());

when the user gets the mail all apostrophies (') are escaped like ('). how do i prevent this?

Invisible Characters
I have an invisible character in a string that I have read in from my database. I need to convert the invisible character to something else so that when I use the data to generate an XML file it does not complain that it is not a well formed xml document. I extracted the hex from the file (am not sure I know how to use what I saw yet). But I am guessing I need a way to use an ereg_replace like function to replace the hex representation of the invisible character with another character. Does anyone know how to do this? The invisible character is (Don t) where the space in Don't is, and it might be a smart quote from some windows text editor.

Specify Trim() Characters?
I get an error trying to trim commas from the end of a string using:

$newstring = rtrim($oldstring, ",");

"Warning: Wrong parameter count for rtrim() in..."

As far as I can see my syntax is correct, although I notice the PHP manual states "Note: The second parameter was added in PHP 4.1.0" (URL). I don't think 4.1.0 is released, right?

Special Characters
How ould i convert to html code the characters ã, á, à, é, ç, ...

Special Characters.
When I put in a textarea some french charactes, when I get them back
with a SQL request, all is correct.

With phpMyAdmin, in the database, I can see this:

Et voilà que la star de l'Internet met cette fois la voûte
céleste à portée de souris grâce à une nouvelle option baptisée

But on another server, with the same PHP code, in the database I have
this:

Et voilà que la star de l'Internet met cette fois la voûte
céleste à portée de souris grâce à une nouvelle optionbaptisée

Knowing that the PHP code is the same and the browsers too, which
difference in the config files (PHP or MySQL) can affect the
characters ?


Copyright © 2005-08 www.BigResource.com, All rights reserved