Jump to content

[SOLVED] mysql dump, and die


Q695

Recommended Posts

The site I'm using to load data into a database was working fine, now it's dumping data to the browser and dieing, and I don't know why.

 

<?php
if ($catagory && $column_name){
$sql="INSERT INTO categories (
`name` ,
`type` ,
`column_name` ,
'image',
'text'
)
VALUES (
'$catagory', '0', '$column_name', '$image', '$text');";
$result=@mysql_query($sql,$con) or die($sql);
}
?>

Link to comment
https://forums.phpfreaks.com/topic/145375-solved-mysql-dump-and-die/
Share on other sites

death does both the mysql error, and the sql statement, so I like it better :D

 

It dumps $sql

 

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''image', 'text' ) VALUES ( 'Electrical', '0', 'Electrical', 'http://www.qualityc' at line 5

The whole script is:

<?php
$catagory=$_POST[catagory];
$column_name=$_POST[column_name];
$image=$_POST[image];
$text=$_POST[text];


if ($catagory && $column_name && $image && $text){
$sql="INSERT INTO categories (
`name` ,
`type` ,
`column_name` ,
'image',
'text'
)
VALUES (
'$catagory', '0', '$column_name', '$image', '$text');";
$result=@mysql_query($sql,$con) or die(death($sql));
}
?>

To some degree it's not picky at all. You don't need the quotes around column names. Actually you don't need them around values either, though for security purposes, it's better to put them around values. But you can leave them off of the column names with no worries.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.