PHP 5 problem with issuing mysql commands from browser....

  • fotbon
  • Novice
  • Novice
  • fotbon
  • Posts: 20

Post 3+ Months Ago

howdy gents,

I've hit a php roadblock--I've asked a few php-experienced friends and it has stumped them all.

I've got a php file that should insert given variables into a database (much like a guestbook script). When I run the file from an SSH client (replacing posted variables with internal ones, of course), it parses perfectly and modifies the database as desired. From a browser, however, it will not load anything after the mysql commands (it won't even die when the command fails).

Here is the code:

Code: [ Select ]

$data = "howdy";
$query = "INSERT INTO guests ";
$query .= "(guest_name)";
$query .= " values ('$data')";

echo "$query";
mysql_pconnect('localhost' , 'user' , 'password');

echo "$query";
mysql_query($query) or die ("Error: " . mysql_error());

  1. <?php
  2. error_reporting(E_ALL);
  3. $data = "howdy";
  4. $query = "INSERT INTO guests ";
  5. $query .= "(guest_name)";
  6. $query .= " values ('$data')";
  7. echo "$query";
  8. mysql_pconnect('localhost' , 'user' , 'password');
  9. mysql_select_db("guestbook");
  10. echo "$query";
  11. mysql_query($query) or die ("Error: " . mysql_error());
  12. ?>

It echoes the first time but not the second.

(note: the mysql command was force installed rather than mysqli because the mysqli package was corrupt on the installer. I haven't yet tried to reinstall mysqli, mainly because the admin is out of town :roll: )

  • _Leo_
  • Proficient
  • Proficient
  • User avatar
  • Posts: 279
  • Loc: Buenos Aires, Argentina

Post 3+ Months Ago

Have you checked the web-server error log?

If the second echo does not work, then the web-server process is death for some reason. Apache web server usually sends this kind of errors to errors.log

From your description, I think you need all that installation to get checked. If PHP dies, something is REALLY wrong.
  • Scorpius
  • Proficient
  • Proficient
  • User avatar
  • Posts: 401
  • Loc: Scorpion Hole

Post 3+ Months Ago

Also you could put:
Code: [ Select ]
or die ("Error: " . mysql_error());

After every mysql command so it will tell you the error when it finds it, if it is a mysql error. You could also try to just connect with mysql_connect, unless you need a persistant connection.

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 55 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum

© 1998-2017. Ozzu® is a registered trademark of Unmelted, LLC.