/    Sign up×
Community /Pin to ProfileBookmark

How to read URL and store to database?

I have URL values from particular file name and its values like:
How to do this as my index.php has search terms like:
index.php?ae=%DF&q=Ofacebookmarketing&x=13&y=14&cnt=3

How to store those values to database [B]after ?[/B]

to post a comment
PHP

8 Comments(s)

Copy linkTweet thisAlerts:
@Peterk92Jan 05.2011 — Would you not be able to just use the $_GET[] Array e.g

[code=php]<?php
print_r($_GET);
?>[/code]


That should return all the search parameters then just go through it inputting it into your database.
Copy linkTweet thisAlerts:
@toplisekauthorJan 05.2011 — How to store just some arrays from

index.php?ae=&#37;DF&q=Ofacebookmarketing&x=13&y=14&cnt=3
Copy linkTweet thisAlerts:
@criterion9Jan 05.2011 — Would something like this not work?
[code=php]
foreach($_GET as $key=> $value){
//do something
}
[/code]
Copy linkTweet thisAlerts:
@toplisekauthorJan 05.2011 — //do something should have what settings to store into variables each separate array?

You see you have

?ae

&q=Ofacebookmarketing

&x=13

&y=14

&cnt=3
Copy linkTweet thisAlerts:
@criterion9Jan 05.2011 — I'm not understanding what you are asking.

[code=php]
echo $_GET['ae']."<br>"; //should be empty
echo $_GET['q']."<br>"; // should be Ofacebookmarketing
echo $_GET['x']."<br>"; // should be 13
echo $_GET['y']."<br>"; //should be 14
echo $_GET['cnt']."<br>"; //should be 3
[/code]


Did you try running the previously posted code?

[code=php]
foreach($_GET as $key => $value){
echo $key ." => ".$value."<br>"; //this spits out each variable key and value
}
[/code]
Copy linkTweet thisAlerts:
@eval_BadCode_Jan 06.2011 — If you're trying to make a sys.argv type log in your datastore look at the predefined $_SERVER array.

[code=php]echo '<pre>',htmlentities(print_r($_SERVER)),'</pre>';[/code]

:p

If you're just trying to process data and store it in a meaningful manner then you need to be more descriptive...

[U]What does your database TABLE look like?[/U]
Copy linkTweet thisAlerts:
@toplisekauthorJan 06.2011 — If you're trying to make a sys.argv type log in your datastore look at the predefined $_SERVER array. [/QUOTE]

What you you mean that this will be better?
Copy linkTweet thisAlerts:
@eval_BadCode_Jan 06.2011 — [code=php]
$link = mysql_connect('example.com:3307', 'mysql_user', 'mysql_password');

mysql_query("create table IF NOT EXISTS url_storage (
url_key int(11) primary key auto_increment,
URL text
) Engine = Archive");

mysql_query(sprintf("INSERT INTO test_url (NULL, '&#37;s')",
mysql_real_escape_string($_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']));

mysql_close($link);
[/code]
×

Success!

Help @toplisek spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.1,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...