Skip to content | Skip to navigation
<?php
if ( $auth > 0 )
{
$form = "<form action=\"$PHP_SELF\" method=\"post\">";
$form.= "<B>Blog Entry Form</B><BR><BR>";
$form.= "Title: <input type=\"text\" size=\"100\" name=\"title\" style=\"border: dashed white 1px; background-color: black; color: white\"/><BR><BR>";
$form.= "<textarea rows=\"15\" cols=\"85\" border=\"0\" style=\"font-family: Arial; border: 1px dashed; background-color: black; color: white\" name=\"blog\">";
$form.= "</textarea><BR>";
$form.= "<button type=\"submit\" style=\"width: 100; border: dashed white 1px; background-color: #400000; color: white\">Ok</button>";
$form.= "<button type=\"reset\" style=\"width: 100; border: 1px dashed white; background-color: black; color: white\">Reset</button>";
$form.= "</form>";
if ( !$submit ) { $msg = $form; } else
/* if ( !$blog or !$title )
{
$msg = $form;
$msg .= "<H2>You didn't write an entry! Try your luck again...</H2><BR>";
} else*/
{
echo("I was here");
mysql_connect("50free.net:3306", "****", "****") or die("COULD NOT ACCESS THE DATABASE!");
$rs = mysql_select_db("deadimp_eljefe") or die ("Could not select the database");
$sql = "insert into blog (user,icon,blog,title) VALUES('$username','$icon','$blog','$title')";
mysql_query($sql) or die ("Could not execute SQL query");
$msg = "<H3>Your blog has been submitted</H3><BR><a href=\"http://eljefe.50free.net\" target=\"_parent\">Click here to view.</a>";
}
} else
{ $msg = "<H3>NOT LOGGED IN!</H3>"; }
echo($msg);
echo("$username , $icon , $blog , $title");
echo ( mysql_error());
echo ($sql);
?>
I need some help. This is obviously a form to submit an entry. The form consists of 1 input, 1 text area, 1 submit class button and 1 reset class button.
Unfortunately, it's not even going into the sql query and connect code. All the variables are coming through (username, icon, etc.), only somewhere in one of the if statements its not going to the actualy sql part. If you look at the bottom, I put those echos to debuc, and the first echo"username", etc. displays all the correct stuff, and the mysql_error doesn't return and the echo ($sql) DOESN'T RETURN ANTYHING.
Its just not going into the sql portion. The sql query works, i tried it in phpmyadmin and it works, its just not even executing that section of code.
... help??? ...
Pistol Grip Pump In My Lap At All Times
Note: for better reading / coding standards it is VERY useful if you would write the SQL commands ALL in UPPERCASE, like in following example:
$sql_query = "SELECT * FROM my_table ORDER BY name,timestamp";
note #2: Jaz is AFAIK the Perl crack, not the PHP enthusiast
possible solution(s) to your problem could be:
a) set all inserted data into double quotes, like this:
$sql_query = "INSERT INTO katalog (user,icon,blog,title) "
."VALUES(\"".$username."\",\"".$icon."\"',\"".$blog."\",\"".$title."\");"
b) theres some apostroph missing at the end of the query string
c) the mysql serv does not resolve correctly at all
a good option to prove your own data is to set up your own WAMP/LAMP system locally on your very own computer, either by adding manually all needed stuff or using some good package, like the current version of XAMPP (1.4.4), which is available both for Win32 and for Linux (of course ;)). You can find mentioned package at following URL:
http://www.apachefriends.org/en/xampp.html
After installing you easily can upload/copy your current blog project to a new directory inside the htdoccs-directory, start up the system as said online in the FAQ/documentation, and feel happy while testing out your work on your own computer, finding out why you cant get your DB query running :)
good luck,
cu, w0lf.
I prefer lifing in a nightmare called reality.
This post was edited by ginsterbusch on May 11, 2004.
Unfortunately, the capitalization and the double quotes are not teh problem. I've already tried out the query syntax itself in phpmyadmin, and it works fine, its just that when submit is clicked, it doesn't even go into that section of coding (starting with the "echo ("i was here")" part....
Also, the server respots (it accesses the userdatabase reading and it acceses the blog databse to post the articles on the front page.
I'll look into Xampp. i have apache installed on my computer, but unfortunately mysql hates windows...
Pistol Grip Pump In My Lap At All Times
This post was edited by eljefe on May 11, 2004.
I'll look into Xampp. i have apache installed on my computer, but unfortunately mysql hates windows..
strange. on both my windows systems (now minus one) Ive got MySQL up and running very stable ... maybe you got not enough system ressources? Altough I couldnt image that you would got have a less powerful machine than mine (dead notebook: celeron 533, 196 MB RAM; working desktop: idt w2c 233, 96 MB RAM).
Normally, it should work fine. Suggestion for controlling/administrating MySQL on Win32 would be to help yourself to a copy of MySQLCC (MySQL ControlCenter). Very nice, stable, and a good Windows GUI-based replacement for phpMyAdmin ;)
about your current problem: Im going to rework your posted code and afterwards try to find out whats wrong with it. ;)
cu, w0lf.
I prefer lifing in a nightmare called reality.
Hm ... you shouldnt do that. Just put the thing up in its default install, and let it roll.
Another option would be: your remote host doesnt like you at all, so you'd be better in searching a commercial solution including some GOOD support - there are lots around - I personally recommend manitu, where i am not only let host nearly all of my domains, but also am a reseller ;)
- see, its just way more fun hacking together your own blog system if you do it on a professionell hosted platform where you also get some folks helping you out when something doesnt work the way you want, even if its sunday night :)
cu, w0lf.
I prefer lifing in a nightmare called reality.
Ha,
what an evil bug .. looks like you forgot to add the $rs-link thats supposed to give mysql / php the exact info WHICH table you're currently working on:
$rs = mysql_select_db("deadimp_eljefe") or die ("Could not select the database");
$sql = "insert into blog (user,icon,blog,title) VALUES('$username','$icon','$blog','$title')";
on the above position, you've got initialized a link called $rs, which now HAS TO BE added to the mysql_query-function to work properly:
mysql_query($sql) or die ("Could not execute SQL query");
Should be:
mysql_query($sql,$rs) (...)
Update: after doing a bit of reading in the php man pages, it looks like it wasnt neccessary passing over said link variable, but then Im doing that all the time. Another possible solution could be:
(...) mysql_query() will also fail and return FALSE if you don't have permission to access the table(s) referenced by the query.
And third option could be: you're trying to either access the wrong port or server. Best solution still is to test it out on your local system, and if it works there, you gotta change the mysql_connect-data so you can try out if it works out well with your remote db.
cu, w0lf.
I prefer lifing in a nightmare called reality.