This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2011-09-30 18:55:25

flashgocrazy
Scratcher
Registered: 2011-01-12
Posts: 500+

PHP/ MYSQL help

i have this code:

Code:

<?php
//THIS CODE WAS MADE BY FLASHGOCRAZY AND GP1 IF YOU GET BANNED WHILE USING THIS CODE IT IS NOT OUR FAULT


//makes sure there is all the info needed
if(isset($_GET['user'])&&isset($_GET['projectid'])){
$proj-id = filter_input(INPUT_GET, "projectid");
$user = filter_input(INPUT_GET, "user");
header('Location: http://scratch.mit.edu/projects/$user/$proj-id/loveit#');

}

?>

and it says there is an error on line 9! Help?


◕‿◕

Offline

 

#2 2011-09-30 19:12:50

bbbeb
Scratcher
Registered: 2009-06-11
Posts: 1000+

Re: PHP/ MYSQL help

1 too many blank lines?


Back in my day.... there were no laws that censored the internet... now, there are.... nah.

Offline

 

#3 2011-09-30 19:19:49

flashgocrazy
Scratcher
Registered: 2011-01-12
Posts: 500+

Re: PHP/ MYSQL help

bbbeb wrote:

1 too many blank lines

no, I don't think that is it.

Last edited by flashgocrazy (2011-09-30 19:47:23)


◕‿◕

Offline

 

#4 2011-09-30 20:13:30

rookwood101
Scratcher
Registered: 2011-07-29
Posts: 500+

Re: PHP/ MYSQL help

for the header, use " instead of ' to enclose the string, as speech marks support variables, whereas apostrophes don't.


http://i.imgur.com/zeIZW.png

Offline

 

#5 2011-10-01 01:52:25

TRocket
Scratcher
Registered: 2009-08-18
Posts: 1000+

Re: PHP/ MYSQL help

try chaning to:

Code:

header('Location: http://scratch.mit.edu/projects/' . $user . '/' . $proj-id . '/loveit#');

http://i.imgur.com/1QqnHxQ.png

Offline

 

#6 2011-10-01 03:39:37

GP1
Scratcher
Registered: 2009-07-06
Posts: 1000+

Re: PHP/ MYSQL help

Try this:

Code:

<?php
//THIS CODE WAS MADE BY FLASHGOCRAZY AND GP1 IF YOU GET BANNED WHILE USING THIS CODE IT IS NOT OUR FAULT


//makes sure there is all the info needed
if(isset($_GET['user'])&&isset($_GET['projectid'])){
$projid = $_GET['projectid'];
$user = $_GET['user'];
header('Location: http://scratch.mit.edu/projects/'.$user.'/'.$proj-id.'/loveit#');

}

?>

I took out filter_input() because i don't know what they're code is. Could you include the code for me for those functions?


I am currently http://blocks.scratchr.org/API.php?user=GP1&amp;action=onlineStatus&amp;type=imagehttp://blocks.scratchr.org/API.php?user=GP1&amp;action=onlineStatus&amp;type=text and I finally got over 1000 posts.

Offline

 

#7 2011-10-01 05:37:19

rookwood101
Scratcher
Registered: 2011-07-29
Posts: 500+

Re: PHP/ MYSQL help

TRocket wrote:

try chaning to:

Code:

header('Location: http://scratch.mit.edu/projects/' . $user . '/' . $proj-id . '/loveit#');

That also would work.

And I agree with above poster, you have no need for the filter inputs, if you're not going to use their full functionality.


http://i.imgur.com/zeIZW.png

Offline

 

#8 2011-10-01 06:16:18

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: PHP/ MYSQL help

Any good programming language doesn't allow hyphens in variable names! So first of all, it's good practice to use underscores instead. Second, use double quotes to enclose strings. Lastly, you're never sure whether the parser will interpret the variable names as a string or as a variable -- so use string concatenation instead of embedding the variables into a single string.

Offline

 

#9 2011-10-01 08:13:37

nathanprocks
Scratcher
Registered: 2011-04-14
Posts: 1000+

Re: PHP/ MYSQL help

LS97 wrote:

Any good programming language doesn't allow hyphens in variable names! So first of all, it's good practice to use underscores instead. Second, use double quotes to enclose strings. Lastly, you're never sure whether the parser will interpret the variable names as a string or as a variable -- so use string concatenation instead of embedding the variables into a single string.

lol i try to always use camel caps so proj-id would be projId


http://carrot.cassiedragonandfriends.org/Scratch_Signature/randomsig.php
http://trinary.site40.net/images/scratchrank.php?username=nathanprocks&amp;display=small

Offline

 

#10 2011-10-01 09:32:46

flashgocrazy
Scratcher
Registered: 2011-01-12
Posts: 500+

Re: PHP/ MYSQL help

GP1 wrote:

Try this:

Code:

<?php
//THIS CODE WAS MADE BY FLASHGOCRAZY AND GP1 IF YOU GET BANNED WHILE USING THIS CODE IT IS NOT OUR FAULT


//makes sure there is all the info needed
if(isset($_GET['user'])&&isset($_GET['projectid'])){
$projid = $_GET['projectid'];
$user = $_GET['user'];
header('Location: http://scratch.mit.edu/projects/'.$user.'/'.$proj-id.'/loveit#');

}

?>

I took out filter_input() because i don't know what they're code is. Could you include the code for me for those functions?

I found filter_input() in a book about php and mysql


◕‿◕

Offline

 

#11 2011-10-01 09:40:27

flashgocrazy
Scratcher
Registered: 2011-01-12
Posts: 500+

Re: PHP/ MYSQL help

GP1 wrote:

Try this:

Code:

<?php
//THIS CODE WAS MADE BY FLASHGOCRAZY AND GP1 IF YOU GET BANNED WHILE USING THIS CODE IT IS NOT OUR FAULT


//makes sure there is all the info needed
if(isset($_GET['user'])&&isset($_GET['projectid'])){
$projid = $_GET['projectid'];
$user = $_GET['user'];
header('Location: http://scratch.mit.edu/projects/'.$user.'/'.$proj-id.'/loveit#');

}

?>

I took out filter_input() because i don't know what they're code is. Could you include the code for me for those functions?

can you test the code for me?


◕‿◕

Offline

 

#12 2011-10-01 13:13:30

GP1
Scratcher
Registered: 2009-07-06
Posts: 1000+

Re: PHP/ MYSQL help

flashgocrazy wrote:

GP1 wrote:

Try this:

Code:

<?php
//THIS CODE WAS MADE BY FLASHGOCRAZY AND GP1 IF YOU GET BANNED WHILE USING THIS CODE IT IS NOT OUR FAULT


//makes sure there is all the info needed
if(isset($_GET['user'])&&isset($_GET['projectid'])){
$projid = $_GET['projectid'];
$user = $_GET['user'];
header('Location: http://scratch.mit.edu/projects/'.$user.'/'.$proj-id.'/loveit#');

}

?>

I took out filter_input() because i don't know what they're code is. Could you include the code for me for those functions?

can you test the code for me?

Do I have to do everything myself? Fine, I will.


I am currently http://blocks.scratchr.org/API.php?user=GP1&amp;action=onlineStatus&amp;type=imagehttp://blocks.scratchr.org/API.php?user=GP1&amp;action=onlineStatus&amp;type=text and I finally got over 1000 posts.

Offline

 

#13 2011-10-01 13:19:36

WindowsExplorer
Scratcher
Registered: 2011-02-25
Posts: 1000+

Re: PHP/ MYSQL help

GP1 wrote:

flashgocrazy wrote:

GP1 wrote:

Try this:

Code:

<?php
//THIS CODE WAS MADE BY FLASHGOCRAZY AND GP1 IF YOU GET BANNED WHILE USING THIS CODE IT IS NOT OUR FAULT


//makes sure there is all the info needed
if(isset($_GET['user'])&&isset($_GET['projectid'])){
$projid = $_GET['projectid'];
$user = $_GET['user'];
header('Location: http://scratch.mit.edu/projects/'.$user.'/'.$proj-id.'/loveit#');

}

?>

I took out filter_input() because i don't know what they're code is. Could you include the code for me for those functions?

can you test the code for me?

Do I have to do everything myself? Yes!

Okay, I have this code:

Code:

<link rel="stylesheet" type="text/css" href="global.css" />
<?php
include("demo.php");
include("main.php");

$ip = $_SEREVR["REMOTE_ADDR"];
$con = mysql_connect("*","*","*");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("*", $con);

mysql_query("INSERT INTO visitors (ip)
VALUES ('$ip')");

mysql_close($con);
?>

http://i.imgur.com/H6LLdnK.pnghttp://i.imgur.com/VYuD7BY.png

Offline

 

#14 2011-10-01 14:22:07

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: PHP/ MYSQL help

Closed by request of the topic owner.


http://i39.tinypic.com/2nav6o7.gif

Offline

 

Board footer