Need Quick php help

SpaceshipSpaceship
Watch

Mike_Wiseman

Established Member
Impact
3
Hi, this script was maid by poordoggy at this forum but something is wrong: the script is you fill out the forums and click submit if something is wrong it will just echo "something is wrong" but no matter what you put it sais it is always wrong. here is the script:

<?php

// Lets start by adding some variables
$name = "";
$author = "";
$tutorial = "";

// Ok - lets find out if the user submitted the form
if( isset( $_POST['submit'] ) ) // if the submit button was pressed...
{
// change the variables...
$name = $_POST['name'];
$author = $_POST['author'];
$tutorial = $_POST['tutorial'];

if( !$_POST['name'] || !$_POST['author'] || !$_POST['tutorial'] ) // if anything was not filled in (|| = "or")
{
echo "There is a problem somewhere... please go down and check everything!";
}
else // if everything is ok...
{
// set your database infomation.
$dbhost='localhost'; // database host
$dbusername='mwise_form'; // username for db
$dbuserpass='hahaha'; // password for db
$dbname='mwise_form'; // database name

// connect to the mysql database server.
$connect = mysql_connect($dbhost, $dbusername, $dbuserpass);

// select the database
mysql_select_db($dbname);

// do the query
// I put the query into a variable this time
$sql = "INSERT INTO tutorials (name, author, tutorial) VALUES(".$name.", ".$author.", ".$tutorial.")";
if(mysql_query($sql))
{
echo "Added to database";
}
else
{
echo "something wrong";
}
}
}

?>


Im pretty possitive this is the problem:
if( !$_POST['name'] || !$_POST['author'] || !$_POST['tutorial'] ) // if anything was not filled in (|| = "or")
{
echo "There is a problem somewhere... please go down and check everything!";
}

i will send whoever fixes this problem all my np$ (witch isnt very much but its the best i can do)
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
PHP:
if(empty($_POST['name']) || empty($_POST['author'] || empty($_POST['tutorial'] )
{
echo "There is a problem somewhere... please go down and check everything!";
}
else // if everything is ok...
{

try this...
 
Last edited:
0
•••
no that didnt work, it just gives me this error:
Parse error: parse error, unexpected '|', expecting ')' in /home/mwise/public_html/add.php on line 16
 
0
•••
PHP:
if (strlen($_POST['name'])<1 || strlen($_POST['author'])<1 || strlen($_POST['tutorial'])<1)
{
echo "There is a problem somewhere... please go down and check everything!";
}
else // if everything is ok...
{

ok, try this one, other should work, i probably put wrong syntax in it
 
0
•••
i didnt get any error on the page but when i type in the info and stuf no matter what it is it still sais something is wrong
 
0
•••
hmm can you post the html form your using? might be someting wrong with it

-edit-

does it just say "something wrong"

or the first error message,

if it says something wrong its something with yoru database

Regards
Brian
 
0
•••
its defintly not the form because i got it to work once but i cannot find the file?

ok i fixed the problem, but now on view.php it has this error:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/mwise/public_html/admin/view.php on line 15

here is line 15:
while($row = mysql_fetch_array( $result )) {
 
Last edited:
0
•••
just a note the reason why brians first attempt did not work is he forgot to close the bracket at empty($_POST['author']

should have been empty($_POST['author'])
 
0
•••
If poordoggy made this script I strongly suggest you tell poordoggy to fix his script.

Regards,

(ps. I am creating a tutorial script if you wish I can let you download it once I fix a few thigns and add a couple pages.

http://gameserverchat.com/sticktuts/
)
 
0
•••
filth said:
just a note the reason why brians first attempt did not work is he forgot to close the bracket at empty($_POST['author']

should have been empty($_POST['author'])

haha opps, figured i forgot to do something, was too lazy to look back through it and just made a new way lol.

Yeah, Mike i would suggest contacting poordoggy for assistance, as he knows exactly how he made the script, hard for us to help with only seeing bits and pieces of it .

Regards
Brian
 
0
•••
Appraise.net

We're social

Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomainEasy — Live Options
DomDB
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back