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

#1 2012-02-11 11:44:59

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

Source code for Scratch Live?

I'm not sure if this is the right place to post this, but how can I setup my own private Scratch Live... Is the source code available?


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

Offline

 

#2 2012-02-11 13:40:16

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Source code for Scratch Live?

Official One by JD1

My "revised" version:

Code:

<title>Scratch-Live <?php 
$title = 'Variables';
echo($title);?></title>

<?php 

$SQLhost     = "127.0.0.1";
$SQLuser     = "root";
$SQLpass     = "";
$SQLdatabase = "test";
$SQLtable    = "scratchlive";

$con = mysql_connect($SQLhost,$SQLuser,$SQLpass);
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
echo "Database Connected";
echo "<br />";

if ( isset($_GET['user']) ) { $user  = $_GET["user"]; } else { $user = ""; }
if ( isset($_GET['pass']) ) { $pass  = $_GET["pass"]; } else { $pass = ""; }
if ( isset($_GET['value']) ) { $value  = $_GET["value"]; } else { $value = ""; }

echo $user;
echo "<br />";
echo $pass;
echo "<br />";
echo $value;
echo "<br />";

if ($pass == 1) {
    $val = strlen($value);
    if ($val > 0) {
        echo "Acting on request";
        $act = "set";
    } else {
        echo "Getting request";
        $act = "get";
    }
echo "<br />";


//**************************
//******DATABASE STUFF******
//**************************

mysql_select_db($SQLdatabase, $con);

if(1==0)
    {
        $sql = "CREATE TABLE" . $SQLtable. "
                    (
                    Username varchar(20),
                    Value varchar(20),
                    )";
        mysql_query($sql,$con);
        echo "<br />";
        echo "Table made";
        echo "<br />";
            
    }

$result = mysql_query("SELECT * FROM ".$SQLtable." WHERE Username='$user'");
$row = mysql_fetch_array($result);
if ( $row['Username'] != "" ) { $get = $row['Value']; }
else { $get = ""; }

if ($get == "") {
    $query = "INSERT INTO ".$SQLtable." (Username, Value) VALUES ('$user', '$value')";
    mysql_query($query);
}
echo "<br />";
echo "\n";
if ($act == "get") {
    echo $get;
}

if ($act == "set") {
    $query = "UPDATE ".$SQLtable." SET Value = '".$value."' WHERE Username = '".$user."'";
    mysql_query($query);
    echo "Updated";
}

}

mysql_close($con);
?>

Offline

 

#3 2012-02-11 13:47:10

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

Re: Source code for Scratch Live?

Magnie wrote:

Official One by JD1

My "revised" version:

Code:

<title>Scratch-Live <?php 
$title = 'Variables';
echo($title);?></title>

<?php 

$SQLhost     = "127.0.0.1";
$SQLuser     = "root";
$SQLpass     = "";
$SQLdatabase = "test";
$SQLtable    = "scratchlive";

$con = mysql_connect($SQLhost,$SQLuser,$SQLpass);
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
echo "Database Connected";
echo "<br />";

if ( isset($_GET['user']) ) { $user  = $_GET["user"]; } else { $user = ""; }
if ( isset($_GET['pass']) ) { $pass  = $_GET["pass"]; } else { $pass = ""; }
if ( isset($_GET['value']) ) { $value  = $_GET["value"]; } else { $value = ""; }

echo $user;
echo "<br />";
echo $pass;
echo "<br />";
echo $value;
echo "<br />";

if ($pass == 1) {
    $val = strlen($value);
    if ($val > 0) {
        echo "Acting on request";
        $act = "set";
    } else {
        echo "Getting request";
        $act = "get";
    }
echo "<br />";


//**************************
//******DATABASE STUFF******
//**************************

mysql_select_db($SQLdatabase, $con);

if(1==0)
    {
        $sql = "CREATE TABLE" . $SQLtable. "
                    (
                    Username varchar(20),
                    Value varchar(20),
                    )";
        mysql_query($sql,$con);
        echo "<br />";
        echo "Table made";
        echo "<br />";
            
    }

$result = mysql_query("SELECT * FROM ".$SQLtable." WHERE Username='$user'");
$row = mysql_fetch_array($result);
if ( $row['Username'] != "" ) { $get = $row['Value']; }
else { $get = ""; }

if ($get == "") {
    $query = "INSERT INTO ".$SQLtable." (Username, Value) VALUES ('$user', '$value')";
    mysql_query($query);
}
echo "<br />";
echo "\n";
if ($act == "get") {
    echo $get;
}

if ($act == "set") {
    $query = "UPDATE ".$SQLtable." SET Value = '".$value."' WHERE Username = '".$user."'";
    mysql_query($query);
    echo "Updated";
}

}

mysql_close($con);
?>

ok thanks i will try it  smile


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

Offline

 

#4 2012-02-11 15:03:26

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

Re: Source code for Scratch Live?

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/********/public_html/varstore/set.php on line 65


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

Offline

 

#5 2012-02-11 15:21:24

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

Re: Source code for Scratch Live?

i know why it won't work now... i forgot to insert the coloumns in the database lol


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

Offline

 

#6 2012-02-11 18:42:02

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Source code for Scratch Live?

nathanprocks wrote:

i know why it won't work now... i forgot to insert the coloumns in the database lol

Haha, nice to know you got it to work!

Offline

 

Board footer