Jump to content

Script Syntaxes Ok?


Akenatehm

Recommended Posts

Hey Guys,

 

I was wondering if you could check over the following scripts and see if they are set out well and if the syntax in them is valid.

 

<?php
include "connect.php";

$author=$_POST['author'];

$time=$_POST['time'];

$insert = "INSERT INTO `chatrooms` (author,time)
VALUES ($author,$time)";

$result= "SELECT `chat_id` FROM chatrooms where time = $time AND author = $author";

while($row = mysql_fetch_array($result))
  {
$create = "CREATE TABLE "chat_".$result.""
(
username text,
message text
)";
  }
  
?>

 

<?php

include "connect.php";

<?php

if(isset($_POST['submit']))

{
   $message=$_POST['message'];

   $username=$_POST['username'];
   
   $chat_id=$_POST['chat_id'];

   if(strlen($message)<1)

   {

      print "Please Enter a Message.";

   }

   else

   {
$insert = "INSERT INTO /$chat_id' (username,message)
VALUES ($username, $message)";
   }

}


?>

Link to comment
https://forums.phpfreaks.com/topic/134819-script-syntaxes-ok/
Share on other sites

Sounds like you didn't even write this code. Php freaks is so people can get help with a specific problem. You have to narrow it down, and then ask a specific question. You can't just expect people to debug a huge piece of code when you didn't even tell them what the problem is.

Link to comment
https://forums.phpfreaks.com/topic/134819-script-syntaxes-ok/#findComment-702067
Share on other sites

I wrote this code myself, and expected their to be errors. Rather than wasting time, I thought I would get it checked over first.

Rather than wasting a lot of other people's time, there are ways of doing some basic checks yourself.

 

From a command line:

php -l <filename>

will identify any fatal errors that will prevent the script identified by <filename> from even compiling.

Few people ever bother to use it, but it can save hours of time when you would otherwise get an http 500 error from a server when trying to run a script which can't compile.

 

Get in the habit of setting your script so that it displays all errors right at the very top of the script, even before setting config or db connections or any other includes

Link to comment
https://forums.phpfreaks.com/topic/134819-script-syntaxes-ok/#findComment-702185
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.