FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


php and am lost...





Saber
OK well Im working on this php news poster... or thats the idea.... at the moment Im lost because it seems to take the data then... just loses it..... any php guru out there that knows what thing(s) (I bet a lot) Im doing wrong?

-setup the table in a database http://pastebin.com/675555
-the database username, name, and pass http://pastebin.com/675563
-page for the form, http://pastebin.com/675572
-attempting to insret data, http://pastebin.com/675565
-and then attempting to read the data to a page, http://pastebin.com/675574

so yah.... Im here all day....
mathiaus
woot someone actually used the pastebin! Smile
Well to save having to upload all that and create a new database,
1) Are there any errors?
2) Check in phpmyadmin to see if the news is actually being stored or not so we know wether the problems before or after that
Saber
@mathiaus thanks for the quick reply. I guess I should have said, there are no errors, and checking phpmyadmin (something I had forgot about) I checked to see if the table was there... and it is... it just has no Data.
Thus it seems that the data gets lost in the insert.
thnn
change this line ( line 28 )
Code:

$query = "INSERT INTO newspost ('','newstitle','loginname','date','news') VALUES('','$newstitle','$loginname','$date','$news');";


To this

Code:
$query = "INSERT INTO newspost ('newstitle','loginname','date','news')  VALUES ('$newstitle','$loginname','$date','$news')";


provided the id field is an auto_increment. You also didnt need the first ; in this piece here
Code:
 );";
Saber
hmm thanks for the correct way to do the code, but I still have the same problem. Anyone else have an input?
Stubru Freak
Maybe this works?

Code:
$query = "INSERT INTO `newspost` (`newstitle`,`loginname`,`date`,`news`)  VALUES ('$newstitle','$loginname','$date','$news')";
krazycapital
If that doesn't work, this may:
Code:
$query = "INSERT INTO `newspost` (`newstitle`,`loginname`,`date`,`news`)  VALUES ('".$newstitle."','".$loginname."','".$date."','".$news."')";
Saber
hmmm well now I dont think I changed anything but now its just not working... Also those links to the code were reset, thus I made these html files with the code in it... so I know these files dont work but you can see the code with the source http://kodamakage.frih.net/
Stubru Freak
Saber wrote:
hmmm well now I dont think I changed anything but now its just not working... Also those links to teh code were reset, thus I made these html files with the code in it... so I know these files dont work but you can see the code with the source http://kodamakage.frih.net/


Try what krazycapital and I said.
Saber
@Stubru Freak and krazycapital
-_- that didnt fix it, but thanks for the help. I still know thats its not inputting right.. and just dont have a clue why not..
Stubru Freak
Saber wrote:
@Stubru Freak and krazycapital
-_- that didnt fix it, but thanks for the help. I still know thats its not inputting right.. and just dont have a clue why not..


Are you sure you don't get any error, and that you are using backticks (``) instead of normal single quotes ('') around the table and fieldnames?
BlackSkad
Nope he isn't. Try using those backticks, but I don't think that's the solution.
At the moment, the script "insert.php" gives an "unexpected ;" at line 29 (I didn't manage to find the error though)
Secondly, I would advise you to use <?php instead of <?, as the last one is also used for xml-parsing.
Thirdly, also on mysql_query, use the mysql_error. This helped me out of some SQL-problems a lot of time Smile
Code:
mysql_query($query) or die (mysql_error());


I hope something of this helped
BlackSkad
Saber
@Stubru Freak, thank you very much. It was those back ticks. I learned something again..
@everyone else, thanks for your help too.
Related topics
Gaming Ladders (PHP)
What - I had lost at Karen Mok's concert
Php Code Trouble Set-up
Database/PHP/Cron Jobs [Resolved]
[PHP] Weird Errors and lost files.
Please help with php-quick question
TWO Problems, Password lost and diskspace :-(
php nuke - 15FRI$ reward.
PHP Username And Password Login Script, Using those to creat
PHP OOP
PHP as site template?
My website database is lost, what is going on?
_GET LOST
file lost -- help
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.