Jump to content

Empty Query?


elite_prodigy

Recommended Posts

Why is navId comming out blank?

 

 

<?php

include 'config.php';
include 'functions.php';

mysql_select_db('exembar_site');

if( isset($_POST['title']) & isset($_POST['display']) & isset($_POST['topbar']) & isset($_POST['content'])) {
$title = $_POST['title'];
$display = $_POST['display'];
$top = $_POST['topbar'];
$content = $_POST['content'];

//sanitize everything
$title = sanitize($title);
$display = sanitize($display);
$top = sanitize($top);
$content = sanitize($content);

$sql = "INSERT INTO `navigation` VALUES('','{$display}','')";
mysql_query($sql) or die(mysql_error());

$sql = "SELECT * FROM `navigation` WHERE `display`='{$display}'";
$res = mysql_query($sql) or die(mysql_error());
$stuff = mysql_fetch_array($res) or die(mysql_error());

$navId = $stuff['id'];
echo $navID;

$sql = "INSERT INTO `pages` VALUES('','{$title}','{$navID}')";
mysql_query($sql) or die(mysql_error());

$sql = "INSERT INTO `pgContent` VALUES('','{$top}','{$content}','{$navID}')";
mysql_query($sql) or die(mysql_error());

//header("location:{$root}");

}
else {

echo "Variables Were Not Defined!";

}

?>

 

I don't know what to try, as i've tried it all....

Link to comment
https://forums.phpfreaks.com/topic/136305-empty-query/
Share on other sites

I am not an expert on this stuff by any means and I may be wrong here, but this don't look right to me..

 

$sql = "INSERT INTO `navigation` VALUES('','{$display}','')";

 

To the best of my knowledge, an insert statement should look like this..

 

$sql = INSERT INTO tableName (fieldName1, fieldName2, fieldName3) VALUES ('$value1', '$value2', '$value3');

 

Thats what I can see offhand... but like I said I could be wrong about the structure of your query.

 

Nate

 

Link to comment
https://forums.phpfreaks.com/topic/136305-empty-query/#findComment-711166
Share on other sites

I am not an expert on this stuff by any means and I may be wrong here, but this don't look right to me..

 

$sql = "INSERT INTO `navigation` VALUES('','{$display}','')";

 

To the best of my knowledge, an insert statement should look like this..

 

$sql = INSERT INTO tableName (fieldName1, fieldName2, fieldName3) VALUES ('$value1', '$value2', '$value3');

 

Thats what I can see offhand... but like I said I could be wrong about the structure of your query.

 

Nate

 

 

You don't have to specify columns in an insert statement. It will insert the data in the order the columns are stored in the table hence the '' (blanks) in the values.

However as a best practice I would always state the columns.

 

However I've never used { } around my values. So not sure if this is correct.

Link to comment
https://forums.phpfreaks.com/topic/136305-empty-query/#findComment-711231
Share on other sites

I am not an expert on this stuff by any means and I may be wrong here, but this don't look right to me..

 

$sql = "INSERT INTO `navigation` VALUES('','{$display}','')";

 

To the best of my knowledge, an insert statement should look like this..

 

$sql = INSERT INTO tableName (fieldName1, fieldName2, fieldName3) VALUES ('$value1', '$value2', '$value3');

 

Thats what I can see offhand... but like I said I could be wrong about the structure of your query.

 

Nate

 

 

You don't have to specify columns in an insert statement. It will insert the data in the order the columns are stored in the table hence the '' (blanks) in the values.

However as a best practice I would always state the columns.

 

However I've never used { } around my values. So not sure if this is correct.

 

NEVER use that kind of query structure. What if you decide to add a column later on?

Link to comment
https://forums.phpfreaks.com/topic/136305-empty-query/#findComment-711234
Share on other sites

Did you try the whole $navID vs $navId thing..... that would make a big difference as has been pointed out...

 

I would say try echoing out your query and make sure that the values are filled in like your expecting.

 

When I have issues with a sql statement, I generally will echo them out and try them in phpmyadmin... found a lot of issues that way.

 

Thats the only 2 things I can suggest.

 

Nate

Link to comment
https://forums.phpfreaks.com/topic/136305-empty-query/#findComment-712183
Share on other sites

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.