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

#1 2011-12-28 20:16:56

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

php help!

i have this code

Code:

<?php

$mysql_host = "xxxx";
$mysql_database = "xxxxx";
$mysql_user = "xxxxxx";
$mysql_password = "xxxx";
$con = mysql_connect($mysql_host,$mysql_user,$mysql_password);
if (!$con)
  {
echo "mysql error";
  }
$ip=$_SERVER['REMOTE_ADDR'];
mysql_query("INSERT INTO stuff (ip)
VALUES ('$ip')");
mysql_close($con);
?>

can somebody make this code so it displays a image and records your ip onto a mysql database?
thanks,
flash  smile


◕‿◕

Offline

 

#2 2011-12-29 10:43:28

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

Re: php help!

flashgocrazy wrote:

i have this code

Code:

<?php

$mysql_host = "xxxx";
$mysql_database = "xxxxx";
$mysql_user = "xxxxxx";
$mysql_password = "xxxx";
$con = mysql_connect($mysql_host,$mysql_user,$mysql_password);
if (!$con)
  {
echo "mysql error";
  }
$ip=$_SERVER['REMOTE_ADDR'];
mysql_query("INSERT INTO stuff (ip)
VALUES ('$ip')");
mysql_close($con);
?>

can somebody make this code so it displays a image and records your ip onto a mysql database?
thanks,
flash  smile

I'm not sure. Is there any errors coming up? Also, I was trying to do this once too, but it didn't work.


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

Offline

 

#3 2011-12-29 10:45:01

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

Re: php help!

WindowsExplorer wrote:

flashgocrazy wrote:

i have this code

Code:

<?php

$mysql_host = "xxxx";
$mysql_database = "xxxxx";
$mysql_user = "xxxxxx";
$mysql_password = "xxxx";
$con = mysql_connect($mysql_host,$mysql_user,$mysql_password);
if (!$con)
  {
echo "mysql error";
  }
$ip=$_SERVER['REMOTE_ADDR'];
mysql_query("INSERT INTO stuff (ip)
VALUES ('$ip')");
mysql_close($con);
?>

can somebody make this code so it displays a image and records your ip onto a mysql database?
thanks,
flash  smile

I'm not sure. Is there any errors coming up? Also, I was trying to do this once too, but it didn't work.

no errors, its just not posting the ip in the database


◕‿◕

Offline

 

#4 2011-12-29 10:47:25

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

Re: php help!

flashgocrazy wrote:

i have this code

Code:

<?php

$mysql_host = "xxxx";
$mysql_database = "xxxxx";
$mysql_user = "xxxxxx";
$mysql_password = "xxxx";
$con = mysql_connect($mysql_host,$mysql_user,$mysql_password);
if (!$con)
  {
echo "mysql error";
  }
$ip=$_SERVER['REMOTE_ADDR'];

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

mysql_close($con);
?>

can somebody make this code so it displays a image and records your ip onto a mysql database?
thanks,
flash  smile

you need to give mysql_query $con as well

Last edited by TRocket (2011-12-29 10:47:51)


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

Offline

 

#5 2011-12-29 10:53:58

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

Re: php help!

TRocket wrote:

flashgocrazy wrote:

i have this code

Code:

<?php

$mysql_host = "xxxx";
$mysql_database = "xxxxx";
$mysql_user = "xxxxxx";
$mysql_password = "xxxx";
$con = mysql_connect($mysql_host,$mysql_user,$mysql_password);
if (!$con)
  {
echo "mysql error";
  }
$ip=$_SERVER['REMOTE_ADDR'];

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

mysql_close($con);
?>

can somebody make this code so it displays a image and records your ip onto a mysql database?
thanks,
flash  smile

you need to give mysql_query $con as well

do you have the code for it?


◕‿◕

Offline

 

#6 2011-12-29 10:57:13

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

Re: php help!

you need to specify a database to connect to
http://www.php.net/manual/en/function.m … ect-db.php

mysql_select_db($mysql_database);


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

Offline

 

#7 2011-12-29 10:58:08

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

Re: php help!

Code:

$sql = 'INSERT INTO stuff (ip) VALUES (' . $ip . ')';
mysql_query($sql, $con);

should work...

Last edited by TRocket (2011-12-29 10:59:30)


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

Offline

 

#8 2011-12-29 11:15:07

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

Re: php help!

Code:

<?php

$mysql_host = "xxxx";
$mysql_database = "xxxxx";
$mysql_user = "xxxxxx";
$mysql_password = "xxxx";
$con = mysql_connect($mysql_host, $mysql_user, $mysql_password);
mysql_select_db($mysql_database, $con);
if (!$con)
  {
echo "mysql error";
  }
$ip=$_SERVER['REMOTE_ADDR'];

mysql_query("INSERT INTO stuff (ip)
VALUES ('$ip')", $con);

mysql_close($con);
?>

Try this.


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

Offline

 

#9 2011-12-29 12:40:40

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

Re: php help!

WindowsExplorer wrote:

Code:

<?php

$mysql_host = "xxxx";
$mysql_database = "xxxxx";
$mysql_user = "xxxxxx";
$mysql_password = "xxxx";
$con = mysql_connect($mysql_host, $mysql_user, $mysql_password);
mysql_select_db($mysql_database, $con);
if (!$con)
  {
echo "mysql error";
  }
$ip=$_SERVER['REMOTE_ADDR'];

mysql_query("INSERT INTO stuff (ip)
VALUES ('$ip')", $con);

mysql_close($con);
?>

Try this.

exactly, although you don't need to specify the connection in the mysql_select_db parameters but you can anyway  smile


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

Offline

 

#10 2011-12-29 13:32:08

cheddargirl
Scratch Team
Registered: 2008-09-15
Posts: 1000+

Re: php help!

Topic closed by request of topic owner  *Jumps up and flies into the sunset*


http://i.imgur.com/8QRYx.png
Everything is better when you add a little cheddar, because when you have cheese your life is at ease  smile

Offline

 

#11 2011-12-29 13:33:43

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

Re: php help!

wierd, its not closed


◕‿◕

Offline

 

#12 2011-12-29 13:38:35

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

Re: php help!

Didn't you want to make an image also with the ip on it? Ill do it, in a sec....


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-12-29 14:00:00

cheddargirl
Scratch Team
Registered: 2008-09-15
Posts: 1000+

Re: php help!

flashgocrazy wrote:

wierd, its not closed

Yikes, I guess I closed my browser tab too soon before the thread got closed. It's closed now.  tongue


http://i.imgur.com/8QRYx.png
Everything is better when you add a little cheddar, because when you have cheese your life is at ease  smile

Offline

 

Board footer