Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 06-11-2005, 10:59 AM Little help please?
feraira's Avatar
BeTheBand!

Posts: 350
Trades: 0
PHP Code:
<?

include("tags.php");

$tname $_GET['tname'];
$ttype $_GET['ttype'];
$caption $_GET['caption'];
$tutorial $_GET['tutorial'];
$author $_GET['author'];

if(!
$tname) {
exit(
"You need to input a title for the tutorial");
}
if(!
$ttype) {
exit(
"You need to input a type of tutorial");
}
if(!
$caption) {
exit(
"You need to input a caption");
}
if(!
$author) {
exit(
"You need to input an author for the tutorial!");
} else {

$tname addslashes($tname);
$caption addslashes($caption);
$tutorial addslashes($tutorial);
$tutorial tags($tutorial);

mysql_connect("localhost""lalala""lalalala") or die("Could not connect to DB because: ".mysql_error());
mysql_select_db("lalala") or die("Could not select the DB because: ".mysql_error());

$query "INSERT INTO tutorials VALUES ('', '".$tname."', '".$ttype."', '".$caption"', '".$tutorial."', '".$author."')";
mysql_query($query) or die("Could not complete query because: ".mysql_error());

?>
I get an error on line 34...

Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/xingeh/public_html/test/insert.php on line 34

Can anyone help please?
feraira is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-11-2005, 12:32 PM
Monkeon's Avatar
Skilled Talker

Posts: 59
Trades: 0
At a first glance, it looks like you missed a full stop at $caption

PHP Code:
$query "INSERT INTO tutorials VALUES ('', '".$tname."', '".$ttype."', '".$caption"', '".$tutorial."', '".$author."')"
__________________

Please login or register to view this content. Registration is FREE
FREE Online Dating!
Meet your perfect match online right now!
Monkeon is offline
Reply With Quote
View Public Profile
 
Old 06-11-2005, 01:51 PM
feraira's Avatar
BeTheBand!

Posts: 350
Trades: 0
Ok great, I missed that one after checking it all... Dam, thanks anyway man. This file is used when the form is submitted to it. The only problem is that the error checking works no matter what, the data isn't get sent to the file, any help on this one?

Form > POST > php

php > process > insert

That's not happening though?
feraira is offline
Reply With Quote
View Public Profile
 
Old 06-11-2005, 02:30 PM
Logical Program's Avatar
Super Talker

Posts: 130
Location: Atlanta, Georgia
Trades: 0
Put a Curlybrace on the line before PHP closes. }, you forgot to close off your if...else statement.
__________________

Please login or register to view this content. Registration is FREE
- For all of your website programming and design needs, make the logical choice. Logical Assistance For Real-World Clients.
Logical Program is offline
Reply With Quote
View Public Profile Visit Logical Program's homepage!
 
Old 06-11-2005, 04:28 PM
feraira's Avatar
BeTheBand!

Posts: 350
Trades: 0
Ahha, this has been sorted now! I had put $_GET instead of $_POST, sorry for the post guys! I started a new topic for it, rather pointless... Thanks for the help though!
Also I did forget to close the IF statement, noticed that too, thanks mate!
feraira is offline
Reply With Quote
View Public Profile
 
Old 06-11-2005, 04:31 PM
feraira's Avatar
BeTheBand!

Posts: 350
Trades: 0
OK, another small problem... I get this error:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/xingeh/public_html/test/viewtutorial.php on line 11

The code is:
PHP Code:
<?

$id 
$_GET['id'];

mysql_connect("localhost""lalala""lala") or die("Could not connect to DB because: ".mysql_error());
mysql_select_db("lalalalala") or die("Could not select the DB because: ".mysql_error());

$query "SELECT * FROM tutorials WHERE id = ".$id." LIMIT 1";
mysql_query($query) or die("Could not do query because: ".mysql_error());

while(
$row=mysql_fetch_array($query)) {

$id $row['id'];
$tname $row['tname'];
$ttype $row['ttype'];
$tutorial $row['tutorial'];
$author $row['author'];
$caption $row['caption'];

echo(
"Tutorial $id");
echo(
"<br>");
echo(
"$tname");
echo(
"<br><br>");
echo(
"$tutorial");

}
mysql_close();
?>
Whats wrong with that?
feraira is offline
Reply With Quote
View Public Profile
 
Old 06-11-2005, 05:13 PM
Monkeon's Avatar
Skilled Talker

Posts: 59
Trades: 0
heh heh, you're trying to fetch this "SELECT * FROM tutorials WHERE id = ".$id." LIMIT 1";
instead of the actual result of the query.


you need to put something like this in

PHP Code:
$result mysql_query("SELECT * FROM tutorials WHERE id = ".$id." LIMIT 1");
while(
$row=mysql_fetch_array($result)) { 

ect ect 
__________________

Please login or register to view this content. Registration is FREE
FREE Online Dating!
Meet your perfect match online right now!
Monkeon is offline
Reply With Quote
View Public Profile
 
Old 06-11-2005, 05:23 PM
feraira's Avatar
BeTheBand!

Posts: 350
Trades: 0
But isn't that just the same? Making the variable, carrying out the query, doing the fetch function... Same both ways isn't it?

Hehe, I have sorted this problem now again lol, and another has arise ...

This time it is:

Could not do query because: Unknown column 'PHP' in 'where clause'

PHP Code:
<?

$cat 
$_GET['cat'];

mysql_connect("localhost""lala""lala") or die("Could not connect to DB because: ".mysql_error());
mysql_select_db("lala") or die("Could not select the DB because: ".mysql_error());

$query mysql_query("SELECT * FROM tutorials WHERE ttype = ".$cat."")
or die(
"Could not do query because: ".mysql_error());

while(
$row=mysql_fetch_array($query)) {

$id $row['id'];
$tname $row['tname'];
$ttype $row['ttype'];
$tutorial $row['tutorial'];
$author $row['author'];
$caption $row['caption'];

$tname stripslashes($tname);
$caption stripslashes($caption);
$tutorial stripslashes($tutorial);

echo(
"$ttype");
echo(
"<br>");
echo(
"$tname");
echo(
"<br><br>");
echo(
"$caption");
echo(
"<br><br>");

}
mysql_close();
?>
feraira is offline
Reply With Quote
View Public Profile
 
Old 06-11-2005, 06:32 PM
Logical Program's Avatar
Super Talker

Posts: 130
Location: Atlanta, Georgia
Trades: 0
That just means the query returned 0 results. I wouldn't suggest making the script die if the query fails. You should designate a specific output if the query returns 0 results rather than making the entire script die.
__________________

Please login or register to view this content. Registration is FREE
- For all of your website programming and design needs, make the logical choice. Logical Assistance For Real-World Clients.
Logical Program is offline
Reply With Quote
View Public Profile Visit Logical Program's homepage!
 
Old 06-11-2005, 06:35 PM
feraira's Avatar
BeTheBand!

Posts: 350
Trades: 0
OK, I will try that, but the thing is, in the database.. $ttype is PHP for 2 items in the database (because there are only 2, im just testing it), so why does it give an error?

Last edited by feraira; 06-12-2005 at 07:38 AM.. Reason: Wrong variable name!
feraira is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Little help please?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.34977 seconds with 12 queries