MySQL is not working with PHP

Guys, I have a problem with my PHP and MySQL, and I think its either my code or the way I installed MySQL and PHP. This is what happens:

$QueryResult = @mysqli_query($DBConnect, $SQLString)
Or die(“

unable to execute query.

”);
. "

Error code " . mysqli_errno($DBConnect)
. ": " . mysqli_error($DBConnect)) . “

”;
echo “

Successfully executed the query.

”;
if (mysqli_num_rows($QueryResult) == 0)
die(“

You must enter a valid Email Address and Password! Click your browser’s Back button to return to the login page.</p.”);
mysqli_close($DBConnect);

Im trying to get the $QueryResult to display, but it will not. I am using a sample From a Book so I think the Code Works. Everything Else Works. I can connect to the DB, just not this Query Result…

HELP!!!

Hi there,

The first thing I would point out is this bit:
[php] Or die(“

unable to execute query.

”);
. "

Error code " . mysqli_errno($DBConnect)
. ": " . mysqli_error($DBConnect)) . “

”;[/php]

It may help if you replace the first “.” after the or die() statement with an echo:
[php] Or die(“

unable to execute query.

”);
echo "

Error code " . mysqli_errno($DBConnect)
. ": " . mysqli_error($DBConnect)) . “

”;[/php]

Make sure you’re fetching records from a table with pre-populated data…

or can you print the value you assigned to $SQLString? Your query might be the problem.

You should not have ended the code here with the ;
[php] Or die(“

unable to execute query.

”);[/php]

next you had an extra ) here :
[php] . ": " . mysqli_error($DBConnect)) . “

”;[/php]

here ya go, a cleaned up code,
[php]

$QueryResult = @mysqli_query($DBConnect, $SQLString)
Or die(“

unable to execute query.

”)
. "

Error code " . mysqli_errno($DBConnect)
. ": " . mysqli_error($DBConnect) . “

”;
echo “

Successfully executed the query.

”;
if (mysqli_num_rows($QueryResult) == 0)
die(“

You must enter a valid Email Address and Password! Click your browser’s Back button to return to the login page.</p.”);
mysqli_close($DBConnect); [/php]

forgot to add this, since you added the period you were trying to append the data to the original query or die section, but once you add the ; semi-colon you are finalizing the statement so you in essence trying to append everything after the period to nothing because there was no more open statements.

Sponsor our Newsletter | Privacy Policy | Terms of Service