Futurama   Planet Express Employee Lounge
The Futurama Message Board

Design and Support by Can't get enough Futurama
Help Search Futurama chat Login Register

PEEL - The Futurama Message Board    General Futurama Forum Category    Websites/Reviews    HTML Hic-ups, PHP Problems « previous next »
Author Topic: HTML Hic-ups, PHP Problems  (Read 930 times)
Pages: [1] Print
aslate

Space Pope
****
« on: 04-06-2004 16:14 »
« Last Edit on: 04-06-2004 16:14 »

PEEL has a vast number of web-affiliated people, each with in-depth knowledge of most languages that get used in websites. I know that a lot of people have problems that seem simple to others but they just don't know how to fix it and so i decided to make a thread for it.

Do you have a problem that someone else might be able to solve? Try posting it here!

I'll start. I'm trying to write myself a basic PHP script that lets me interface with MySQL. I have a form, textarea and my info to be submitted to MySQL. The only problem is every ' comes out as \' and thus confuses MySQL. How to i stop them coming out as \'? Can i just tell it to run a textfile outputted by a local MySQL dump using PHP?
Mercapto

Professor
*
« Reply #1 on: 04-06-2004 17:09 »

This isn't directly related to your problem, but if you want a PHP-based interface for MySQL, you should really consider using phpMyAdmin.

It has pretty much everything you'll ever need.
aslate

Space Pope
****
« Reply #2 on: 04-06-2004 17:12 »

My host (Alltoons) currently won't let me use phpMyAdmin, but i do use it on my PC when testing stuff. Thus i'm trying to create a simple way to input large[ish] amounts of data using PHP and a textarea.
Mercapto

Professor
*
« Reply #3 on: 04-06-2004 17:14 »

Okay, I was just making sure you weren't trying to reinvent the wheel.  :p

As for your problem, would you mind showing us your code?
aslate

Space Pope
****
« Reply #4 on: 04-06-2004 17:26 »
« Last Edit on: 04-06-2004 17:26 »

Code: [Select]
<?
include "style1.php";

$sql_info = $_POST[']sql_info'];
if ($sql_info != '') {
$conn=mysql_connect("HOST", "USERNAME", "PASSWORD" );
@mysql_select_db("alltoon_thefryhole", $conn);

$sql = "$sql_info";
$result = mysql_query($sql, $conn);

if ($result) { echo "Data added"; }
else { echo "Something went wrong<br>"; $result = die(mysql_error()); echo $result; }

} else {
echo "<b>MySQL Inputs:</b><br><br>";


echo "<table width=100% border=0><tr><td rowspan=4 width=20> </td><td width=10%><form action='mysql_forms.php' method='POST'>";
echo "<td><b>$style[2]Input:$style[1]</font>:</b></td><td><textarea cols='30' rows='5' name='sql_info'></textarea></td></tr>";
echo "<td colspan=3 align=center><br><input type='submit' value='Submit MySQL Command'></td></tr>";
echo "</form>";
echo "</table>";
}

include "style2.php";
?>

Just removed the username and password bits, hope it's obvious what i'm doing.

EDIT: I know it works because i can do stuff like drop tables, but it's the \' confusing MySQL.
Mercapto

Professor
*
« Reply #5 on: 04-06-2004 18:07 »

Try replacing
Code: [Select]
$sql = "$sql_info";
with

Code: [Select]
$sql = stripslashes($sql_info);
[AdAM]

Bending Unit
***
« Reply #6 on: 04-06-2004 18:11 »

hmm, could you give an example of which sql commands aren't working?

I tried your code and it works correctly for me with an command like this:

INSERT INTO `users` VALUES (1, 'test','test@test.com');

The problem you might have is that mysql makes a difference between ' and ´ (see above example...).
Also this line seems pretty useless:
$sql = "$sql_info";
(or did I miss something?)
 
aslate

Space Pope
****
« Reply #7 on: 04-06-2004 18:12 »
« Last Edit on: 04-06-2004 18:12 »

Ah stripslashes(), where have you been? Thanks Mercapto. Only problem is i can only do one line of script at a time, damn. Ah well, part way there.

EDIT: It probably is useless, i have a lot of code like that which i really should clean up. And i never tried using `, just '. Anyway, it works with stripslashes(). It's whenever a command has ' in it, because PHP doesn't like using 's.
[AdAM]

Bending Unit
***
« Reply #8 on: 04-06-2004 18:17 »

That's strange as it works for me when using 's...
Maybe a php.ini configuration thingy.
Mercapto

Professor
*
« Reply #9 on: 04-06-2004 18:18 »

Must be, it doesn't work for me with aslate's original script on PHP 4.3.4.
[AdAM]

Bending Unit
***
« Reply #10 on: 04-06-2004 18:21 »

Ahh, I just found the bastard:

; - magic_quotes_gpc = Off         [Performance]
;     Input data is no longer escaped with slashes so that it can be sent into
;     SQL databases without further manipulation.
aslate

Space Pope
****
« Reply #11 on: 04-06-2004 18:34 »

That's the problem! Too bad i can't change that.
Pages: [1] Print 
« previous next »
Jump to:  

SMF 2.0.17 | SMF © 2019, Simple Machines | some icons from famfamfam
Legal Notice & Disclaimer: "Futurama" TM and copyright FOX, its related entities and the Curiosity Company. All rights reserved. Any reproduction, duplication or distribution of these materials in any form is expressly prohibited. As a fan site, this Futurama forum, its operators, and any content on the site relating to "Futurama" are not explicitely authorized by Fox or the Curiosity Company.
Page created in 0.213 seconds with 35 queries.