Adding Strings To A Query String?
I want to use my string $stringvar to show text in this sql query. ATM its sticking "$player, $score" into a field, I want it to instead print it out into the sql statement.
This is my code:
$stringvar="$player, $score";
$sql=mysql_query("INSERT INTO $game_db VALUES ('$new_matchid', '$opponent', '$map', $stringvar, '$result')");
This is what I want the sql query thing to look like:
$sql=mysql_query("INSERT INTO $game_db VALUES ('$new_matchid', '$opponent', '$map', $player, $score, '$result')");
View Complete Forum Thread with Replies
Related Forum Messages:
Adding Query Strings
How do you put the strings after an url together. e.g. the url is already: http://something.com/index.php?id=2 and a link is going to change it to index.php?id=2&order=4
View Replies !
Adding Strings With Quotes Into Mysql
I am using htmlspecialchars because some strings that I am adding to mysql (articledate) are like the following: Friday - September 15, 2006 by Jolene "foxxylady" Petipas (the quotes are causing problems) Code:
View Replies !
Query Strings
I have got query stings up and working on my site. But there are some problems. How do I make the title of the page change with the diff. index.php?page= Also, I wanted the query strings to act like a frame, so when clicked it only changes the content, not the whole page. I am using this code: [PHP <?php if ($page=="whatever") { include ("whereat"); } elseif ($page=="whatever") { include ("whereat"); } elseif ($page=="whatever") { include ("whereat"); } else { include ("whereat"); } ?> [/PHP]
View Replies !
Two DB Query Strings
PHP Code: $result45 = mysql_query ("SELECT * From results_players_data where result_id = $Result_ID and position = 'team1_wing2'"); $row45 = mysql_fetch_array($result45); $playerid = $row43[player_id]; $result46 = mysql_query ("SELECT * From results_players where player_id = $playerid"); $row46 = mysql_fetch_array($result46); I have two questions relating to this code, one - how would i make this one query? econd. if playerid = nothing ie: there is no record found how can i stop it from doing the second search? I guess the first part of this post may answer the second.
View Replies !
Db Query Strings
I notice that many examples in the manual use sprintf in constructing database query strings. Is this just style, or are there some serious advantages to sprintf over concatenating the string, assuming in both cases that the variable parts of the string are properly sanitized?
View Replies !
How To Find Several Strings Within A String
I'm trying to find several keyowrds out of string of text which are the list of keywords for a text file. The keyword list is in a field called keywords in a mysql database. So if the user types in "foo bar foobar" to be looked up and the field contians "Bar foobar foo oyster moregarbage stuff" it will be able to bring up that record.
View Replies !
Building GET Query Strings
I am currently building a sports web application and have run into a design question. In order to create a new coach record, there are two pieces of information that are needed: 1) username 2) team_id It seems to me that the best way to do this is to break the problem into two parts. First, search for the username and append that to the URL: http://www.mysite.com?username=john Next, I would present the user with another search box to search for a team and then add '&team_id=1' to the GET url. The final URL should look something like http://www.mysite.com?username=john...action=addcoach Does anyone know of a good example out there for doing this in a methodical and elegant fashion?
View Replies !
Aliasing Query Strings
I Am trying to find a way to alias my query strings so I can optimize my site for search engines. Currently my site is doing well in search results with my static content, but since I've switched to dynamic content (same material) the engines don't fine my stuff, not even the build in search that comes from my host. so simply, my question is, how can I change: www.anysite.com/details.php?cat=food to www.anysite.com/food.htm My site depends heavily on search engine traffic,
View Replies !
Combine Two Strings Into A Query
I am picking values from which are seperated by a comma in the following format: value1,value2,value3 I then pass the values into a query such that if the value was only one the query would be: PHP Code: $sql="select vacancy from jobs where vacancy='$value1'"; If it was more then one value then it would be: PHP Code:
View Replies !
Enabling Query Strings On Dev PC
Not having a net connection at home anymore I've had to use my own PC for development transferring files by disk to a PC with a connection. I've installed Apache and PHP on my pc and it's parsing the PHP however it's not reading the Query Strings in the URL. How do I go about getting it to recognise them? EG: 127.0.0.6/index.php?dir=_incl&=page1 Should open the index and include a file in _incl called page1. However it's just defaulting to a default page if no Query String is called. Leading me to believe it's not parsing the Query String. This works online on my host. Are Query Strings not enabled by default or is this because I'm using my PC as a Server & viewing files on it?
View Replies !
Query Strings Question
I know in PHP you can set query string (index.php?q=jargon), but I was wondering, if I could set empty query strings (like this: index.php?q). Is this valid? I just want this to pass that a certain error has happned for instance in a Login script.
View Replies !
Encoding Query Strings
we often need to send query strings as the value of another parameter. e.g. /redirect.php?refpage=/mypage.php?mode=view&ID=45678 where we need to capture the full value of refpage and redirect the user to that value (in the case above /mypage.php?mode=view&ID=45678) however because there is an extra ampersand in it, the value is not stored correctly. one way round it is to use base64_encode() to encode the value of refpage. however this results in a very long string - too long for some email clients, which break it and make it non-clickable.
View Replies !
Split String In Smaller Strings
I have a string consisting of say 1000 characters. Want I want to do is to split the string at the first space after the first 80 characters, enter a <br> tag and after the <br> tag carry on with the rest of the string. Then it needs to repeat this with the remaining string and split it again at the first string after 80 characters till it reach the end of the string. I got it in a way to split it after 80 characters and enter a <br> tag, but it's not working properly and I don't have any idea how to repeat it. PHP Code:
View Replies !
Split The String Into Two Separate Strings
I have this variable: $str = "4xAura Extraction"; I need it to split the string into two separate strings containing this: $split[0]: 4 $split[1]: Aura Extraction I can't use explode(), because that will split it up again if there are x's other than the one that comes after the number. What would be the best way to get this done. I'm asking because I'm not real good at string manipulation when it comes to mutilating them.
View Replies !
Replacing Two Strings Within A String And Copying What's Between Them
Yeah, kinda hard to sum up in a title. Basically, I'm trying to do something like BBCode, but I'm only making one tag--a link tag. For example, a user types [url]http://the.wesite.com/[/url], then the php code replaces [url] with <a href="http://the.website.com/"> and [/url] with </a>. Then the URL would appear again between the <a> tags. I've tried looking around, but I can't figure out which of the many string replacement functions I need to use.
View Replies !
Including Files That Have Query Strings
I am having trouble with accessing files with query strings. For example the code "require 'template.php?102932'" gives the following error: Warning: main(/www/blog/template.php?102932): failed to open stream: Invalid argument in C:wwwlog20041227est-of-2004index.php on line 54 Fatal error: main(): Failed opening required '/www/blog/template.php?102932' (include_path='.;c:php4pear') in C:wwwlog20041227est-of-2004index.php on line 54 I have no idea what's going on. Is it impossible to open files with query strings in PHP? I am running PHP 4.3.9 on Apache 2/Win.
View Replies !
Query Strings, Extract() And Including Pages
I wanted to do: include('page.htm?id=12&foo=bar'); But since I can't (and don't want to make another seperate HTTP request with include('http://...')); I was wondering if there's a function similar to extract(); that can handle a query string as input, so that I could: $id = 12; $foo = 'bar' include('page.htm'); I am using this on a 'processor' style page to interperet URLs as http://foo.com/bla. It consults a database to manage a large number of URLs to their pages.
View Replies !
Query Strings - Edit The Topic And Submit The Form?
I am creating some custom php forums right now, and I need some help with query strings. In the forums, when someone edit his own post, I set the following query string: "address.com/topic.php?t=123&control=edit" Which opens a text area so that the user can edit his topic. Now when the user edit the topic and submit the form, the address stays: "address.com/topic.php?t=123&control=edit" But I want it to change back to: "address.com/topic.php?t=123" without the 'control=edit' part.
View Replies !
How To Search Strings Escaped By Mysql Real Escape String()?
I am currently developing an article script and there are Titles and Contents. To prevent sql injection, people say we must use mysql_real_escape_string(). So let's say if there is a Title that says "My Friend's best friend", if I look into the MySQL table record, the text will be saved as "My Friend's best friend", where the apostrophe is escaped. Code:
View Replies !
Why Is Preg_match_all Slower On A Large String Than In A Loop Of Smaller Strings With The Same Overall Length?
While using the following loop to extract images from the google search engine I discovered that preg_match_all works much faster parsing small strings in a loop than extracting all of the urls at once from a much larger string. This surprised me because I expected the preg_match_all to perform the task much faster. Why is this, and is there an easier way to resolve this matter? for ($i = 0; $i < $m; $i++, $start+=20){ $saURL = "http://images.google.com/images?q=" . $searchString . "&start=" . $start; preg_match_all("/:(wwwS+?.(jpg|png|bmp|gif))/i", file_get_contents( $saURL ), $matches); $image = array_merge($image, $matches[1]); }
View Replies !
Adding To A String
I have a string $string I initialize the string: $string = "test string<br>"; I want to add text to the string along my script but: $string += "more information<br>";
View Replies !
Adding Another GET Var To The URL String
i have a form that validates using GET, what i would like to do is add an additional variable to the get string. i have tried various suggestions like.... 1. concatenating the GET variable on the end of the action="..." string. 2. I have tried to add the value on the end of the $_GET array using array_push(). 3. I tried to add the variable to the $_SERVER['QUERY_STRING'] variable. At the bottom of my page i am outputting the $_GET array to see when the extra value is outputted, but I only get a result when i physically type the "&Email=fail" on the end of the URL. I suppose i could get round this by using hidden form fields but there must be an easier and more efficient way of simply adding another get var to the end of the URL string ?
View Replies !
Adding SUM To Query
I have a SELECT * query that returns info such as 'name', 'date', 'cost', and 'notes'. At the head of this query return it reads how many records were found. I would like to append that with 'how many records were found at a cost of' ... But haven't been able to find a means of totalizing the 'cost' column in my query. Does anyone have any ideas on how this might be accomplished ??? I've spent considerable time on the net looking at examples and my reference book but so far, no luck.
View Replies !
Adding In Query
How can I just had a value to the value in the DB, like: "UPDATE rate SET totalval='$score', totalvote='' WHERE user_id='$id'"; I want to be able to had certain values to what is in the totalvote, without having to query it, then get the value add the two and reupdate.
View Replies !
Query Not Adding To Db
i having a few problems with the order being added to my db. the information from the checkou form is being stored in the varibles, but it cannot add the order to the database. please help me ive been strglling for ages.PHP Code: function insert_order($order_details) { // extract order_details out as variables extract($order_details); $conn = db_connect(); $date = date('Y-m-d'); $query = "insert into orders values ('', ".$_SESSION['$valid_user'].", ".$_SESSION['total_price'].", '$date', 'PARTIAL', '$sname', '$saddress','$scity','$spost')"; $result = $conn->query($query); if (!$result) return false; $query = "select orderid from orders where customerid = ".$_SESSION['$valid_user']." and amount > ".$_SESSION['total_price']."-.001 and amount < ".$_SESSION['total_price']."+.001 and..........
View Replies !
Adding Spaces Into A String
I have a post string that has eight characters in and need to add five spaces in between each character. Eg. $account = "12345678" I need $account = "1Â Â Â 2Â Â Â 3Â Â Â 4Â Â Â 5Â Â Â 6Â Â Â 7Â Â Â 8" What would be the best way to do this?
View Replies !
Adding To A String Or Number
So basically I have these numbers: $number1 = 5; $number2 = 25; $number3 = 50; And I want to add them on to the end of each other. So I tried to use code like this: $numbers = $number1 . $number2 . $number3; But that didn't work all it outputs is the last number. What other code could I use?
View Replies !
Adding 1 More Criteria To A Query
I have a query that needs to pull data from two tables based on criteria from those two and a third table. The issue I'm having is with the WHERE part of the query. Here's the basic query. It works correctly for the result that I need. Code:
View Replies !
Adding Spaces To A Text String
i want to do and im not sure how to go about it if i had a text string returned that was a long post of just characters no spaces included that displayed would break the width of my html frame causing scrolling and its a hassle i dont particually want. so how can i go about looking for spaces and adding them if the character length is long with no spaces included?
View Replies !
Edit It In 1 Query Without Removing And Adding?
I have tried a number of ways and could not get it to work. I just want to edit a certain line where I know the value of one of the fields Here is what I do now: $mynum = 3; $result=MYSQL_QUERY("DELETE FROM $db WHERE num = '$mynum'"); $result=MYSQL_QUERY("INSERT INTO $db (title,url,num)"."VALUES (''$mytitle','$myurl','$mynum')"); I delete it then add the updated one back in, is there a way to just edit it in 1 query without removing and adding?
View Replies !
Using Php In A String. Not Adding To The String.
<div><a href="avatars.php?style="<?=$style?>"">Avatars</a></div> isn't giving me the correct number. In fact, its not giving me any number. It is set up above and works on the rest of the page. I think i need to use the '.' to tell it is part of the same string, but i get errors when i do that.
View Replies !
Searching Through String, Adding Certain Elements Into Array?
I'm having some difficulty searching through a string, and adding to an array at the same time, this is my string: and basically what I want to do is only add the img src's to my array, and only the one's that are before the first 2 's. Does anyone have a quick solution for this, I've tried many different ways using preg_match_all() but havent managed to get it right.
View Replies !
Adding Values In One Column From Query Results
I have this query: SELECT *, sum(field_value) as totalValue FROM table_name WHERE field_id = $id GROUP BY field_group the data type of field value is a decimal value, with values such as 125.00 and 150.50 stored in each record. My goal is to have totalValue be the total value of those numbers. So if I have two records that equal 125.00 and 150.50 totalValue would = 175.50. the above query does not do this. What do I need to change here? Should I try to do this from the PHP side?
View Replies !
Array Query - For Adding Alt Text To Multiple Image Upload Form
I've set up a form for uploading multiple images and I am writing the urls to a database, which is queried and outputs the images on a web page. This works fine, however, I also want to add alt/title text for each image upload but can't quite seem to get it working. I'm pretty new to PHP so my knowledge of how to use arrays is fairly limited. Code:
View Replies !
Splitting Strings - Break Strings Apart By Character
I am trying to make post code search and need to be able to break strings apart by character. I can do it by spaces and things using the explode() function, but I want to be able to get the first letter of the string only, the first and second only, first second and third etc.
View Replies !
Get Value Of Query String
I am trying to get the value of a query string. The query string variable name is stored in a array value(because I need to read one particular query string) PHP Code:
View Replies !
String Query
I'm trying to get this query in PHP: select answer,correct from quiz_answer WHERE (qsid=28 OR qsid=29 OR qsid=30) and correct='yes' But the thing is that when I select a wrong answer then it displays qsid=66 OR, so this depends on how many questions wrong..PHP code:
View Replies !
Query String ?
i have a form that accepts user info. i have to add that info to my database and redirect the user to another site and fill the form on that site with the info the user just entered in my form. i am using the query string. the other website that i am transferring to is using jsp. Code:
View Replies !
Using Query String
I do understand you can use get, post and session(maybe cookie as well?) to pass the variables. But I would like to know whether you can just create url manually, without having a submit button to generate the url in a form. Because I if I do this in a form it will always direct to only one webpage. What I want to do is create multiple links which could link to different pages,(not a single page) on just one form, so each link will direct to differnt page, with variables' values specified(set). I tried to search for a function which does this job on google, but I couldn't find it. Another question is, once the target page sees this url, can we retrieve the values nicely?
View Replies !
Query String
Is it possible that you could send multiple values in one query string value like <a href somepage.php?category=style,art,music>Add</a> Or could we send an array like $category = array("style","art","music"); <a href somepage.php?category=$category>Add</a> Is this possible or am i totally out of track,or is there anyway of doing it.
View Replies !
Via Query String
I have used the following url format to build a template site with a fair bit of success: page.php?content=whatever The only problem is that with many pages the directory becomes quite messy due to all the content pages being in the same root folder. Is there a way to keep all the content pages in folders and still access them via a query string? I have tried this before: page.php?content=about/whatever (where about is a subfolder in the site).
View Replies !
Can You Ignore A GET Query String?
Hello all, I have a recursive form that uses both GET and POST variables. After calling a GET, the string stays in the URI. When I do a POST, the scripts breaks because the GET string is still there. I can't figure out how ignore or delete the query string after I'm done with it. unset() doesn't work.
View Replies !
Making A Query String
I'm new to Google Groups (this is my first post or topic or whatever it's called). I'm also new to PHP. My knowledge in PHP extends to variables, basic fuctions, etc. I have a site with a MySQL 4.1.14 database and I use phpMyAdmin 2.6.3-pl1. Suppose there's a page called videos.php. What do I need to do to get a page called: videos.php?name=matrix-ping-pong Also, it would be helpful if you tell me how to add more pages (well, it's really not a page, is it?) such as: videos.php?name=hamster-dance
View Replies !
How To Build Query String?
From a form I have a list of fields, e.g: name address phone memo I know how I do it manually for search query but how do I do it automatically. select * from <table_name> where name = %$_POST['name']% and/or address LIKE %$_POST['address']% and/or phone LIKE %$_POST['phone']% and/or memo LIKE %$_POST['memo']% but my trouble if one of them is blank.
View Replies !
|