I have a MySQL db, with a functioning table. I am trying to get to it via a php page. The whole setup is WAMP2. Everything seems to work OK, I have connected to the MySQL and pulled back a basic 'select all' via PHP. I am now trying to search via PHP.
I can test the connection that comes with the install:
<?php
$link = mysql_connect('localhost','testuser','testpass');
if (!$link) {
die('Could not connect to MySQL: ' . mysql_error());
}
echo 'Connection OK'; mysql_close($link);
?>
And I see the 'Connection OK' reply. Every attempt to connect with the table has failed in various ways, and I suspect I have something amiss with my config of either apache/php/mysql.
I tried the code here: http://www.tutorialized.com/view/tutorial/PHP-MySQL-database-search/416, and I get an error:
Parse error: syntax error, unexpected T_VARIABLE in C:\wamp\www\search3.php on line 22
the line that gets the error?
$trimmed = trim($var) //trim whitespace from the stored variable
// rows to return
$limit=10; // line 22
My last attempt is to try this code: http://www.wallpaperama.com/forums/simple-php-mysql-connection-test-script-example-t5702.html which according to its preamble should let me test any connection.
When I run the page, I get errors pointing at any variable I have 'Notice: Undefined index" or "Notice: Undefined variable:".
I tried suppressing the warning, by using the @ prefix to a variable to see if it was a critical failure, and I get a follow on error of 'Parse error: syntax error,' or similar that relates to the function the variable is invoked for.
I suspect that there is something amiss in the variable declaration / handling, but I don't know where to look for pointers. I have checked the various logs and there is nothing I can see that illuminates further than the errors thrown on the browser page.
I'm a bit lost as to where to look next - this is my first play with PHP. Any suggestions?
the line that gets the error?no, something BEFORE that line (missing;or}or)) triggers that error. Show the previous line.