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

#1 2011-10-30 10:17:34

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

SQL/php not working:

My SQL script isn't working:

Code:

$dbHost = '***'; // localhost will be used in most cases
// set these to your mysql database username and password.
$dbUser = '***'; 
$dbPass = '***';
$dbDatabase = '****'; // the database you put the table into.
$con = mysql_connect($dbHost, $dbUser, $dbPass) or die("Failed to connect to MySQL Server. Error: " . mysql_error());

mysql_select_db($dbDatabase) or die("Failed to connect to database. Error: " . mysql_error());


$username = $_SESSION['username'];
$id = $_POST['id'];
$name = $_GET['name'];

session_start();
if ($_POST['submit']) {
mysql_query("UPDATE project_details SET reported='$username' WHERE  name='$id'", $con); //THIS PART DOESN'T WORK
echo "<p>You have reported a planet as inappropriate. That planet will remain invisible until a moderator reviews it.</p>";
} else {
echo "<form method=\"POST\" action=\"report.php\">
<p>Planet Name: <input type=\"text\" value=\"$name\" name=\"id\" readonly=\"readonly\"><br />
<input type=\"submit\" name=\"submit\" value=\"Report\"></p>
</form>";
}

It just doesn't run the sql part at the end, but everything else works and no errors ?

Last edited by WindowsExplorer (2011-10-30 10:17:48)


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

Offline

 

#2 2011-10-30 11:38:26

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

Re: SQL/php not working:

do the other bits within the 'if ($_POST['submit'])' work?


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

Offline

 

#3 2011-10-30 12:00:39

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

Re: SQL/php not working:

rookwood101 wrote:

do the other bits within the 'if ($_POST['submit'])' work?

still not working  sad


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

Offline

 

#4 2011-10-30 12:21:44

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

Re: SQL/php not working:

try putting

Code:

echo $_POST['submit'];

before the if ,what does it say?

also look at the log


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

Offline

 

#5 2011-10-30 12:21:58

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

Re: SQL/php not working:

WindowsExplorer wrote:

rookwood101 wrote:

do the other bits within the 'if ($_POST['submit'])' work?

still not working  sad

You didn't answer my question, in the code, you put a comment saying which bit wasn't working, what I'm asking is whether the code after that line works.


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

Offline

 

#6 2011-10-30 12:23:29

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

Re: SQL/php not working:

rookwood101 wrote:

WindowsExplorer wrote:

rookwood101 wrote:

do the other bits within the 'if ($_POST['submit'])' work?

still not working  sad

You didn't answer my question, in the code, you put a comment saying which bit wasn't working, what I'm asking is whether the code after that line works.

I know its only the sql update part because all the other things in the condition POST[submit] works.


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

Offline

 

#7 2011-10-31 16:05:00

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

Re: SQL/php not working:

Drop the ', $con' part.

Offline

 

#8 2011-10-31 16:20:59

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: SQL/php not working:

Magnie wrote:

Drop the ', $con' part.

That should do it. If it doesn't, maybe the SQL's wrong...


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#9 2011-10-31 16:57:34

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

Re: SQL/php not working:

Magnie wrote:

Drop the ', $con' part.


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

Offline

 

Board footer