Jump to content

[SOLVED] Newb working on a database problem


TheTrav

Recommended Posts

I am making a simple guestbook using php and mysql. This code grabs an image using a database connection - eventually I will be using it as a captcha.

 

Everything works good on my home server running WAMP, but when I upload it to my website nothing will process past the mysqli_connect line (no php, no html, nothing). I asked customer service and mysqli is enabled.

 

Any ideas for a newbie?

 

Thanks in advance.

 

<?php

						$dbUser = "*****";
						$dbIP = "*****";
						$dbPwd = "****";

                                this line works -> echo "test 1234";

						$dbConnect = @mysqli_connect($dbIP, $dbUser, $dbPwd)
    							Or die("<p>Unable to connect to the database server.</p>" . "<p>Error Code " . mysqli_connect_errno() . ": " . mysqli_connect_error() . "</p>");

                              this line doesn't -> echo "test 1234";

						$dbName = "TravisH_captcha";

						if (!@mysqli_select_db($dbConnect, $dbName))
        							die("<p>Unable to connect to the database.</p>");

						$tableName = "images";
						$sqlString = "SELECT * FROM images ORDER BY RAND() LIMIT 1";
						$queryResult = @mysqli_query($dbConnect, $sqlString);
						$row = mysqli_fetch_assoc($queryResult);

						echo("<input type='text' size='3' maxlength='4' name='imageTextTb'></td><td><img src='{$row['imageLocation']}' class='img' alt='Please enter the text of this image into the text area on the left.' /></td>");
						echo("<input type='hidden' name='captcha' value='{$row['imageID']}'>");

						mysqli_free_result($queryResult);
						mysqli_close($dbConnect);
    					?>

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.